Class: Cfhighlander::Util::Debug

Inherits:
Object
  • Object
show all
Defined in:
lib/util/debug.util.rb

Constant Summary collapse

@@debug_folder_exists =
false

Class Method Summary collapse

Class Method Details

.create_debug_folderObject



9
10
11
12
13
14
# File 'lib/util/debug.util.rb', line 9

def self.create_debug_folder
  if ((ENV.key? 'CFHIGHLANDER_DEBUG') and (ENV['CFHIGHLANDER_DEBUG'] == '1'))
    FileUtils.mkdir_p "#{ENV['CFHIGHLANDER_WORKDIR']}/out/debug/"
    @@debug_folder_exists = true
  end unless @@debug_folder_exists
end

.debug_dump(model, dump_name) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/util/debug.util.rb', line 26

def self.debug_dump(model, dump_name)
  create_debug_folder
  if ((ENV.key? 'CFHIGHLANDER_DEBUG') and (ENV['CFHIGHLANDER_DEBUG'] == '1'))
    path = "#{ENV['CFHIGHLANDER_WORKDIR']}/out/debug/#{dump_name}.yaml"
    File.write(path, model.to_yaml)
  end
end

.debug_dump_cfn(template, step_name) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/util/debug.util.rb', line 16

def self.debug_dump_cfn(template, step_name)
  create_debug_folder
  if ((ENV.key? 'CFHIGHLANDER_DEBUG') and (ENV['CFHIGHLANDER_DEBUG'] == '1'))
    template.subcomponents.each do |sub_component|
      path = "#{ENV['CFHIGHLANDER_WORKDIR']}/out/debug/#{sub_component.cfn_name}_#{step_name}.yaml"
      File.write(path, sub_component.component_loaded.cfn_model_raw.to_yaml)
    end
  end
end