popro 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +1 -0
- data/lib/popro.rb +10 -0
- data/lib/popro/formatter.rb +26 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c3d8c8dba5a532d23b95582322983b844243a72679bff15acce69933c106ea2
|
4
|
+
data.tar.gz: ea5170d62aa990167c89d0fee9d7ee07d1cb1902f0a8e64f1920abbb523ed446
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9023ad0fbf774e02fab5dc99df4720365a742c651469342bed04326fa88a34dd7e91d04830f50a4d28ac28a677e660a93715b6b51688b17668933cf0bdc3276e
|
7
|
+
data.tar.gz: b79e9a485d34aaab14bd7674a3adfad80305ba9c87b0ff8a7cd1981ec5dd6afeaef263efab503cef06065662c5d1ad296e7bec3c49c56e21117028fb691a5d7e
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
0.2.4 add support for `Popro.(un)silence!` atomic silencing, better duration formatting
|
1
2
|
0.2.3 add support for `Popro.silenced`
|
2
3
|
0.2.2 add gonna and each_gonna, add Callback Indicator
|
3
4
|
0.2.1 add support for estimation and re-use of default indicator with added concatted formatters
|
data/lib/popro.rb
CHANGED
data/lib/popro/formatter.rb
CHANGED
@@ -63,6 +63,15 @@ module Popro
|
|
63
63
|
|
64
64
|
private
|
65
65
|
|
66
|
+
UNITS = [
|
67
|
+
[60, '%02ds'],
|
68
|
+
[60, '%02dm'],
|
69
|
+
[24, '%02dh'],
|
70
|
+
[7, '%d days, '],
|
71
|
+
[52, '%d weeks, '],
|
72
|
+
[nil, '%d years, ']
|
73
|
+
].freeze
|
74
|
+
|
66
75
|
def elapsed
|
67
76
|
current_time - @start_time
|
68
77
|
end
|
@@ -80,9 +89,24 @@ module Popro
|
|
80
89
|
end
|
81
90
|
|
82
91
|
def format_duration(secs)
|
83
|
-
return '
|
92
|
+
return '?' if secs.nil?
|
93
|
+
|
94
|
+
return format('%.3fs', secs) if secs < 10
|
95
|
+
|
96
|
+
format_duration_long(secs)
|
97
|
+
end
|
98
|
+
|
99
|
+
def format_duration_long(secs)
|
100
|
+
UNITS.map do |(divisor, format_str)|
|
101
|
+
next if secs < 1
|
102
|
+
|
103
|
+
if divisor
|
104
|
+
amount = secs % divisor
|
105
|
+
secs /= divisor
|
106
|
+
end
|
84
107
|
|
85
|
-
|
108
|
+
format(format_str, divisor ? amount : secs)
|
109
|
+
end.take_while(&:itself).reverse!.join
|
86
110
|
end
|
87
111
|
|
88
112
|
def current_time
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: popro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MikeSmithEU
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-09-
|
11
|
+
date: 2020-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: The Poor-Man's Progress Indicator
|
14
14
|
email:
|