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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1293f264abf36ab70524881a2974f6fdebe2c1e4dabf27deebbcc6b27fb01427
4
- data.tar.gz: bfddc1e65b56ee647749e2141f2b81723609f68755066bad9d621632c92b1800
3
+ metadata.gz: '09a93764f15ad976d7ee482e6929f8147f156a872f4ecd67a059b0278609d4fb'
4
+ data.tar.gz: 112dbcf423fda86c5fb95a65e80d5cc40eae4c34568bfb5c26a32cbadd6cae64
5
5
  SHA512:
6
- metadata.gz: fb9fa51a760bade676b6173438c626cbfbfd442d24bad59b2fd9e44441bd0df6563fe56e7acfc3291d3208544014e68c5a76b11ec6d9b0a117fcddddee26f720
7
- data.tar.gz: 3ec5c7c1bc23dfe2449dadb3deecd35e5f933631c61937b8e1a2a316378c2e82c803c27a1f1e00dc6004f191198f3a8ede720b83c7fbe9421c449ace68e8e3b7
6
+ metadata.gz: 4b57fa536d465c4ef2bc9ef8cb7d2e251cb0b5875ec4b8144c78f5874a65f296d821e8cb148a028e41f3b5cf31626deffd2756f22c573d9d0320aac20e69ee6f
7
+ data.tar.gz: 0cca3a7feae34faeee90aba4b5e4e7250ba6d1693f54c1ac3275f60a64cb60109f123f0cd8d70b3b6c169597ef16695234e6885a5ae8cb7798ae235c27ce0470
@@ -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.values.inject(0) { |sum, x| sum + x }})"
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, _ = details.keys[0].split('. (', 2)
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 = key.split('. (', 2)
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.each do |_, cnt|
62
- i += cnt
63
- end
89
+ i += detail.size
64
90
  end
65
91
  i
66
92
  end
@@ -4,5 +4,5 @@
4
4
  # Gem version
5
5
  #
6
6
  module Depralyzer
7
- VERSION = '0.1.4'
7
+ VERSION = '0.1.5'
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: depralyzer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Timothy Chambers