Module: CfInner
- Included in:
- CfFactory::CfAppCookieStickinessPolicy, CfFactory::CfCacheBehavior, CfFactory::CfCloudFormationCommand, CfFactory::CfCloudFormationCommands, CfFactory::CfCloudFormationConfig, CfFactory::CfCloudFormationFile, CfFactory::CfCloudFormationFiles, CfFactory::CfCloudFormationInit, CfFactory::CfCloudFormationInner, CfFactory::CfCloudFormationPackage, CfFactory::CfCloudFormationPackages, CfFactory::CfCloudFormationSources, CfFactory::CfCustomOriginConfig, CfFactory::CfDefaultCacheBehavior, CfFactory::CfDefaultCacheBehaviors, CfFactory::CfDistributionConfig, CfFactory::CfEbApplicationVersion, CfFactory::CfEbConfigurationTemplate, CfFactory::CfEbOptionSetting, CfFactory::CfEc2SecurityGroupEgress, CfFactory::CfEc2SecurityGroupIngress, CfFactory::CfEc2Tag, CfFactory::CfElbAliasTarget, CfFactory::CfForwardedValues, CfFactory::CfHealthCheck, CfFactory::CfIamPolicy, CfFactory::CfIamStatement, CfFactory::CfInnerNetworkInterface, CfFactory::CfLbCookieStickinessPolicy, CfFactory::CfListener, CfFactory::CfLogging, CfFactory::CfOrigin, CfFactory::CfPolicyDocument, CfFactory::CfRdsSecurityGroupIngress, CfFactory::CfRecordSet, CfFactory::CfS3OriginConfig, CfFactory::CfWebSiteConfig
- Defined in:
- lib/cf_factory/base/cf_inner.rb
Instance Method Summary collapse
- #additional_indent ⇒ Object
- #generate ⇒ Object
- #generate_name ⇒ Object
- #get_cf_attributes ⇒ Object
- #hash_to_string(hash, indent = 0) ⇒ Object
-
#set_quotes(value) ⇒ Object
Sets leading and trailing quotes.
Instance Method Details
#additional_indent ⇒ Object
8 9 10 |
# File 'lib/cf_factory/base/cf_inner.rb', line 8 def additional_indent 0 end |
#generate ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/cf_factory/base/cf_inner.rb', line 32 def generate() indent = " "*additional_indent() @result = "#{indent}" @result += "#{indent}{\n" attributes = self.get_cf_attributes @result += hash_to_string(attributes) @result += "\n#{indent} }" end |
#generate_name ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/cf_factory/base/cf_inner.rb', line 12 def generate_name() indent = " "*additional_indent() @result = "#{indent}" @result += "#{indent}{\n" attributes = self.get_cf_attributes @result += "#{indent} \"#{@name}\" : {\n" attributes.keys.each() {|key| value = attributes[key] if (not (value.class.to_s == "String")) and value.method_defined? :get_cf_attributes @result += "#{indent} \"#{key}\" : #{value.get_cf_attributes},\n}" else @result += "#{indent} \"#{key}\" : #{set_quotes(value)},\n" end } @result = @result.chomp.chomp(",") @result += "\n#{indent} }" @result += "\n#{indent} }" end |
#get_cf_attributes ⇒ Object
4 5 6 |
# File 'lib/cf_factory/base/cf_inner.rb', line 4 def get_cf_attributes raise Exception.new("must be defined") end |
#hash_to_string(hash, indent = 0) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/cf_factory/base/cf_inner.rb', line 42 def hash_to_string(hash, indent=0) output = "" hash.keys.each() do |key| value = hash[key] output += " " * indent case value.class.to_s when "Hash" output += " \"#{key}\" : \n{#{hash_to_string(value,indent+5)}},\n" else output += " \"#{key}\" : #{set_quotes(value)},\n" end end output output = output.chomp().chomp(",") end |
#set_quotes(value) ⇒ Object
Sets leading and trailing quotes
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/cf_factory/base/cf_inner.rb', line 61 def set_quotes(value) if value.class.to_s == "String" if value.delete(" ").start_with?("{") || value.delete(" ").start_with?("[") value else "\"#{value}\"" end else value end end |