lib/aws/cfn/compiler/mixins/save.rb in aws-cfn-compiler-0.7.0 vs lib/aws/cfn/compiler/mixins/save.rb in aws-cfn-compiler-0.8.0
- old
+ new
@@ -1,10 +1,41 @@
+require 'inifile'
module Aws
module Cfn
module Compiler
module Save
+ def save_inifile(dir, file, section, parameters, brick=nil)
+ brick ||= "INI #{section}"
+ path = File.join(File.expand_path(dir), file)
+ filn = if @config[:expandedpaths]
+ path
+ else
+ File.join(dir, file)
+ end
+ logStep "Saving #{brick} to #{filn} "
+
+ if i_am_maintainer(path) or @config[:force]
+ begin
+ ini = IniFile.new
+
+ # noinspection RubyStringKeysInHashInspection
+ parms = {
+ 'region' => 'us-east-1'
+ }
+ parameters.map{ |p| parms[p['ParameterKey']] = p['ParameterValue'] }
+ ini['<StackName>'] = parms
+ ini.write( filename: path )
+ @logger.info " saved #{filn}."
+ rescue
+ abort! "!!! Could not write file #{path}: #{$!}"
+ end
+ else
+ @logger.warn " Did not overwrite #{filn}."
+ end
+ end
+
def save_section(dir, file, format, section, hash, join='/', brick=nil)
brick ||= "brick #{hash.keys[0]}"
path = File.join(File.expand_path(dir), file)
filn = if @config[:expandedpaths]
path
@@ -37,12 +68,12 @@
else
abort! "Internal: Unsupported format #{format}. Should have noticed this earlier!"
end
f.close
end
- @logger.info " decompiled #{filn}."
+ @logger.info " saved #{filn}."
rescue
- abort! "!!! Could not write compiled file #{path}: #{$!}"
+ abort! "!!! Could not write file #{path}: #{$!}"
end
else
@logger.warn " Did not overwrite #{filn}."
end
end