Class: CfFactory::CfMain

Inherits:
Object
  • Object
show all
Defined in:
lib/cf_factory/base/cf_main.rb

Instance Method Summary collapse

Constructor Details

#initialize(description, version = "2010-09-09") ⇒ CfMain

Returns a new instance of CfMain.



3
4
5
6
7
8
9
10
# File 'lib/cf_factory/base/cf_main.rb', line 3

def initialize(description, version = "2010-09-09")
  @description = description
  @version = version
  @mappings = []
  @parameters = []
  @outputs = []
  @resources = []
end

Instance Method Details

#add_elb(elb) ⇒ Object



23
24
25
# File 'lib/cf_factory/base/cf_main.rb', line 23

def add_elb(elb)
  @resources << elb
end

#add_mapping(mapping) ⇒ Object



27
28
29
# File 'lib/cf_factory/base/cf_main.rb', line 27

def add_mapping(mapping)
  @mappings << mapping
end

#add_output(parameter) ⇒ Object



35
36
37
# File 'lib/cf_factory/base/cf_main.rb', line 35

def add_output(parameter)
  @outputs << parameter
end

#add_parameter(parameter) ⇒ Object



31
32
33
# File 'lib/cf_factory/base/cf_main.rb', line 31

def add_parameter(parameter)
  @parameters << parameter
end

#add_resource(resource) ⇒ Object



39
40
41
# File 'lib/cf_factory/base/cf_main.rb', line 39

def add_resource(resource)
  @resources << resource
end

#add_vpc(vpc) ⇒ Object



19
20
21
# File 'lib/cf_factory/base/cf_main.rb', line 19

def add_vpc(vpc)
  @resources << vpc
end

#apply_tags_to_all_resources(tag_list) ⇒ Object

Go through all resources and tag them with the specified array of tags.



13
14
15
16
17
# File 'lib/cf_factory/base/cf_main.rb', line 13

def apply_tags_to_all_resources(tag_list)
  @resources.each() {|resource|
    resource.set_tags(tag_list)
  }
end

#generateObject



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/cf_factory/base/cf_main.rb', line 43

def generate()
  @result = "{\n"
  generate_version
  generate_description
  generate_parameters
  generate_mappings unless @mappings.size == 0
  generate_resources
  generate_outputs
  @result += "}\n"
  @result
end