console 1.37.0 → 1.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/console/logger.rb +1 -1
- data/lib/console/progress.rb +8 -4
- data/lib/console/terminal/formatter/progress.rb +3 -5
- data/lib/console/version.rb +1 -1
- data/readme.md +4 -4
- data/releases.md +4 -0
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 00b1eca4193288f97e7b4e1a5dd1cd5e074447bf26f92e994eab48a3daf2728a
|
|
4
|
+
data.tar.gz: efa0889c58183210e91d37efbfc0ee5952020fd43f0524717a1cce09cc626139
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8c1bd30af3388dccfba16b043f54643a6daf23fbe859117897608e93cc6a451d89367d7518ca42710c2c6daa52a9b981215f4cc999b4c7a0fdfc15844861f2c2
|
|
7
|
+
data.tar.gz: 57e0f70484777fbfa5c8a03d8604ae4f915dad90f5154bd47553c303ab28d700f4671eb9293be4ca11a827243887a91f334a20058998ce636e5ab7fd75030987
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/lib/console/logger.rb
CHANGED
data/lib/console/progress.rb
CHANGED
|
@@ -18,10 +18,12 @@ module Console
|
|
|
18
18
|
#
|
|
19
19
|
# @parameter subject [Object] The subject of the progress indicator.
|
|
20
20
|
# @parameter total [Integer] The total number of steps.
|
|
21
|
+
# @parameter logger [Console::Logger] The logger to use for output.
|
|
21
22
|
# @parameter minimum_output_duration [Numeric] The minimum duration between outputs.
|
|
22
23
|
# @parameter options [Hash] Additional options to customize the output.
|
|
23
|
-
def initialize(subject, total = 0, minimum_output_duration: 0.1, **options)
|
|
24
|
+
def initialize(subject, total = 0, logger: Console, minimum_output_duration: 0.1, **options)
|
|
24
25
|
@subject = subject
|
|
26
|
+
@logger = logger
|
|
25
27
|
@options = options
|
|
26
28
|
|
|
27
29
|
@start_time = Clock.now
|
|
@@ -55,6 +57,8 @@ module Console
|
|
|
55
57
|
|
|
56
58
|
# @returns [Rational] The ratio of steps completed to total steps.
|
|
57
59
|
def ratio
|
|
60
|
+
return Rational(0, 1) if @total.zero?
|
|
61
|
+
|
|
58
62
|
Rational(@current.to_f, @total.to_f)
|
|
59
63
|
end
|
|
60
64
|
|
|
@@ -99,7 +103,7 @@ module Console
|
|
|
99
103
|
@current += amount
|
|
100
104
|
|
|
101
105
|
if output?
|
|
102
|
-
|
|
106
|
+
@logger.call(@subject, self.to_s, event: self.to_hash, **@options)
|
|
103
107
|
@last_output_time = Clock.now
|
|
104
108
|
end
|
|
105
109
|
|
|
@@ -113,7 +117,7 @@ module Console
|
|
|
113
117
|
def resize(total)
|
|
114
118
|
@total = total
|
|
115
119
|
|
|
116
|
-
|
|
120
|
+
@logger.call(@subject, self.to_s, event: self.to_hash, **@options)
|
|
117
121
|
@last_output_time = Clock.now
|
|
118
122
|
|
|
119
123
|
return self
|
|
@@ -125,7 +129,7 @@ module Console
|
|
|
125
129
|
# @parameter **options [Hash] Additional options to log.
|
|
126
130
|
# @parameter &block [Proc] An optional block used to generate the log message.
|
|
127
131
|
def mark(*arguments, **options, &block)
|
|
128
|
-
|
|
132
|
+
@logger.call(@subject, *arguments, **options, **@options, &block)
|
|
129
133
|
end
|
|
130
134
|
|
|
131
135
|
# @returns [String] A human-readable representation of the progress indicator.
|
|
@@ -41,12 +41,10 @@ module Console
|
|
|
41
41
|
def format(event, stream, verbose: false, width: 80)
|
|
42
42
|
current = event[:current].to_f
|
|
43
43
|
total = event[:total].to_f
|
|
44
|
-
value = current / total
|
|
44
|
+
value = total.zero? ? 0.0 : current / total
|
|
45
45
|
|
|
46
|
-
# Clamp value to
|
|
47
|
-
|
|
48
|
-
value = 1.0
|
|
49
|
-
end
|
|
46
|
+
# Clamp value to avoid rendering issues:
|
|
47
|
+
value = value.clamp(0.0, 1.0)
|
|
50
48
|
|
|
51
49
|
stream.puts "#{@terminal[:progress_bar]}#{self.bar(value, width-10)}#{@terminal.reset} #{sprintf('%6.2f', value * 100)}%"
|
|
52
50
|
end
|
data/lib/console/version.rb
CHANGED
data/readme.md
CHANGED
|
@@ -34,6 +34,10 @@ Please see the [project documentation](https://socketry.github.io/console/) for
|
|
|
34
34
|
|
|
35
35
|
Please see the [project releases](https://socketry.github.io/console/releases/index) for all releases.
|
|
36
36
|
|
|
37
|
+
### v1.38.0
|
|
38
|
+
|
|
39
|
+
- Fix `Console::Progress` to emit through the logger that created it and safely handle zero totals.
|
|
40
|
+
|
|
37
41
|
### v1.37.0
|
|
38
42
|
|
|
39
43
|
- Show compound units in elapsed time display.
|
|
@@ -76,10 +80,6 @@ Please see the [project releases](https://socketry.github.io/console/releases/in
|
|
|
76
80
|
|
|
77
81
|
- Serialized output now uses `IO#write` with a single string to reduce the chance of interleaved output.
|
|
78
82
|
|
|
79
|
-
### v1.29.2
|
|
80
|
-
|
|
81
|
-
- Always return `nil` from `Console::Filter` logging methods.
|
|
82
|
-
|
|
83
83
|
## Contributing
|
|
84
84
|
|
|
85
85
|
We welcome contributions to this project.
|
data/releases.md
CHANGED
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
|
Binary file
|