Module: Aws::Cfn::Dsl::DSL

Included in:
Base
Defined in:
lib/aws/cfn/dsl/mixins/dsl.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(includer) ⇒ Object



45
46
47
# File 'lib/aws/cfn/dsl/mixins/dsl.rb', line 45

def self.included(includer)

end

Instance Method Details

#add_brick(subdir, name) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/aws/cfn/dsl/mixins/dsl.rb', line 22

def add_brick(subdir,name)
  if @config[:directory]
    #file = rb_file(subdir, name).gsub(%r'^#{@config[:directory]}/','')
    #writeln "  file '#{file}'"
    s = subdir.downcase.gsub(%r's$','')
    writeln "  #{s} '#{name}'"
  end
end

#detect_type(val) ⇒ Object

Attempt to figure out what fragment of the template we have. This is imprecise and can’t detect Mappings and Outputs sections reliably, so it doesn’t attempt to.



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/aws/cfn/dsl/mixins/dsl.rb', line 8

def detect_type(val)
  if val.is_a?(Hash) && val['AWSTemplateFormatVersion']
    :template
  elsif val.is_a?(Hash) && /^(String|Number)$/ =~ val['Type']
    :parameter
  elsif val.is_a?(Hash) && val['Type']
    :resource
  elsif val.is_a?(Hash) && val.values.all? { |v| detect_type(v) == :parameter }
    :parameters
  elsif val.is_a?(Hash) && val.values.all? { |v| detect_type(v) == :resource }
    :resources
  end
end

#module_name(parts = -1)) ⇒ Object



39
40
41
42
# File 'lib/aws/cfn/dsl/mixins/dsl.rb', line 39

def module_name(parts=-1)
  name = self.class.to_s.split("::")
  name[0..parts-1].join('::')
end

#rb_file(subdir, name) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/aws/cfn/dsl/mixins/dsl.rb', line 31

def rb_file(subdir, name)
  path = File.join(@config[:directory], subdir)
  unless File.directory? path
    Dir.mkdir path
  end
  file = File.join(path, "#{name}.rb")
end