Class: Enc::Manifest
- Inherits:
-
Object
- Object
- Enc::Manifest
- Defined in:
- lib/enc/manifest.rb
Instance Attribute Summary collapse
-
#hostname ⇒ Object
readonly
Returns the value of attribute hostname.
-
#roles ⇒ Object
readonly
Returns the value of attribute roles.
Instance Method Summary collapse
- #file(role) ⇒ Object
- #files ⇒ Object
- #hash ⇒ Object
-
#initialize(hostname, roles) ⇒ Manifest
constructor
A new instance of Manifest.
- #manifests ⇒ Object
Constructor Details
#initialize(hostname, roles) ⇒ Manifest
Returns a new instance of Manifest.
29 30 31 |
# File 'lib/enc/manifest.rb', line 29 def initialize(hostname, roles) @hostname, @roles = hostname, roles end |
Instance Attribute Details
#hostname ⇒ Object (readonly)
Returns the value of attribute hostname.
27 28 29 |
# File 'lib/enc/manifest.rb', line 27 def hostname @hostname end |
#roles ⇒ Object (readonly)
Returns the value of attribute roles.
27 28 29 |
# File 'lib/enc/manifest.rb', line 27 def roles @roles end |
Instance Method Details
#file(role) ⇒ Object
45 46 47 |
# File 'lib/enc/manifest.rb', line 45 def file(role) "#{Enc.template_dir}/#{role}.yml" end |
#files ⇒ Object
41 42 43 |
# File 'lib/enc/manifest.rb', line 41 def files roles.push(hostname).map{ |r| file(r) }.select{ |f| File.exists?(f) } end |
#hash ⇒ Object
33 34 35 |
# File 'lib/enc/manifest.rb', line 33 def hash manifests.inject({}){ |result, m| result.deep_merge(m) } end |
#manifests ⇒ Object
37 38 39 |
# File 'lib/enc/manifest.rb', line 37 def manifests files.map{ |f| YAML.load(ERB.new(File.read(f)).result(binding)) } end |