instant_ec2 0.1.2 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3ba694d8dac452161e3b7590663a7963e75973c2
4
- data.tar.gz: 9e2a2d0a1425121b5e4860a09c91ba591357c505
3
+ metadata.gz: 42cfc79bfd329aa789ce68b9d7b955699c9eebfb
4
+ data.tar.gz: d9af3f8b46f88b3b95f149fa48ac3bb337b6c2da
5
5
  SHA512:
6
- metadata.gz: be8616f736600d6bec62c8942e973d8ea10fe8fe5656961242648083e3948d885ce26c4c1bd082337a05b7010ec5e1c10dd001274fde90d42c77dad6e986b997
7
- data.tar.gz: 27ba6067ad63729a31bc4e78b9bf81440581a2c81d729ecc720fca8f29088737af206f57956ed806059b0c54fe9e0706c1711104944d5399a5f30490ea23b1ea
6
+ metadata.gz: 1b2b7d7edeaf36e7378a0215bd999fa7ee97227765f4f2c822a927decb164a6e6dc6fd1783d05d46b71d3420548ed417f6ee4d0765bd96304ed52ec8b7ca54e0
7
+ data.tar.gz: d9526ba7df9a67fe8873c9c520c557c041fd3b70bcd56f6f3d7db39b7d492c591ed3dc046e37be737d9c6ace8ae873e66e88d50242b47be5c45ed6db4fd2f379
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/instant_ec2.rb CHANGED
@@ -17,7 +17,7 @@ class EC2Instance < Hash
17
17
  def start(duration: nil)
18
18
 
19
19
  @c.start_instance self[:instance_id]
20
- Thread.new{ sleep duration * 60; self.stop} if duration
20
+ Thread.new{ sleep duration.to_i * 60; self.stop} if duration
21
21
 
22
22
  end
23
23
 
@@ -38,18 +38,24 @@ class InstantEC2
38
38
  credentials: Aws::Credentials.new(*credentials))
39
39
 
40
40
  r = @ec2.describe_instances.reservations
41
- image_ids = r.map{|x| x[:instances][0][:image_id] }
42
- image_names = @ec2.describe_images(image_ids: image_ids).images.\
43
- map{|x| x.name }
44
- instance_ids = r.map{|x| x.instances[0].instance_id}
41
+
42
+ ids = @ec2.describe_instances[:reservations].inject({}) do |r, item|
43
+ x = item.instances[0]
44
+ r.merge(x.image_id => x.instance_id)
45
+ end
46
+
47
+ rows = @ec2.describe_images(image_ids: ids.keys)[:images].\
48
+ map{|x| [x.name, x.image_id] }
45
49
 
46
- @images = image_names.zip(instance_ids).inject([]) do |r, x|
50
+ @images = rows.inject([]) do |r, x|
47
51
 
48
- name, id = x
49
- r << EC2Instance.new({image_name: name, instance_id: id}, self)
52
+ name, image_id = x
53
+
54
+ r << EC2Instance.new({image_name: name, \
55
+ instance_id: ids[image_id]}, self)
50
56
 
51
57
  end
52
-
58
+
53
59
  @hooks = {
54
60
  running: ->(ip){
55
61
  puts "%s: the instance is now accessible from %s" % [Time.now, ip]
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: instant_ec2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file