console 1.36.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/clock.rb +15 -8
- data/lib/console/event/spawn.rb +7 -1
- data/lib/console/logger.rb +1 -1
- data/lib/console/progress.rb +8 -4
- data/lib/console/resolver.rb +7 -2
- data/lib/console/terminal/formatter/progress.rb +3 -5
- data/lib/console/version.rb +1 -1
- data/readme.md +8 -8
- data/releases.md +8 -0
- data.tar.gz.sig +3 -2
- 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/clock.rb
CHANGED
|
@@ -16,21 +16,28 @@ module Console
|
|
|
16
16
|
return format("%.2fs", duration)
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
duration
|
|
19
|
+
minutes = duration / 60.0
|
|
20
20
|
|
|
21
|
-
if
|
|
22
|
-
|
|
21
|
+
if minutes < 60.0
|
|
22
|
+
seconds = duration % 60
|
|
23
|
+
return format("%dm%02ds", minutes, seconds)
|
|
23
24
|
end
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
hours = minutes / 60.0
|
|
26
27
|
|
|
27
|
-
if
|
|
28
|
-
|
|
28
|
+
if hours < 24.0
|
|
29
|
+
minutes = minutes % 60
|
|
30
|
+
return format("%dh%02dm", hours, minutes)
|
|
29
31
|
end
|
|
30
32
|
|
|
31
|
-
|
|
33
|
+
days = hours / 24.0
|
|
34
|
+
|
|
35
|
+
if days < 100.0
|
|
36
|
+
hours = hours % 24
|
|
37
|
+
return format("%dd%02dh", days, hours)
|
|
38
|
+
end
|
|
32
39
|
|
|
33
|
-
return "
|
|
40
|
+
return format("%dd", days)
|
|
34
41
|
end
|
|
35
42
|
|
|
36
43
|
# @returns [Time] The current monotonic time.
|
data/lib/console/event/spawn.rb
CHANGED
|
@@ -61,7 +61,7 @@ module Console
|
|
|
61
61
|
#
|
|
62
62
|
# @parameter status [Process::Status] The status of the command.
|
|
63
63
|
def status=(status)
|
|
64
|
-
@end_time =
|
|
64
|
+
@end_time = self.now
|
|
65
65
|
@status = status
|
|
66
66
|
end
|
|
67
67
|
|
|
@@ -100,6 +100,12 @@ module Console
|
|
|
100
100
|
options[:severity] ||= :info
|
|
101
101
|
super
|
|
102
102
|
end
|
|
103
|
+
|
|
104
|
+
private
|
|
105
|
+
|
|
106
|
+
def now
|
|
107
|
+
Clock.now
|
|
108
|
+
end
|
|
103
109
|
end
|
|
104
110
|
end
|
|
105
111
|
end
|
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.
|
data/lib/console/resolver.rb
CHANGED
|
@@ -103,8 +103,13 @@ module Console
|
|
|
103
103
|
#
|
|
104
104
|
# @parameter trace_point [TracePoint] The trace point that triggered the event.
|
|
105
105
|
def resolve(trace_point)
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
resolve_class(trace_point.self)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# @parameter klass [Class] The class that was resolved.
|
|
110
|
+
def resolve_class(klass)
|
|
111
|
+
if block = @names.delete(klass.to_s)
|
|
112
|
+
block.call(klass)
|
|
108
113
|
end
|
|
109
114
|
|
|
110
115
|
if @names.empty?
|
|
@@ -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,14 @@ 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
|
+
|
|
41
|
+
### v1.37.0
|
|
42
|
+
|
|
43
|
+
- Show compound units in elapsed time display.
|
|
44
|
+
|
|
37
45
|
### v1.36.0
|
|
38
46
|
|
|
39
47
|
- Add a `size_limit` to `Console::Format::Safe` (default 16KiB) which rebuilds oversized records field-by-field, keeping as many top-level fields as fit within the limit.
|
|
@@ -72,14 +80,6 @@ Please see the [project releases](https://socketry.github.io/console/releases/in
|
|
|
72
80
|
|
|
73
81
|
- Serialized output now uses `IO#write` with a single string to reduce the chance of interleaved output.
|
|
74
82
|
|
|
75
|
-
### v1.29.2
|
|
76
|
-
|
|
77
|
-
- Always return `nil` from `Console::Filter` logging methods.
|
|
78
|
-
|
|
79
|
-
### v1.29.1
|
|
80
|
-
|
|
81
|
-
- Fix logging `exception:` keyword argument when the value was not an exception.
|
|
82
|
-
|
|
83
83
|
## Contributing
|
|
84
84
|
|
|
85
85
|
We welcome contributions to this project.
|
data/releases.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Releases
|
|
2
2
|
|
|
3
|
+
## v1.38.0
|
|
4
|
+
|
|
5
|
+
- Fix `Console::Progress` to emit through the logger that created it and safely handle zero totals.
|
|
6
|
+
|
|
7
|
+
## v1.37.0
|
|
8
|
+
|
|
9
|
+
- Show compound units in elapsed time display.
|
|
10
|
+
|
|
3
11
|
## v1.36.0
|
|
4
12
|
|
|
5
13
|
- Add a `size_limit` to `Console::Format::Safe` (default 16KiB) which rebuilds oversized records field-by-field, keeping as many top-level fields as fit within the limit.
|
data.tar.gz.sig
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
f��{(Rq��l�m*�%��_���[�PP%�lu��%�}�B�d{����]�e騥p����K�#�K��P��/U�;aӚ��r����l
|
|
2
|
+
��+�;�&� �#E"H�rE�H-Sk��s�BF<�P���m��
|
|
3
|
+
�iDҚ1/C��
|
metadata
CHANGED
metadata.gz.sig
CHANGED
|
Binary file
|