Class: MakeMeSpiffy::OutputTemplateManifest

Inherits:
Object
  • Object
show all
Defined in:
lib/makemespiffy/output_template_manifest.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bosh_manifest_yaml) ⇒ OutputTemplateManifest

Returns a new instance of OutputTemplateManifest.



16
17
18
# File 'lib/makemespiffy/output_template_manifest.rb', line 16

def initialize(bosh_manifest_yaml)
  @manifest = bosh_manifest_yaml
end

Instance Attribute Details

#manifestObject (readonly)

Returns the value of attribute manifest.



5
6
7
# File 'lib/makemespiffy/output_template_manifest.rb', line 5

def manifest
  @manifest
end

Class Method Details

.from_file(manifest_path) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/makemespiffy/output_template_manifest.rb', line 7

def self.from_file(manifest_path)
  if File.exist?(manifest_path)
    file = YAML.load_file(manifest_path)
  else
    file = {}
  end
  self.new(file)
end

Instance Method Details

#insert_scope_value(meta_scope, value) ⇒ Object

Usage: insert_scope_value(“meta.foo.bar”, 1234) Will add the following into manifest YAML

meta:
  foo:
    bar: 1234


25
26
27
28
29
30
31
32
33
34
# File 'lib/makemespiffy/output_template_manifest.rb', line 25

def insert_scope_value(meta_scope, value)
  parts = meta_scope.split('.')
  submanifest = manifest
  scoping_parts, key = parts[0..-2], parts[-1]
  for part in scoping_parts
    submanifest[part] ||= {}
    submanifest = submanifest[part]
  end
  submanifest[key] = value
end