depralyzer 0.1.3 → 0.1.4

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: d52e868100c813c02c3230f7e975b67b846af89c9cbf283256a88aa285ebe39d
4
- data.tar.gz: 9b8193303c92dccfcb7985443375143b0f83541077a366e29823d1754fb5db33
3
+ metadata.gz: 1293f264abf36ab70524881a2974f6fdebe2c1e4dabf27deebbcc6b27fb01427
4
+ data.tar.gz: bfddc1e65b56ee647749e2141f2b81723609f68755066bad9d621632c92b1800
5
5
  SHA512:
6
- metadata.gz: cf62b72be1528d168d585aae9cda752c3587276ca7496f0920aafe1d9a22f123f4fdc914fe1d793b7f3c51121a5621b75a585c0dabc7e348f6e2c1202187777d
7
- data.tar.gz: 2cebad4e68d11b596984200370621e74d8d1a461fd59a43a1f8ce26a5dda174fd204d1dfd0113852736ab8be0eb812b1ed84622946a96136c326d87138ea2524
6
+ metadata.gz: fb9fa51a760bade676b6173438c626cbfbfd442d24bad59b2fd9e44441bd0df6563fe56e7acfc3291d3208544014e68c5a76b11ec6d9b0a117fcddddee26f720
7
+ data.tar.gz: 3ec5c7c1bc23dfe2449dadb3deecd35e5f933631c61937b8e1a2a316378c2e82c803c27a1f1e00dc6004f191198f3a8ede720b83c7fbe9421c449ace68e8e3b7
@@ -17,28 +17,48 @@ module Depralyzer
17
17
 
18
18
  def process
19
19
  warnings = input.scan(DEPRECATION_FORMAT)
20
- summary = summarize warnings
20
+ summary = summarize warnings
21
21
  pretty_output summary
22
22
  end
23
-
23
+
24
24
  def pretty_output(summary)
25
25
  puts "Total of #{summary.size} deprecation types with #{occurrence(summary)} occurrences"
26
- m1 = summary.sort_by { |_, value| -value.values.inject(0) { |sum, x| sum + x }}.to_h
26
+ m1 = summary.sort_by { |_, value| -value.values.inject(0) { |sum, x| sum + x } }.to_h
27
27
  m1.each do |top, details|
28
- puts
29
- puts "### #{top} (#{details.values.inject(0) { |sum, x| sum + x }})"
28
+ puts
29
+ puts "### #{top.gsub('_','\_')} (#{details.values.inject(0) { |sum, x| sum + x }})"
30
+
31
+ annotation, new_details = deannotate(details)
30
32
 
31
- m = details.sort_by { |_, value| -value}.to_h
33
+ if annotation
34
+ puts "##### #{annotation.gsub('_','\_')}"
35
+ end
36
+
37
+ m = new_details.sort_by { |_, value| -value }.to_h
32
38
  m.each do |note, cnt|
33
- puts sprintf("- %10d %s", cnt, note)
39
+ puts sprintf("- %10d %s", cnt, note.gsub('_','\_'))
40
+ end
41
+ end
42
+ end
43
+
44
+ def deannotate(details)
45
+ guess, _ = details.keys[0].split('. (', 2)
46
+ new_details = {}
47
+ details.each do |key, value|
48
+ if key.start_with?(guess)
49
+ _, rest = key.split('. (', 2)
50
+ new_details["(#{rest}"] = value
51
+ else
52
+ return [nil, details]
34
53
  end
35
54
  end
55
+ [guess, new_details]
36
56
  end
37
57
 
38
58
  def occurrence(summary)
39
59
  i = 0
40
60
  summary.each do |_, detail|
41
- detail.each do |_, cnt |
61
+ detail.each do |_, cnt|
42
62
  i += cnt
43
63
  end
44
64
  end
@@ -48,10 +68,10 @@ module Depralyzer
48
68
  def summarize(warnings)
49
69
  summary = {}
50
70
  warnings.each do |warning|
51
- content = warning.sub('DEPRECATION WARNING: ','')
52
- type, details = content.split('. ', 2)
53
- summary[type] = {} unless summary.key?(type)
54
- summary[type][details] = 0 unless summary[type].key?(details)
71
+ content = warning.sub('DEPRECATION WARNING: ', '')
72
+ type, details = content.split('. ', 2)
73
+ summary[type] = {} unless summary.key?(type)
74
+ summary[type][details] = 0 unless summary[type].key?(details)
55
75
  summary[type][details] += 1
56
76
  end
57
77
  summary
@@ -4,5 +4,5 @@
4
4
  # Gem version
5
5
  #
6
6
  module Depralyzer
7
- VERSION = '0.1.3'
7
+ VERSION = '0.1.4'
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: depralyzer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Timothy Chambers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-17 00:00:00.000000000 Z
11
+ date: 2018-11-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: depralyzer analyzes and summarizes your deprecations.
14
14
  email: