awful 0.0.132 → 0.0.133

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 14133429fbba1f41a835d8d45c39f5373a970934
4
- data.tar.gz: c78d296568121425e737eb1101ab6227b4145f1f
3
+ metadata.gz: f20fa5e02041068d58d0a6eb5303dccf56af9bf4
4
+ data.tar.gz: ac99595963ec8e583cf7e80fa96866f15e884b56
5
5
  SHA512:
6
- metadata.gz: 5d8e26ea411a4c35a932113c54a8123110c5e8bb3910f8514779a3c84b1a6aae59951cfa94cde2b9d3f30606d32db5e7ffb2057a6198ab5ace642a20b2aa8157
7
- data.tar.gz: 5535193a7a7fa50171676f61ec315b1ef228a1d041241e4bd29569aff95316abc8ebee71e58b31580b6e85a243c22bfdad676e081fb22687617953bdd0ab694b
6
+ metadata.gz: 2a87db67e4ddea50a875c5f2b38d149921536227585b7abcaf0e79470b817ed47fc17788057ccb54b6a9c54992529fdf05c4945c705887738e52ec5f2481cb67
7
+ data.tar.gz: 924d74990c82d76e26acd21317557df931d96f14f80439680af6cf1573840038e3873068e12cb8aced59cf644def20e2d6b8ac6909fced12aee4e510a417e7f7
data/lib/awful/ami.rb CHANGED
@@ -37,7 +37,7 @@ module Awful
37
37
  def ls(name = /./)
38
38
  images(options).select do |image|
39
39
  image.name.match(name)
40
- end.tap do |list|
40
+ end.output do |list|
41
41
  if options[:long]
42
42
  print_table list.map { |i|
43
43
  [ i.name, i.image_id, i.root_device_type, color(i.state), i.creation_date, i.tags.map{ |t| "#{t.key}=#{t.value}" }.sort.join(',') ]
@@ -52,7 +52,7 @@ module Awful
52
52
  def delete(id)
53
53
  images(options).find do |image|
54
54
  image.image_id.match(id)
55
- end.tap do |ami|
55
+ end.output do |ami|
56
56
  if yes? "Really deregister image #{ami.name} (#{ami.image_id})?", :yellow
57
57
  ec2.deregister_image(image_id: ami.image_id)
58
58
  end
@@ -61,7 +61,7 @@ module Awful
61
61
 
62
62
  desc 'dump IDS', 'describe images'
63
63
  def dump(*ids)
64
- ec2.describe_images(image_ids: ids).images.tap do |images|
64
+ ec2.describe_images(image_ids: ids).images.output do |images|
65
65
  images.each do |image|
66
66
  puts YAML.dump(stringify_keys(image.to_hash))
67
67
  end
@@ -71,7 +71,7 @@ module Awful
71
71
  desc 'tags ID [TAGS]', 'get tags for AMI, or set multiple tags as key:value'
72
72
  def tags(id, *tags)
73
73
  if tags.empty?
74
- ec2.describe_images(image_ids: [id]).images.first.tags.tap do |list|
74
+ ec2.describe_images(image_ids: [id]).images.first.tags.output do |list|
75
75
  print_table list.map { |t| [t.key, t.value] }
76
76
  end
77
77
  else
@@ -104,7 +104,7 @@ module Awful
104
104
  image.name.match(name)
105
105
  end.sort_by(&:creation_date).last(options[:count]).map do |image|
106
106
  image.image_id
107
- end.tap do |list|
107
+ end.output do |list|
108
108
  puts list
109
109
  end
110
110
  end
@@ -36,14 +36,14 @@ module Awful
36
36
 
37
37
  desc 'dump ARN', 'describe the stream with ARN as yaml'
38
38
  def dump(arn)
39
- streams.describe_stream(stream_arn: arn).stream_description.tap do |stream|
39
+ streams.describe_stream(stream_arn: arn).stream_description.output do |stream|
40
40
  puts YAML.dump(stringify_keys(stream.to_hash))
41
41
  end
42
42
  end
43
43
 
44
44
  desc 'shards ARN', 'list shards for stream with ARN'
45
45
  def shards(arn)
46
- streams.describe_stream(stream_arn: arn).stream_description.shards.tap do |shards|
46
+ streams.describe_stream(stream_arn: arn).stream_description.shards.output do |shards|
47
47
  puts shards.map(&:shard_id)
48
48
  end
49
49
  end
@@ -52,7 +52,7 @@ module Awful
52
52
  def get_records(arn, shard_id)
53
53
  iterator = streams.get_shard_iterator(stream_arn: arn, shard_id: shard_id, shard_iterator_type: 'TRIM_HORIZON').shard_iterator
54
54
 
55
- streams.get_records(shard_iterator: iterator).records.tap do |records|
55
+ streams.get_records(shard_iterator: iterator).records.output do |records|
56
56
  print_table records.map { |r| [r.event_id, r.event_name, r.dynamodb.sequence_number, r.dynamodb.size_bytes] }
57
57
  end
58
58
  end
data/lib/awful/ec2.rb CHANGED
@@ -56,7 +56,7 @@ module Awful
56
56
  instances.select! { |i| tag_name(i, '').match(name) } if name
57
57
 
58
58
  ## output
59
- instances.tap do |list|
59
+ instances.output do |list|
60
60
  if options[:long]
61
61
  print_table list.map { |i|
62
62
  [
@@ -81,7 +81,7 @@ module Awful
81
81
  def dump(name)
82
82
  ec2.describe_instances.map(&:reservations).flatten.map(&:instances).flatten.find do |instance|
83
83
  instance.instance_id == name or tag_name(instance) == name
84
- end.tap do |instance|
84
+ end.output do |instance|
85
85
  puts YAML.dump(stringify_keys(instance.to_hash))
86
86
  end
87
87
  end
@@ -106,7 +106,7 @@ module Awful
106
106
  opt[:network_interfaces] ? (opt[:network_interfaces][0][:subnet_id] = subnet) : (opt[:subnet_id] = subnet)
107
107
  end
108
108
 
109
- (opt[:tags] = opt.fetch(:tags, [])).find_index { |t| t[:key] == 'Name' }.tap do |index|
109
+ (opt[:tags] = opt.fetch(:tags, [])).find_index { |t| t[:key] == 'Name' }.output do |index|
110
110
  opt[:tags][index || 0] = {key: 'Name', value: name}
111
111
  end
112
112
 
@@ -135,7 +135,7 @@ module Awful
135
135
  ## report DNS or IP for instance
136
136
  ec2.describe_instances(instance_ids: ids).map(&:reservations).flatten.map(&:instances).flatten.map do |instance|
137
137
  instance.public_dns_name or instance.public_ip_address or instance.private_ip_address
138
- end.tap do |list|
138
+ end.output do |list|
139
139
  puts list
140
140
  end
141
141
  end
@@ -143,7 +143,7 @@ module Awful
143
143
  desc 'az', 'list availability zones'
144
144
  method_option :long, aliases: '-l', default: false, desc: 'Long listing'
145
145
  def az
146
- ec2.describe_availability_zones.availability_zones.tap do |zones|
146
+ ec2.describe_availability_zones.availability_zones.output do |zones|
147
147
  if options[:long]
148
148
  print_table zones.map { |z| [z.zone_name, z.state, z.messages.join(',')] }
149
149
  else
@@ -154,14 +154,14 @@ module Awful
154
154
 
155
155
  desc 'allocate', 'allocate a new elastic IP address'
156
156
  def allocate
157
- ec2.allocate_address(domain: 'vpc').first.tap do |eip|
157
+ ec2.allocate_address(domain: 'vpc').first.output do |eip|
158
158
  puts eip.allocation_id, eip.public_ip
159
159
  end
160
160
  end
161
161
 
162
162
  desc 'associate NAME IP', 'associate a public ip with an instance'
163
163
  def associate(name, eip)
164
- ec2.associate_address(instance_id: find_instance(name), allocation_id: eip).map(&:association_id).tap do |id|
164
+ ec2.associate_address(instance_id: find_instance(name), allocation_id: eip).map(&:association_id).output do |id|
165
165
  puts id
166
166
  end
167
167
  end
@@ -170,7 +170,7 @@ module Awful
170
170
  def addresses
171
171
  ec2.describe_addresses.map(&:addresses).flatten.map do |ip|
172
172
  [ ip.allocation_id, ip.public_ip, ip.instance_id, ip.domain ]
173
- end.tap do |list|
173
+ end.output do |list|
174
174
  print_table list
175
175
  end
176
176
  end
@@ -179,7 +179,7 @@ module Awful
179
179
  def dns(name)
180
180
  ec2.describe_instances.map(&:reservations).flatten.map(&:instances).flatten.find do |instance|
181
181
  instance.instance_id == name or (n = tag_name(instance) and n.match(name))
182
- end.public_dns_name.tap do |dns|
182
+ end.public_dns_name.output do |dns|
183
183
  puts dns
184
184
  end
185
185
  end
@@ -189,7 +189,7 @@ module Awful
189
189
  # opt = load_cfg(options)
190
190
  # ec2.describe_instances.map(&:reservations).flatten.map(&:instances).flatten.find do |instance|
191
191
  # instance.instance_id == name or (n = tag_name(instance) and n.match(name))
192
- # end.tap do |instance|
192
+ # end.output do |instance|
193
193
  # ec2.modify_instance_attribute(instance_id: instance.instance_id, user_data: {
194
194
  # #value: Base64.strict_encode64(opt[:user_data])
195
195
  # value: opt[:user_data]
@@ -201,8 +201,8 @@ module Awful
201
201
  def user_data(name)
202
202
  ec2.describe_instances.map(&:reservations).flatten.map(&:instances).flatten.find do |instance|
203
203
  instance.instance_id == name or tag_name(instance) == name
204
- end.tap do |instance|
205
- ec2.describe_instance_attribute(instance_id: instance.instance_id, attribute: 'userData').user_data.value.tap do |user_data|
204
+ end.output do |instance|
205
+ ec2.describe_instance_attribute(instance_id: instance.instance_id, attribute: 'userData').user_data.value.output do |user_data|
206
206
  puts Base64.strict_decode64(user_data)
207
207
  end
208
208
  end
@@ -212,7 +212,7 @@ module Awful
212
212
  def stop(name)
213
213
  ec2.describe_instances.map(&:reservations).flatten.map(&:instances).flatten.find do |instance|
214
214
  instance.instance_id == name or (n = tag_name(instance) and n == name)
215
- end.instance_id.tap do |id|
215
+ end.instance_id.output do |id|
216
216
  if yes? "Really stop instance #{name} (#{id})?", :yellow
217
217
  ec2.stop_instances(instance_ids: Array(id))
218
218
  end
@@ -223,7 +223,7 @@ module Awful
223
223
  def start(name)
224
224
  ec2.describe_instances.map(&:reservations).flatten.map(&:instances).flatten.find do |instance|
225
225
  instance.instance_id == name or (n = tag_name(instance) and n == name)
226
- end.instance_id.tap do |id|
226
+ end.instance_id.output do |id|
227
227
  ec2.start_instances(instance_ids: Array(id))
228
228
  end
229
229
  end
data/lib/awful/s3.rb CHANGED
@@ -35,7 +35,7 @@ module Awful
35
35
  def buckets(name = /./)
36
36
  s3.list_buckets.buckets.select do |bucket|
37
37
  bucket.name.match(/#{name}/)
38
- end.tap do |list|
38
+ end.output do |list|
39
39
  if options[:long]
40
40
  print_table list.map { |b| [ b.name, b.creation_date ] }
41
41
  else
@@ -48,7 +48,7 @@ module Awful
48
48
  def objects(bucket, prefix = nil)
49
49
  s3_resource.bucket(bucket).objects(prefix: prefix).map do |object|
50
50
  object.key
51
- end.tap { |list| puts list }
51
+ end.output { |list| puts list }
52
52
  end
53
53
 
54
54
  desc 'exists? NAME', 'test if bucket exists'
@@ -57,12 +57,12 @@ module Awful
57
57
  s3.head_bucket(bucket: bucket_name) && true
58
58
  rescue Aws::S3::Errors::NotFound
59
59
  false
60
- end.tap(&method(:puts))
60
+ end.output(&method(:puts))
61
61
  end
62
62
 
63
63
  desc 'empty? NAME', 'test if bucket is empty'
64
64
  def empty?(bucket_name)
65
- s3.list_objects(bucket: bucket_name, max_keys: 1).contents.empty?.tap(&method(:puts))
65
+ s3.list_objects(bucket: bucket_name, max_keys: 1).contents.empty?.output(&method(:puts))
66
66
  end
67
67
 
68
68
  desc 'tagged [NAME_PREFIX]', 'list buckets matching given tags'
@@ -89,7 +89,7 @@ module Awful
89
89
  tags.any? do |set|
90
90
  conditions.any? { |c| c.call(set) }
91
91
  end && bucket
92
- end.select{|b| b}.tap do |buckets|
92
+ end.select{|b| b}.output do |buckets|
93
93
  puts buckets.map(&:name)
94
94
  end
95
95
  end
@@ -91,7 +91,9 @@ module Awful
91
91
  ## invoked from code, process ip_permissions objects as args
92
92
  perms = ip_permissions.map do |p|
93
93
  p.to_hash.tap do |h|
94
- h[:user_id_group_pairs] = nil if h[:user_id_group_pairs].empty? # sdk will complain if this is empty
94
+ h.each do |k,v|
95
+ h[k] = nil if (v.respond_to?(:empty?) && v.empty?) # no empty arrays, e.g. user_group_id_pairs, prefix_list_ids
96
+ end
95
97
  end
96
98
  end
97
99
 
data/lib/awful/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Awful
2
- VERSION = '0.0.132'
2
+ VERSION = '0.0.133'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awful
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.132
4
+ version: 0.0.133
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ric Lister
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-20 00:00:00.000000000 Z
11
+ date: 2016-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler