Class: EC2Launcher::DSL::Environment

Inherits:
Object
  • Object
show all
Includes:
EmailNotifications, SecurityGroupHandler
Defined in:
lib/ec2launcher/dsl/environment.rb

Instance Attribute Summary collapse

Attributes included from EmailNotifications

#email_notifications

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SecurityGroupHandler

#security_groups, #security_groups_for_environment

Methods included from EmailNotifications

#email_notification

Constructor Details

#initializeEnvironment

Returns a new instance of Environment.



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/ec2launcher/dsl/environment.rb', line 52

def initialize()
	@aliases = []
	@email_notifications = nil
	@gems = []
	@packages = []
	@precommand = []
	@postcommand = []
	@roles = []
	@route53_zone_id = nil
	@security_groups = {}

	@use_rvm = true
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



14
15
16
# File 'lib/ec2launcher/dsl/environment.rb', line 14

def name
  @name
end

#postcommandsObject (readonly)

Returns the value of attribute postcommands.



16
17
18
# File 'lib/ec2launcher/dsl/environment.rb', line 16

def postcommands
  @postcommands
end

#precommandsObject (readonly)

Returns the value of attribute precommands.



15
16
17
# File 'lib/ec2launcher/dsl/environment.rb', line 15

def precommands
  @precommands
end

Class Method Details

.load(dsl) ⇒ Object



114
115
116
117
# File 'lib/ec2launcher/dsl/environment.rb', line 114

def self.load(dsl)
	env = EC2Launcher::DSL::Environment.new.instance_eval(dsl)
	env
end

Instance Method Details

#environment(name) {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



66
67
68
69
70
# File 'lib/ec2launcher/dsl/environment.rb', line 66

def environment(name)
	@name = name
	yield self
	self
end

#load(dsl) ⇒ Object



109
110
111
112
# File 'lib/ec2launcher/dsl/environment.rb', line 109

def load(dsl)
	self.instance_eval(dsl)
	self
end

#merge(other_env) ⇒ Object

Takes values from the other environment and merges them into this one



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/ec2launcher/dsl/environment.rb', line 73

def merge(other_env)
		@name =other_env.name

		@gems += other_env.gems if other_env.gems
		@packages += other_env.packages if other_env.packages
		@roles += other_env.roles if other_env.roles
		@precommand += other_env.precommand if other_env.precommand
		@postcommand += other_env.postcommand if other_env.postcommand
		if other_env.security_groups
			other_env.security_groups.keys.each do |key|
				@security_groups[key] = [] if @security_groups[key].nil?
				@security_groups[key] += other_env.security_groups[key]
			end
		end

		@aliases = other_env.aliases.nil? ? nil : other_env.aliases

		@ami_name = other_env.ami_name if other_env.ami_name
		@aws_keyfile = other_env.aws_keyfile if other_env.aws_keyfile
		@availability_zone = other_env.availability_zone if other_env.availability_zone
		@chef_path = other_env.chef_path if other_env.chef_path
		@chef_server_url = other_env.chef_server_url if other_env.chef_server_url
		@chef_validation_pem_url = other_env.chef_validation_pem_url if other_env.chef_validation_pem_url
		@domain_name = other_env.domain_name if other_env.domain_name
		@email_notifications = other_env.email_notifications if other_env.email_notifications
		@gem_path = other_env.gem_path if other_env.gem_path
		@iam_profile = other_env.iam_profile if other_env.iam_profile
		@key_name = other_env.key_name if other_env.key_name
		@knife_path = other_env.knife_path if other_env.knife_path
		@route53_zone_id = other_env.route53_zone_id if other_env.route53_zone_id
		@ruby_path = other_env.ruby_path if other_env.ruby_path
		@subnet = other_env.subnet if other_env.subnet
		@short_name = other_env.short_name if other_env.short_name
		@use_rvm = other_env.use_rvm if other_env.use_rvm
end