Class: Promote::EnvironmentFile

Inherits:
Object
  • Object
show all
Defined in:
lib/promote/environment_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(environment_name, config) ⇒ EnvironmentFile

Returns a new instance of EnvironmentFile.



7
8
9
10
# File 'lib/promote/environment_file.rb', line 7

def initialize(environment_name, config)
  @name = environment_name
  @config = config
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/promote/environment_file.rb', line 5

def name
  @name
end

Instance Method Details

#cookbook_versionsObject



20
21
22
# File 'lib/promote/environment_file.rb', line 20

def cookbook_versions
  content['cookbook_versions'] || {}
end

#file_pathObject



12
13
14
# File 'lib/promote/environment_file.rb', line 12

def file_path
  File.join(@config.environment_directory, "#{name}.json")
end

#overridesObject



16
17
18
# File 'lib/promote/environment_file.rb', line 16

def overrides
    content['override_attributes'] || {}
end

#write_cookbook_versions(versions) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/promote/environment_file.rb', line 24

def write_cookbook_versions(versions)
  content['cookbook_versions'] = versions

  File.open(file_path, 'w') do |out|
    out << JSON.pretty_generate(content)
  end
end