capify-ec2 1.3.1 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -55,8 +55,8 @@ Capistrano::Configuration.instance(:must_exist).load do
55
55
  def ec2_roles(*roles)
56
56
  server_name = variables[:logger].instance_variable_get("@options")[:actions].first unless variables[:logger].instance_variable_get("@options")[:actions][1].nil?
57
57
 
58
- if !server_name.nil?
59
- named_instance = capify_ec2.get_instance_by_name(server_name) || ""
58
+ if !server_name.nil? && !server_name.empty?
59
+ named_instance = capify_ec2.get_instance_by_name(server_name)
60
60
 
61
61
  task named_instance.name.to_sym do
62
62
  remove_default_roles
@@ -77,9 +77,9 @@ Capistrano::Configuration.instance(:must_exist).load do
77
77
  end
78
78
 
79
79
  def ec2_role(role_name_or_hash)
80
- role = role_name_or_hash.is_a?(Hash) ? role_name_or_hash : {:name => role_name_or_hash,:options => {}}
81
- @roles[role[:name]]
82
-
80
+ role = role_name_or_hash.is_a?(Hash) ? role_name_or_hash : {:name => role_name_or_hash,:options => {}}
81
+ variables = role_name_or_hash[:variables] || {}
82
+
83
83
  instances = capify_ec2.get_instances_by_role(role[:name])
84
84
  if role[:options].delete(:default)
85
85
  instances.each do |instance|
@@ -91,9 +91,8 @@ Capistrano::Configuration.instance(:must_exist).load do
91
91
  define_regions(region, role)
92
92
  end unless regions.nil?
93
93
 
94
- define_role_roles(role, instances)
95
- define_instance_roles(role, instances)
96
-
94
+ define_role_roles(role, instances, variables)
95
+ define_instance_roles(role, instances, variables)
97
96
  end
98
97
 
99
98
  def define_regions(region, role)
@@ -110,35 +109,37 @@ Capistrano::Configuration.instance(:must_exist).load do
110
109
  end
111
110
  end
112
111
 
113
- def define_instance_roles(role, instances)
112
+ def define_instance_roles(role, instances, variables)
114
113
  instances.each do |instance|
115
114
  task instance.name.to_sym do
116
115
  remove_default_roles
117
- define_role(role, instance)
116
+ define_role(role, instance, variables)
118
117
  end
119
118
  end
120
119
  end
121
120
 
122
- def define_role_roles(role, instances)
121
+ def define_role_roles(role, instances, variables)
123
122
  task role[:name].to_sym do
124
123
  remove_default_roles
125
124
  instances.each do |instance|
126
- define_role(role, instance)
125
+ define_role(role, instance, variables)
127
126
  end
128
127
  end
129
128
  end
130
129
 
131
- def define_role(role, instance)
132
- options = role[:options]
133
- new_options = {}
134
- options.each {|key, value| new_options[key] = true if value.to_s == instance.name}
135
- instance.tags["Options"].split(%r{,\s*}).each { |option| new_options[option.to_sym] = true} rescue false
130
+ def define_role(role, instance, variables)
131
+ options = role[:options] || {}
136
132
 
137
- if new_options
138
- role role[:name].to_sym, instance.contact_point, new_options
139
- else
140
- role role[:name].to_sym, instance.contact_point
141
- end
133
+ cap_options = options.inject({}) do |cap_options, (key, value)|
134
+ cap_options[key] = true if value.to_s == instance.name
135
+ cap_options
136
+ end
137
+
138
+ ec2_options = instance.tags["Options"] || ""
139
+ ec2_options.split(%r{,\s*}).compact.each { |ec2_option| cap_options[ec2_option.to_sym] = true }
140
+
141
+ variables.each { |name, value| set name, value }
142
+ role role[:name].to_sym, instance.contact_point, cap_options
142
143
  end
143
144
 
144
145
  def numeric?(object)
@@ -1,6 +1,6 @@
1
1
  module Capify
2
2
  module Ec2
3
- VERSION = "1.3.1"
3
+ VERSION = "1.3.3"
4
4
  end
5
5
  end
6
6
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capify-ec2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-10-03 00:00:00.000000000 Z
13
+ date: 2012-11-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: fog
@@ -99,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  version: '0'
100
100
  requirements: []
101
101
  rubyforge_project: capify-ec2
102
- rubygems_version: 1.8.24
102
+ rubygems_version: 1.8.23
103
103
  signing_key:
104
104
  specification_version: 3
105
105
  summary: Grabs roles from ec2's tags and autogenerates capistrano tasks