Class: Application
- Inherits:
-
Object
- Object
- Application
- Includes:
- EmailNotifications
- Defined in:
- lib/ec2launcher/application.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes included from EmailNotifications
Class Method Summary collapse
Instance Method Summary collapse
- #ami_name(*ami_name) ⇒ Object
- #application(name) {|_self| ... } ⇒ Object
- #availability_zone(*zone) ⇒ Object
- #basename(*name) ⇒ Object
- #block_device(&block) ⇒ Object
- #block_devices(*block_device_data) ⇒ Object
- #elb(*elb) ⇒ Object
- #elb_for_environment(environment) ⇒ Object
- #environment_roles(*data) ⇒ Object
- #gems(*gems) ⇒ Object
- #inherit(*inherit_type) ⇒ Object
-
#initialize(name) ⇒ Application
constructor
A new instance of Application.
- #instance_type(*type_name) ⇒ Object
- #load(dsl) ⇒ Object
-
#merge(other_server) ⇒ Object
Takes values from the other server type and merges them into this one.
- #name_suffix(*suffix) ⇒ Object
- #packages(*packages) ⇒ Object
- #roles(*roles) ⇒ Object
- #roles_for_environment(environment) ⇒ Object
- #security_groups(*groups) ⇒ Object
- #security_groups_for_environment(environment) ⇒ Object
- #subnet(*subnet) ⇒ Object
Methods included from EmailNotifications
Constructor Details
#initialize(name) ⇒ Application
Returns a new instance of Application.
33 34 35 36 |
# File 'lib/ec2launcher/application.rb', line 33 def initialize(name) @name = name @email_notifications = nil end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
31 32 33 |
# File 'lib/ec2launcher/application.rb', line 31 def name @name end |
Class Method Details
.load(dsl) ⇒ Object
258 259 260 261 |
# File 'lib/ec2launcher/application.rb', line 258 def self.load(dsl) env = Application.new.instance_eval(dsl) env end |
Instance Method Details
#ami_name(*ami_name) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ec2launcher/application.rb', line 44 def ami_name(*ami_name) if ami_name.empty? @ami_name else if ami_name[0].kind_of? String @ami_name = /#{ami_name[0]}/ else @ami_name = ami_name[0] end self end end |
#application(name) {|_self| ... } ⇒ Object
38 39 40 41 42 |
# File 'lib/ec2launcher/application.rb', line 38 def application(name) @name = name yield self self end |
#availability_zone(*zone) ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'lib/ec2launcher/application.rb', line 57 def availability_zone(*zone) if zone.empty? @availability_zone else @availability_zone = zone[0].to_s self end end |
#basename(*name) ⇒ Object
66 67 68 69 70 71 72 73 |
# File 'lib/ec2launcher/application.rb', line 66 def basename(*name) if name.empty? @basename else @basename = name[0] self end end |
#block_device(&block) ⇒ Object
83 84 85 86 87 88 |
# File 'lib/ec2launcher/application.rb', line 83 def block_device(&block) @block_devices = [] if @block_devices.nil? device = BlockDevice.new device.instance_exec(&block) @block_devices << device end |
#block_devices(*block_device_data) ⇒ Object
75 76 77 78 79 80 81 |
# File 'lib/ec2launcher/application.rb', line 75 def block_devices(*block_device_data) if block_device_data.empty? @block_devices else self end end |
#elb(*elb) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/ec2launcher/application.rb', line 90 def elb(*elb) if elb.empty? @elb else @elb = Hash.new if @elb.nil? if elb[0].kind_of? Hash elb[0].keys.each {|key| @elb[key] = elb[0][key]} else @elb["default"] = elb[0].to_s end self end end |
#elb_for_environment(environment) ⇒ Object
104 105 106 107 108 |
# File 'lib/ec2launcher/application.rb', line 104 def elb_for_environment(environment) elb_name = @elb[environment] elb_name ||= @elb["default"] elb_name end |
#environment_roles(*data) ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/ec2launcher/application.rb', line 110 def environment_roles(*data) if data.empty? @environment_roles else @environment_roles = Hash.new if @environment_roles.nil? env_name = data[0] env_roles = data[1] environment_data = @environment_roles[env_name] environment_data ||= [] if env_roles.kind_of? Array environment_data += env_roles else environment_data << env_roles end @environment_roles[env_name] = environment_data self end end |
#gems(*gems) ⇒ Object
132 133 134 135 136 137 138 139 |
# File 'lib/ec2launcher/application.rb', line 132 def gems(*gems) if gems.empty? @gems else @gems = gems[0] self end end |
#inherit(*inherit_type) ⇒ Object
141 142 143 144 145 146 147 |
# File 'lib/ec2launcher/application.rb', line 141 def inherit(*inherit_type) if inherit_type.empty? @inherit_type else @inherit_type = inherit_type[0] end end |
#instance_type(*type_name) ⇒ Object
149 150 151 152 153 154 155 156 |
# File 'lib/ec2launcher/application.rb', line 149 def instance_type(*type_name) if type_name.empty? @instance_type else @instance_type = type_name[0] self end end |
#load(dsl) ⇒ Object
253 254 255 256 |
# File 'lib/ec2launcher/application.rb', line 253 def load(dsl) self.instance_eval(dsl) self end |
#merge(other_server) ⇒ Object
Takes values from the other server type and merges them into this one
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/ec2launcher/application.rb', line 159 def merge(other_server) @name = other_server.name @ami_name = other_server.ami_name unless other_server.ami_name.nil? @availability_zone = other_server.availability_zone unless other_server.availability_zone.nil? @basename = other_server.basename unless other_server.basename.nil? other_server.block_devices.each {|bd| @block_devices << bd } unless other_server.block_devices.nil? other_server.elb.keys.each {|env_name| @elb[env_name] = other_server.elb[env_name] } unless other_server.elb.nil? @instance_type = other_server.instance_type unless other_server.instance_type.nil? @name_suffix = other_server.name_suffix unless other_server.name_suffix.nil? other_server.roles.each {|role| @roles << role } unless other_server.roles.nil? unless other_server.security_groups.nil? other_server.security_groups.keys.each do |env_name| unless @security_groups.has_key? env_name @security_groups[env_name] = [] end other_server.security_groups[env_name].each {|sg| @security_groups[env_name] << sg } end end end |
#name_suffix(*suffix) ⇒ Object
179 180 181 182 183 184 185 |
# File 'lib/ec2launcher/application.rb', line 179 def name_suffix(*suffix) if suffix.empty? @name_suffix else @name_suffix = suffix[0] end end |
#packages(*packages) ⇒ Object
187 188 189 190 191 192 193 194 |
# File 'lib/ec2launcher/application.rb', line 187 def packages(*packages) if packages.empty? @packages else @packages = packages[0] self end end |
#roles(*roles) ⇒ Object
196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/ec2launcher/application.rb', line 196 def roles(*roles) if roles.empty? @roles else @roles = [] if @roles.nil? if roles[0].kind_of? Array @roles += roles[0] else @roles = [] @roles << roles[0] end self end end |
#roles_for_environment(environment) ⇒ Object
211 212 213 214 215 216 217 218 219 |
# File 'lib/ec2launcher/application.rb', line 211 def roles_for_environment(environment) roles = [] roles += @roles unless @roles.nil? unless @environment_roles.nil? || @environment_roles[environment].nil? roles += @environment_roles[environment] end roles end |
#security_groups(*groups) ⇒ Object
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'lib/ec2launcher/application.rb', line 221 def security_groups(*groups) if groups.empty? @security_groups else @security_groups = Hash.new if @security_groups.nil? if groups[0].kind_of? Array @security_groups["default"] = groups[0] elsif groups[0].kind_of? Hash groups[0].keys.each {|key| @security_groups[key] = [ groups[0][key] ] } else @security_groups["default"] = [ groups[0].to_s ] end self end end |
#security_groups_for_environment(environment) ⇒ Object
237 238 239 240 241 242 |
# File 'lib/ec2launcher/application.rb', line 237 def security_groups_for_environment(environment) groups = @security_groups[environment] groups ||= @security_groups["default"] groups ||= [] groups end |
#subnet(*subnet) ⇒ Object
244 245 246 247 248 249 250 251 |
# File 'lib/ec2launcher/application.rb', line 244 def subnet(*subnet) if subnet.empty? @subnet else @subnet = subnet[0] self end end |