awsome 0.0.39 → 0.0.40

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.
@@ -84,25 +84,28 @@ module Awsome
84
84
  end
85
85
 
86
86
  def self.to_table(instances)
87
- headings = %w(tags packages volumes elbs elasticips cnames ami key type zone secgroup)
88
- Terminal::Table.new :headings => headings do |t|
89
- instances.each_with_index do |instance, i|
90
- t << [
91
- 'Not built', #req.tags.join("\n"),
92
- instance.packages.to_a.join("\n"),
93
- instance.volumes.to_a.join("\n"),
94
- instance.elbs.join("\n"),
95
- 'Not built', #req.elastic_ips.join("\n"),
96
- 'Not built', #req.cnames.collect{|c|c['names']}.flatten.join("\n"),
97
- instance.ami_id,
98
- instance.key,
99
- instance.instance_type,
100
- instance.availability_zone,
101
- instance.security_group_ids
102
- ]
103
- t << :separator unless i == instances.length-1
104
- end
87
+ rows = []
88
+
89
+ # add instance rows
90
+ instances.each do |instance|
91
+ rows << [
92
+ instance.packages.to_a.join("\n"),
93
+ instance.volumes.to_a.join("\n"),
94
+ instance.elbs.collect(&:name).join("\n"),
95
+ instance.ami_id,
96
+ instance.key,
97
+ instance.instance_type,
98
+ instance.availability_zone,
99
+ instance.security_group_ids
100
+ ]
101
+ rows << :separator
105
102
  end
103
+
104
+ # remove last unnecessary separator
105
+ rows.pop if rows.any?
106
+
107
+ headings = %w(packages volumes elbs ami key type zone secgroup)
108
+ Terminal::Table.new :headings => headings, :rows => rows
106
109
  end
107
110
 
108
111
  def elbs
@@ -110,27 +113,27 @@ module Awsome
110
113
  end
111
114
 
112
115
  def id
113
- properties['instance_id']
116
+ @properties['instance_id']
114
117
  end
115
118
 
116
119
  def ami_id
117
- properties['ami_id']
120
+ @properties['ami_id']
118
121
  end
119
122
 
120
123
  def key
121
- properties['key']
124
+ @properties['key']
122
125
  end
123
126
 
124
127
  def instance_type
125
- properties['instance_type']
128
+ @properties['instance_type']
126
129
  end
127
130
 
128
131
  def availability_zone
129
- properties['availability_zone']
132
+ @properties['availability_zone']
130
133
  end
131
134
 
132
135
  def security_group_ids
133
- properties['security_group_ids']
136
+ @properties['security_group_ids']
134
137
  end
135
138
 
136
139
  private
@@ -19,6 +19,10 @@ module Awsome
19
19
  Awsome::Elb.register_instance_with_lb(@properties['name'], instance_id)
20
20
  end
21
21
 
22
+ def name
23
+ @properties['name']
24
+ end
25
+
22
26
  private
23
27
  def reload!
24
28
  elb = Awsome::Elb.describe_lbs(@properties['name']).first
@@ -34,27 +34,32 @@ module Awsome
34
34
  end
35
35
 
36
36
  def self.to_table(matches)
37
- headings = %w(instance packages volumes elbs ami key type zone secgroup)
38
- Terminal::Table.new :headings => headings do |t|
39
- matches.each_with_index do |match, midx|
40
- 1.upto(match['i_pool'].length) do |idx|
41
- i = match['i_pool'][idx]
42
- r = match['r_pool'][idx]
43
- t << [
44
- i.nil? ? '(new)' : i.id,
45
- r.packages.join("\n"),
46
- r.volumes.join("\n"),
47
- r.elbs.join("\n"),
48
- r.ami_id,
49
- r.key,
50
- r.instance_type,
51
- r.availability_zone,
52
- r.security_group_ids,
53
- ]
54
- t << :separator unless idx == match['i_pool'].length-1 && midx == matches.length-1
55
- end
37
+ rows = []
38
+
39
+ # enumerate match rows
40
+ matches.each do |signature, match|
41
+ match['i_pool'].each_with_index do |i, idx|
42
+ r = match['r_pool'][idx]
43
+ rows << [
44
+ i.nil? ? '(new)' : i.id,
45
+ r.packages.join("\n"),
46
+ r.volumes.join("\n"),
47
+ r.elbs.join("\n"),
48
+ r.ami_id,
49
+ r.key,
50
+ r.instance_type,
51
+ r.availability_zone,
52
+ r.security_group_ids,
53
+ ]
54
+ rows << :separator
56
55
  end
57
56
  end
57
+
58
+ # remove last unnecessary separator
59
+ rows.pop if rows.any?
60
+
61
+ headings = %w(instance packages volumes elbs ami key type zone secgroup)
62
+ Terminal::Table.new :headings => headings, :rows => rows
58
63
  end
59
64
 
60
65
  private
@@ -31,25 +31,31 @@ module Awsome
31
31
  end
32
32
 
33
33
  def self.to_table(requirements)
34
- headings = %w(tags packages volumes elbs elasticips cnames ami key type zone secgroup)
35
- Terminal::Table.new :headings => headings do |t|
36
- requirements.each_with_index do |req, i|
37
- t << [
38
- req.tags.collect { |v| "#{v[0]}: #{v[1]}" }.join("\n"),
39
- req.packages.to_a.join("\n"),
40
- req.volumes.to_a.join("\n"),
41
- req.elbs.join("\n"),
42
- req.elastic_ips.join("\n"),
43
- req.cnames.collect{|c|c['names']}.flatten.join("\n"),
44
- req.ami_id,
45
- req.key,
46
- req.instance_type,
47
- req.availability_zone,
48
- req.security_group_ids
49
- ]
50
- t << :separator unless i == requirements.length-1
51
- end
34
+ rows = []
35
+
36
+ #add requirement rows
37
+ requirements.each do |req|
38
+ rows << [
39
+ req.tags.collect { |v| "#{v[0]}: #{v[1]}" }.join("\n"),
40
+ req.packages.to_a.join("\n"),
41
+ req.volumes.to_a.join("\n"),
42
+ req.elbs.join("\n"),
43
+ req.elastic_ips.join("\n"),
44
+ req.cnames.collect{|c|c['names']}.flatten.join("\n"),
45
+ req.ami_id,
46
+ req.key,
47
+ req.instance_type,
48
+ req.availability_zone,
49
+ req.security_group_ids
50
+ ]
51
+ rows << :separator
52
52
  end
53
+
54
+ # remove last unnecessary separator
55
+ rows.pop if rows.any?
56
+
57
+ headings = %w(tags packages volumes elbs elasticips cnames ami key type zone secgroup)
58
+ Terminal::Table.new :headings => headings, :rows => rows
53
59
  end
54
60
 
55
61
  private
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awsome
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.39
4
+ version: 0.0.40
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: