depralyzer 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/depralyzer/generator.rb +35 -9
- data/lib/depralyzer/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '09a93764f15ad976d7ee482e6929f8147f156a872f4ecd67a059b0278609d4fb'
|
4
|
+
data.tar.gz: 112dbcf423fda86c5fb95a65e80d5cc40eae4c34568bfb5c26a32cbadd6cae64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b57fa536d465c4ef2bc9ef8cb7d2e251cb0b5875ec4b8144c78f5874a65f296d821e8cb148a028e41f3b5cf31626deffd2756f22c573d9d0320aac20e69ee6f
|
7
|
+
data.tar.gz: 0cca3a7feae34faeee90aba4b5e4e7250ba6d1693f54c1ac3275f60a64cb60109f123f0cd8d70b3b6c169597ef16695234e6885a5ae8cb7798ae235c27ce0470
|
data/lib/depralyzer/generator.rb
CHANGED
@@ -26,27 +26,55 @@ module Depralyzer
|
|
26
26
|
m1 = summary.sort_by { |_, value| -value.values.inject(0) { |sum, x| sum + x } }.to_h
|
27
27
|
m1.each do |top, details|
|
28
28
|
puts
|
29
|
-
puts "### #{top.gsub('_','\_')} (#{details.
|
29
|
+
puts "### #{top.gsub('_', '\_')} (#{details.size}) - _est: #{fix_time(details.size)}_"
|
30
30
|
|
31
31
|
annotation, new_details = deannotate(details)
|
32
32
|
|
33
33
|
if annotation
|
34
|
-
puts "##### #{annotation.gsub('_','\_')}"
|
34
|
+
puts "##### #{annotation.gsub('_', '\_')}"
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
m = new_details.sort_by { |_, value| -value }.to_h
|
38
38
|
m.each do |note, cnt|
|
39
|
-
puts sprintf("- %10d %s", cnt, note.gsub('_','\_'))
|
39
|
+
puts sprintf("- %10d %s", cnt, note.gsub('_', '\_'))
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
+
ONE_FIX = 15 * 60
|
45
|
+
|
46
|
+
def fix_time(details)
|
47
|
+
seconds_to_string(details * ONE_FIX)
|
48
|
+
end
|
49
|
+
|
50
|
+
def seconds_to_string(s)
|
51
|
+
|
52
|
+
# d = days, h = hours, m = minutes, s = seconds
|
53
|
+
m = (s / 60).floor
|
54
|
+
s = s % 60
|
55
|
+
h = (m / 60).floor
|
56
|
+
m = m % 60
|
57
|
+
d = (h / 24).floor
|
58
|
+
h = h % 24
|
59
|
+
|
60
|
+
output = "#{m} minute#{pluralize(m)}" if (m > 0)
|
61
|
+
output = "#{h} hour#{pluralize(h)}, #{m} minute#{pluralize(m)}" if (h > 0)
|
62
|
+
output = "#{d} day#{pluralize(d)}, #{h} hour#{pluralize(h)}, #{m} minute#{pluralize(m)}" if (d > 0)
|
63
|
+
|
64
|
+
output.gsub(', 0 minutes','').gsub(', 0 hours','')
|
65
|
+
end
|
66
|
+
|
67
|
+
def pluralize number
|
68
|
+
return "s" unless number == 1
|
69
|
+
""
|
70
|
+
end
|
71
|
+
|
44
72
|
def deannotate(details)
|
45
|
-
guess, _
|
73
|
+
guess, _ = details.keys[0].split('. (', 2)
|
46
74
|
new_details = {}
|
47
75
|
details.each do |key, value|
|
48
76
|
if key.start_with?(guess)
|
49
|
-
_, rest
|
77
|
+
_, rest = key.split('. (', 2)
|
50
78
|
new_details["(#{rest}"] = value
|
51
79
|
else
|
52
80
|
return [nil, details]
|
@@ -58,9 +86,7 @@ module Depralyzer
|
|
58
86
|
def occurrence(summary)
|
59
87
|
i = 0
|
60
88
|
summary.each do |_, detail|
|
61
|
-
detail.
|
62
|
-
i += cnt
|
63
|
-
end
|
89
|
+
i += detail.size
|
64
90
|
end
|
65
91
|
i
|
66
92
|
end
|
data/lib/depralyzer/version.rb
CHANGED