Class: Enc::Manifest

Inherits:
Object
  • Object
show all
Defined in:
lib/enc/manifest.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#hostnameObject (readonly)

Returns the value of attribute hostname.



27
28
29
# File 'lib/enc/manifest.rb', line 27

def hostname
  @hostname
end

#rolesObject (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

#filesObject



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

#hashObject



33
34
35
# File 'lib/enc/manifest.rb', line 33

def hash 
  manifests.inject({}){ |result, m| result.deep_merge(m) }
end

#manifestsObject



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