Class: Hippo::Manifest
- Inherits:
-
Object
- Object
- Hippo::Manifest
- Defined in:
- lib/hippo/manifest.rb
Instance Attribute Summary collapse
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Class Method Summary collapse
Instance Method Summary collapse
- #bootstrap ⇒ Object
- #commands ⇒ Object
- #config ⇒ Object
- #console ⇒ Object
- #images ⇒ Object
-
#initialize(options, root) ⇒ Manifest
constructor
A new instance of Manifest.
- #name ⇒ Object
-
#objects(path, decorator: nil) ⇒ Array<Hash>
Load all YAML objects at a given path and return them.
- #readme ⇒ Object
- #template_vars ⇒ Object
Constructor Details
Instance Attribute Details
#root ⇒ Object (readonly)
Returns the value of attribute root.
24 25 26 |
# File 'lib/hippo/manifest.rb', line 24 def root @root end |
Class Method Details
.load_from_file(path) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/hippo/manifest.rb', line 14 def load_from_file(path) unless File.file?(path) raise Error, "Hippofile file not found at #{path}" end root = File.dirname(path) new(Util.load_yaml_from_file(path).first, root) end |
Instance Method Details
#bootstrap ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/hippo/manifest.rb', line 47 def bootstrap @bootstrap ||= begin bootstrap_file = File.join(@root, 'bootstrap.yaml') if File.file?(bootstrap_file) YAML.load_file(bootstrap_file) else {} end end end |
#commands ⇒ Object
39 40 41 |
# File 'lib/hippo/manifest.rb', line 39 def commands @options['commands'] || {} end |
#config ⇒ Object
43 44 45 |
# File 'lib/hippo/manifest.rb', line 43 def config @options['config'] || {} end |
#console ⇒ Object
35 36 37 |
# File 'lib/hippo/manifest.rb', line 35 def console @options['console'] end |
#images ⇒ Object
76 77 78 79 80 |
# File 'lib/hippo/manifest.rb', line 76 def images return {} unless @options['images'].is_a?(Hash) @options['images'] end |
#name ⇒ Object
31 32 33 |
# File 'lib/hippo/manifest.rb', line 31 def name @options['name'] || 'app' end |
#objects(path, decorator: nil) ⇒ Array<Hash>
Load all YAML objects at a given path and return them.
87 88 89 |
# File 'lib/hippo/manifest.rb', line 87 def objects(path, decorator: nil) Util.load_objects_from_path(File.join(@root, path, '*.{yaml,yml}'), decorator: decorator) end |
#readme ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/hippo/manifest.rb', line 58 def readme return @readme if instance_variable_defined?('@readme') path = File.join(@root, 'readme.txt') unless File.file?(path) @readme = nil return end @readme = File.read(path) end |
#template_vars ⇒ Object
70 71 72 73 74 |
# File 'lib/hippo/manifest.rb', line 70 def template_vars { 'name' => name } end |