Class: Spirit::Manifest
- Inherits:
-
Hash
- Object
- Hash
- Spirit::Manifest
- Defined in:
- lib/spirit/manifest.rb
Overview
Manifest described in YAML. Values in this hash should not be trusted, since they are provided by the user.
Constant Summary collapse
- TYPES =
Expected types.
{ verify: { 'bin' => 'string', 'arg_prefix' => 'string' }, title: 'string', description: 'string', categories: %w[string array], static_paths: %w[string array] }.freeze
Class Method Summary collapse
-
.load(source) ⇒ Manifest
Load configuration from given string.
-
.load_file(path) ⇒ Manifest
Load configuration from given yaml file.
Instance Method Summary collapse
-
#initialize(hash) ⇒ Manifest
constructor
Creates a new manifest from the given source.
Constructor Details
#initialize(hash) ⇒ Manifest
Creates a new manifest from the given source.
21 22 23 24 25 26 27 |
# File 'lib/spirit/manifest.rb', line 21 def initialize(hash) super nil hash ||= {} bad_file(hash.class) unless hash.is_a? Hash merge! hash.symbolize_keys check_types end |
Class Method Details
.load(source) ⇒ Manifest
Load configuration from given string.
32 33 34 35 36 |
# File 'lib/spirit/manifest.rb', line 32 def self.load(source) new ::YAML.load source rescue ::Psych::SyntaxError => e raise ManifestError, 'Unexpected syntax error - ' + e. end |
.load_file(path) ⇒ Manifest
Load configuration from given yaml file.
41 42 43 44 45 |
# File 'lib/spirit/manifest.rb', line 41 def self.load_file(path) File.open(path, 'r:utf-8') { |f| new ::YAML.load f.read } rescue ::Psych::SyntaxError => e raise ManifestError, 'Unexpected syntax error - ' + e. end |