aws_public_ips 1.0.4 → 1.0.5

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: 4a083bab67810085c9610fee6ca593420f077afd
4
- data.tar.gz: eec41af99070ed34d83759f3f042bb3461618e3d
3
+ metadata.gz: 2130ff4b9f59ac6e30c1217be05ae4f3c4f73d17
4
+ data.tar.gz: 24669a0a29799a74acb37e501c467a59865081a3
5
5
  SHA512:
6
- metadata.gz: 78688710a288065d81d6ce4ab60170cbbd3e1f83bed09d3c07efb89a4ad11e92155451ff03836b747554e485081db14b0f262c25636b38ae1c001c7556da80fc
7
- data.tar.gz: 96ab667b2321e1c5f8b656551db71d92c1690715cba785900895493b8f402b48a3e8ea7ae56d9d8b575a2f5ccaa3412ac58f52f895bf2d5e005b616e09307560
6
+ metadata.gz: e4656877db332ff9b05c6b2eda71cb3266280c063dd64528e1da74d4cc18e3618a57feb057b64da9f5cf60dd6deba4edce78db0d3894e215b6ee0f34e8fe322a
7
+ data.tar.gz: 4505daa9cd54e8ca666b9725e25cdd70954155b381de47a4f9cab35393156fc34971371d0430ed6ed5d9b61c6352b54294f957067dbbc5a268841197b433d131
@@ -96,10 +96,10 @@ module AwsPublicIps
96
96
  ::AwsPublicIps::Checks.const_get(service.capitalize).run
97
97
  end
98
98
 
99
- def output(formatter, results)
99
+ def output(formatter, options, results)
100
100
  require "aws_public_ips/formatters/#{formatter}.rb"
101
101
  formatter_klass = ::AwsPublicIps::Formatters.const_get(formatter.capitalize)
102
- output = formatter_klass.new(results).format
102
+ output = formatter_klass.new(results, options).format
103
103
  ::STDOUT.puts output unless output.empty?
104
104
  end
105
105
 
@@ -111,7 +111,7 @@ module AwsPublicIps
111
111
  [service.to_sym, check_service(service)]
112
112
  end.to_h
113
113
 
114
- output(options[:format], results)
114
+ output(options[:format], options, results)
115
115
  rescue ::StandardError, ::Interrupt => ex
116
116
  ::STDERR.puts ex.inspect
117
117
  ::STDERR.puts ex.backtrace if options && options[:verbose]
@@ -5,8 +5,9 @@ require 'json'
5
5
  module AwsPublicIps
6
6
  module Formatters
7
7
  class Json
8
- def initialize(results)
8
+ def initialize(results, options)
9
9
  @results = results
10
+ @options = options
10
11
  end
11
12
 
12
13
  def format
@@ -5,8 +5,9 @@ require 'json'
5
5
  module AwsPublicIps
6
6
  module Formatters
7
7
  class Prettyjson
8
- def initialize(results)
8
+ def initialize(results, options)
9
9
  @results = results
10
+ @options = options
10
11
  end
11
12
 
12
13
  def format
@@ -3,14 +3,31 @@
3
3
  module AwsPublicIps
4
4
  module Formatters
5
5
  class Text
6
- def initialize(results)
6
+ def initialize(results, options)
7
7
  @results = results
8
+ @options = options
8
9
  end
9
10
 
10
11
  def format
12
+ lines = @options[:verbose] ? format_verbose : format_normal
13
+ lines.uniq.join("\n")
14
+ end
15
+
16
+ def format_normal
11
17
  @results.values.flatten.flat_map do |hash|
12
18
  hash[:ip_addresses]
13
- end.uniq.join("\n")
19
+ end
20
+ end
21
+
22
+ def format_verbose
23
+ @results.flat_map do |service, hashes|
24
+ next [] if hashes.empty?
25
+ ["## #{service}"] + hashes.flat_map do |hash|
26
+ [hash[:id], hash[:hostname]].compact.map do |line|
27
+ "# #{line}"
28
+ end + hash[:ip_addresses]
29
+ end
30
+ end
14
31
  end
15
32
  end
16
33
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AwsPublicIps
4
- VERSION = '1.0.4'.freeze
4
+ VERSION = '1.0.5'.freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws_public_ips
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arkadiy Tetelman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-21 00:00:00.000000000 Z
11
+ date: 2018-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-apigateway