puppet-community-rangefinder 0.0.2 → 0.0.3

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
  SHA256:
3
- metadata.gz: 1ca220be6aa4a132ea5446370c2be2e02fa5d4d391026eea586e24636f6010c8
4
- data.tar.gz: 3aa913744e8abc0a9425ebe22e3dea4a32c957e1382df8eedda2c4241d055bbb
3
+ metadata.gz: df586be47d07b0f0933e86a199d3ba2bfe7ab07ea4cdca70a16ebe0c1373c3da
4
+ data.tar.gz: 752482ad501454c4e2d0634ed56eef876e2ee8f4fc6a700a9e8fa3a630c47b2b
5
5
  SHA512:
6
- metadata.gz: 865fc5f2c07268fb2dcb18e23b1ac56eb9b700008fde3cdadf663470c9410a4fc85faa61242adb9c46b1c19c6c2977390216b18140636694070b8158f6d07ed2
7
- data.tar.gz: d65542c4505d25adee4058818240870cdce74a0dd1a2ef04bb5178cf673a476a6f2870a07c68cd3afc834ce4b051cb3ec3f0de00976b4d8166b7fd5a4b5ea61c
6
+ metadata.gz: 489cbbd291d5d246c4e293e8ab8477466351382646bfd982236c6f479c137b4698c55e58ea2dffd0321868471fd35e335806d48421e119ce5ec4c6b9044509b8
7
+ data.tar.gz: 98e847461177dc4b1c753867cfc9d7d9ea52dee6c6963f97c0ec3fcb4741886a1ada3d8ecef94e9d2496f53d215c34b758b7c17845d1e241647d7693ae2d6f52
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # v0.0.3
2
+
3
+ * Added summary view for a list of files
4
+ * Changed how the output was generated to enable library usage
5
+
6
+
1
7
  # v0.0.2
2
8
 
3
9
  * better identification of WILL impact and MAY impact lists
data/README.md CHANGED
@@ -26,7 +26,17 @@ This currently knows how to interpret and look up:
26
26
  * Defined types
27
27
  * Puppet resource types
28
28
 
29
-
29
+
30
+ ## Installation
31
+
32
+ This is distributed as a Ruby gem. Simply `gem install puppet-community-rangefinder`
33
+
34
+ ******************************************************************************
35
+ * Note that this is only useful by members of the Puppet Ecosystem team *
36
+ * because it uses BigQuery data that's not available publicly. *
37
+ ******************************************************************************
38
+
39
+
30
40
  ## Configuration
31
41
 
32
42
  You must configure BigQuery credentials in the `~/.rangefinder.conf` file.
data/bin/rangefinder CHANGED
@@ -16,13 +16,15 @@ will infer what each file defines and then tell you what Forge modules use it.
16
16
  It will separate output by the modules that we KNOW will be impacted and those
17
17
  which we can only GUESS that will be impacted. We can tell the difference based
18
18
  on whether the impacted module has properly described dependencies in their
19
- `metadata.json`.
19
+ `metadata.json`. These are rendered as *exact match* and *near match*.
20
+
21
+ Note that non-namespaced items will always be near match only.
20
22
 
21
23
  "
22
24
 
23
- opts.on('-r', '--render-as FORMAT', 'Render the output as human, json, or yaml') do |val|
25
+ opts.on('-r', '--render-as FORMAT', 'Render the output as human, summarize, json, or yaml') do |val|
24
26
  val = val.downcase.to_sym
25
- fail "Unknown output type (#{val})" unless [:human, :json, :yaml].include? val
27
+ fail "Unknown output type (#{val})" unless [:human, :summarize, :json, :yaml].include? val
26
28
  options[:render] = val
27
29
  end
28
30
 
@@ -1,3 +1,3 @@
1
1
  class Rangefinder
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
data/lib/rangefinder.rb CHANGED
@@ -6,16 +6,45 @@ class Rangefinder
6
6
  require 'rangefinder/version'
7
7
 
8
8
  def initialize(options)
9
+ options[:filenames] ||= [] # don't blow up if we're called with no files
10
+
9
11
  @options = options
10
12
  @bigquery = Rangefinder::Bigquery.new(options)
11
13
 
12
14
  if options[:filenames].size == 1 and File.directory?(options[:filenames].first)
13
15
  options[:filenames] = Dir.glob("#{options[:filenames].first}/*")
14
16
  end
17
+
18
+ @maxlen = options[:filenames].map {|f| File.basename(f).length }.max
15
19
  end
16
20
 
17
21
  def render!
18
- @options[:filenames].each do |filename|
22
+ results = analyze(@options[:filenames])
23
+
24
+ if @options[:render] == :summarize
25
+ printf("%-#{@maxlen}s%12s%8s%6s\n", 'Item Name', 'Kind', 'Exact', 'Near')
26
+ puts '=' * (@maxlen+26)
27
+ end
28
+
29
+ results.compact.each do |item|
30
+ case @options[:render]
31
+ when :human
32
+ puts pretty_print(item)
33
+ when :summarize
34
+ puts print_line(item)
35
+ when :json
36
+ puts JSON.pretty_generate(item)
37
+ when :yaml
38
+ require 'yaml'
39
+ puts item.to_yaml
40
+ else
41
+ raise "Invalid render type (#{@options[:render]})."
42
+ end
43
+ end
44
+ end
45
+
46
+ def analyze(files)
47
+ files.map do |filename|
19
48
  case File.extname(filename).downcase
20
49
  when '.pp'
21
50
  kind, name = Rangefinder::Parser::Puppet.new(filename).evaluate!
@@ -31,19 +60,7 @@ class Rangefinder
31
60
  next
32
61
  end
33
62
 
34
- results = @bigquery.find(namespace(filename), kind, name)
35
-
36
- case @options[:render]
37
- when :human
38
- puts pretty_print(results)
39
- when :json
40
- puts JSON.pretty_generate(results)
41
- when :yaml
42
- require 'yaml'
43
- puts results.to_yaml
44
- else
45
- raise "Invalid render type (#{@options[:render]})."
46
- end
63
+ @bigquery.find(namespace(filename), kind, name)
47
64
  end
48
65
  end
49
66
 
@@ -62,6 +79,10 @@ class Rangefinder
62
79
  metadata['name']
63
80
  end
64
81
 
82
+ def print_line(results)
83
+ sprintf("%-#{@maxlen}s%12s%8d%6d\n", results[:name], results[:kind], results[:exact].size, results[:near].size)
84
+ end
85
+
65
86
  def pretty_print(results)
66
87
  output = "[#{results[:name]}] is a _#{results[:kind]}_\n"
67
88
  output << "==================================\n"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-community-rangefinder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Ford
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-01 00:00:00.000000000 Z
11
+ date: 2018-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puppet