ec2-host 0.2.0 → 0.2.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 111eba0b58ae0c88e7c0c8dc2fa342f8f397d594
4
- data.tar.gz: cfddfadf8447f1cc751ef005c7173a3b64480cc1
3
+ metadata.gz: a11603984da7e55345504bce0b96e21a903d26f9
4
+ data.tar.gz: d01d8ea00adca128ad0e2eb0036725fd4cd2cffa
5
5
  SHA512:
6
- metadata.gz: 80e09e433370bfd266977ce286de1969dff6137b152745e510937903f0a481b58ef7af01a5d70d97221d0f3912e04d17181cff94e9e18c3ea78a5659f45c806d
7
- data.tar.gz: 54d9dca3656d00d3f32d35210bc98e7c9ec40ef1e91985edcb20a4d6ded4280515ad2f32f858cb2ab05464da1cc004e7c8e69f8349fec0f03b28db7724661317
6
+ metadata.gz: a047cb53fc0a9f1c7234ccd8df891e23223574d8d389d7b968cab5da6890ecf171d71157f916d0122a2b24a2942422be3b61a686244f1784b8c92728914cb131
7
+ data.tar.gz: 26074ba59e96bf6b71c52862667b882db1d7254b5d053f3e537bdd51f8f1996cb7849fe2c19de186380e69ba7b84863b59e2f1efb25ea3a7576b303def3123d9
@@ -1,3 +1,9 @@
1
+ # 0.2.1 (2015/08/26)
2
+
3
+ Fixes:
4
+
5
+ * Fix to be able to use together with capistrano 3
6
+
1
7
  # 0.2.0 (2015/08/19)
2
8
 
3
9
  Changes:
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "ec2-host"
3
- gem.version = '0.2.0'
3
+ gem.version = '0.2.1'
4
4
  gem.author = ['Naotoshi Seo']
5
5
  gem.email = ['sonots@gmail.com']
6
6
  gem.homepage = 'https://github.com/sonots/ec2-host'
@@ -19,12 +19,12 @@ class EC2
19
19
  :private_ip_address,
20
20
  :public_ip_address,
21
21
  :launch_time
22
- def state; instance.state.name; end
23
- def monitoring; instance.monitoring.state; end
22
+ def state; self[:instance].state.name; end
23
+ def monitoring; self[:instance].monitoring.state; end
24
24
 
25
25
  alias_method :ip, :private_ip_address
26
26
  alias_method :start_date, :launch_time
27
- def usages; roles; end
27
+ def usages; self[:roles]; end
28
28
 
29
29
  def self.initialize(instance)
30
30
  d = self.new
@@ -63,12 +63,12 @@ class EC2
63
63
  end
64
64
 
65
65
  def info
66
- if hostname and status and roles and tags and service
66
+ if self[:hostname] and self[:status] and self[:roles] and self[:tags] and self[:service]
67
67
  # special treatment for DeNA ;)
68
- info = "#{hostname}:#{status}"
69
- info << "(#{roles.join(' ')})" unless roles.empty?
70
- info << "[#{tags.join(' ')}]" unless tags.empty?
71
- info << "{#{service}}" unless service.empty?
68
+ info = "#{self[:hostname]}:#{self[:status]}"
69
+ info << "(#{self[:roles].join(' ')})" unless self[:roles].empty?
70
+ info << "[#{self[:tags].join(' ')}]" unless self[:tags].empty?
71
+ info << "{#{self[:service]}}" unless self[:service].empty?
72
72
  info
73
73
  else
74
74
  to_hash.to_s
@@ -91,7 +91,7 @@ class EC2
91
91
  # "instance.instance_id" => self.send("instance").send("instance_id")
92
92
  def get_value(key)
93
93
  v = self
94
- key.to_s.split('.').each {|k| v = v.send(k) }
94
+ key.to_s.split('.').each {|k| v = v[k] || v.send(k) }
95
95
  v
96
96
  end
97
97
 
@@ -109,23 +109,23 @@ class EC2
109
109
  role3 = (condition[:role3] || condition[:usage3] || []).first
110
110
  end
111
111
  if role1
112
- return false unless self.roles.find {|role| role.match?(role1, role2, role3) }
112
+ return false unless self[:roles].find {|role| role.match?(role1, role2, role3) }
113
113
  end
114
114
  true
115
115
  end
116
116
 
117
117
  def set_hostname
118
- self.hostname = find_string_tag(Config.hostname_tag)
119
- self.hostname = instance.private_dns_name.split('.').first if self.hostname.empty?
118
+ self[:hostname] = find_string_tag(Config.hostname_tag)
119
+ self[:hostname] = self[:instance].private_dns_name.split('.').first if self[:hostname].empty?
120
120
  end
121
121
 
122
122
  def set_roles
123
123
  roles = find_array_tag(Config.roles_tag)
124
- self.roles = roles.map {|role| EC2::Host::RoleData.initialize(role) }
124
+ self[:roles] = roles.map {|role| EC2::Host::RoleData.initialize(role) }
125
125
  end
126
126
 
127
127
  def set_region
128
- self.region = Config.aws_region
128
+ self[:region] = Config.aws_region
129
129
  end
130
130
 
131
131
  def set_string_tags
@@ -39,6 +39,12 @@ describe EC2::Host do
39
39
  end
40
40
  end
41
41
 
42
+ describe '#get_value' do
43
+ let(:hosts) { EC2::Host.new(instance_id: 'i-85900780').to_a }
44
+ let(:subject) { hosts.first }
45
+ it { expect(subject.get_value('instance.instance_id')).to eql('i-85900780') }
46
+ end
47
+
42
48
  context 'by instance_id' do
43
49
  let(:hosts) { EC2::Host.new(instance_id: 'i-85900780').to_a }
44
50
  let(:subject) { hosts.first }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ec2-host
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-19 00:00:00.000000000 Z
11
+ date: 2015-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk