progress 3.4.0 → 3.5.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 +5 -5
- data/.rubocop.yml +11 -4
- data/.travis.yml +6 -5
- data/CHANGELOG.markdown +4 -0
- data/LICENSE.txt +1 -1
- data/README.markdown +3 -3
- data/lib/progress/class_methods.rb +17 -4
- data/lib/progress/eta.rb +3 -0
- data/lib/progress/kernel.rb +2 -1
- data/lib/progress/with_progress.rb +1 -0
- data/progress.gemspec +3 -3
- data/spec/progress_spec.rb +59 -14
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 88486a9fc4ddbe22b0ba6c4d398c71827a2dca05ac9fee01a4a715a72e8a1ddc
|
4
|
+
data.tar.gz: ff8bd4245c78217409212fb60bdc0b3e205604290ffd2005371e0c38cf7c7eee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a52da0e1033be9ca9069c62c92aa7936c95d4f45df94cbacfb6de439d96fd441a2c59a72750b9728136f11c08ad4e8ade9b51549ee17a3f3da47e915a25cb3a7
|
7
|
+
data.tar.gz: 1a413c2310ae732d1a3bfbe53e86b1a55dbb6677920e6d2cd3307ec59e67a028de5cafa83e53fb728b76ccdbd9b8bbddc2dcf4b5660887837d1fbc5ac77f26e7
|
data/.rubocop.yml
CHANGED
@@ -11,17 +11,21 @@ Layout/CaseIndentation:
|
|
11
11
|
Layout/DotPosition:
|
12
12
|
EnforcedStyle: trailing
|
13
13
|
|
14
|
+
Layout/EndAlignment:
|
15
|
+
EnforcedStyleAlignWith: variable
|
16
|
+
|
14
17
|
Layout/IndentHash:
|
15
18
|
EnforcedStyle: consistent
|
16
19
|
|
17
20
|
Layout/SpaceBeforeBlockBraces:
|
18
21
|
EnforcedStyle: no_space
|
22
|
+
EnforcedStyleForEmptyBraces: no_space
|
19
23
|
|
20
24
|
Layout/SpaceInsideHashLiteralBraces:
|
21
25
|
EnforcedStyle: no_space
|
22
26
|
|
23
|
-
Lint/
|
24
|
-
|
27
|
+
Lint/UnneededRequireStatement:
|
28
|
+
Enabled: false
|
25
29
|
|
26
30
|
Metrics/AbcSize:
|
27
31
|
Max: 30
|
@@ -61,7 +65,7 @@ Style/Encoding:
|
|
61
65
|
Enabled: false
|
62
66
|
|
63
67
|
Style/IfUnlessModifier:
|
64
|
-
|
68
|
+
Enabled: false
|
65
69
|
|
66
70
|
Style/NumericPredicate:
|
67
71
|
Enabled: false
|
@@ -75,5 +79,8 @@ Style/Semicolon:
|
|
75
79
|
Style/TrailingCommaInArguments:
|
76
80
|
EnforcedStyleForMultiline: no_comma
|
77
81
|
|
78
|
-
Style/
|
82
|
+
Style/TrailingCommaInArrayLiteral:
|
83
|
+
EnforcedStyleForMultiline: comma
|
84
|
+
|
85
|
+
Style/TrailingCommaInHashLiteral:
|
79
86
|
EnforcedStyleForMultiline: comma
|
data/.travis.yml
CHANGED
@@ -6,17 +6,18 @@ rvm:
|
|
6
6
|
- '1.9.3-p551'
|
7
7
|
- '2.0.0-p648'
|
8
8
|
- '2.1.10'
|
9
|
-
- '2.2.
|
10
|
-
- '2.3.
|
11
|
-
- '2.4.
|
9
|
+
- '2.2.10'
|
10
|
+
- '2.3.8'
|
11
|
+
- '2.4.5'
|
12
|
+
- '2.5.3'
|
12
13
|
- 'jruby-9.0.5.0'
|
13
14
|
- 'jruby-9.1.9.0'
|
14
15
|
script: bundle exec rspec
|
15
16
|
matrix:
|
16
17
|
include:
|
17
18
|
- env: RUBOCOP=✓
|
18
|
-
rvm: '2.4.
|
19
|
+
rvm: '2.4.5'
|
19
20
|
script: bundle exec rubocop
|
20
21
|
- env: CHECK_RUBIES=✓
|
21
|
-
rvm: '2.4.
|
22
|
+
rvm: '2.4.5'
|
22
23
|
script: bundle exec travis_check_rubies
|
data/CHANGELOG.markdown
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
## unreleased
|
4
4
|
|
5
|
+
## v3.5.0 (2018-10-19)
|
6
|
+
|
7
|
+
* Add `Progress.without_beeper` for stopping periodical refresh of progress/eta for the duration of the block [@toy](https://github.com/toy)
|
8
|
+
|
5
9
|
## v3.4.0 (2017-10-11)
|
6
10
|
|
7
11
|
* Remove special handling for CSV in ruby 1.8 [@toy](https://github.com/toy)
|
data/LICENSE.txt
CHANGED
data/README.markdown
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
[](https://rubygems.org/gems/progress)
|
2
2
|
[](https://travis-ci.org/toy/progress)
|
3
|
-
[](https://codeclimate.com/github/toy/progress)
|
4
|
+
[](https://depfu.com/github/toy/progress)
|
5
5
|
[](https://inch-ci.org/github/toy/progress)
|
6
6
|
|
7
7
|
# progress
|
@@ -137,4 +137,4 @@ Or if you know that B runs 9 times faster than C:
|
|
137
137
|
|
138
138
|
## Copyright
|
139
139
|
|
140
|
-
Copyright (c) 2008-
|
140
|
+
Copyright (c) 2008-2018 Ivan Kuchin. See LICENSE.txt for details.
|
@@ -12,6 +12,7 @@ class Progress
|
|
12
12
|
init(total, title)
|
13
13
|
print_message force: true
|
14
14
|
return unless block_given?
|
15
|
+
|
15
16
|
begin
|
16
17
|
yield
|
17
18
|
ensure
|
@@ -44,6 +45,7 @@ class Progress
|
|
44
45
|
# stop progress
|
45
46
|
def stop
|
46
47
|
return unless running?
|
48
|
+
|
47
49
|
if @levels.length == 1
|
48
50
|
print_message force: true, finish: true
|
49
51
|
stop_beeper
|
@@ -59,6 +61,7 @@ class Progress
|
|
59
61
|
# set note
|
60
62
|
def note=(note)
|
61
63
|
return unless running?
|
64
|
+
|
62
65
|
@levels.last.note = note
|
63
66
|
end
|
64
67
|
|
@@ -82,7 +85,7 @@ class Progress
|
|
82
85
|
@highlight = true && value
|
83
86
|
end
|
84
87
|
|
85
|
-
# show
|
88
|
+
# show progress in terminal title
|
86
89
|
def terminal_title?
|
87
90
|
@terminal_title.nil? ? io_tty? : @terminal_title
|
88
91
|
end
|
@@ -102,6 +105,15 @@ class Progress
|
|
102
105
|
io.tty? || ENV['PROGRESS_TTY']
|
103
106
|
end
|
104
107
|
|
108
|
+
# don't refresh progress (eta) periodically for the duration of the block
|
109
|
+
def without_beeper
|
110
|
+
old_state = @without_beeper
|
111
|
+
@without_beeper = true
|
112
|
+
yield
|
113
|
+
ensure
|
114
|
+
@without_beeper = old_state
|
115
|
+
end
|
116
|
+
|
105
117
|
private
|
106
118
|
|
107
119
|
attr_reader :eta
|
@@ -139,7 +151,7 @@ class Progress
|
|
139
151
|
|
140
152
|
def start_beeper
|
141
153
|
@beeper = Beeper.new(10) do
|
142
|
-
print_message
|
154
|
+
print_message unless @without_beeper
|
143
155
|
end
|
144
156
|
end
|
145
157
|
|
@@ -188,7 +200,7 @@ class Progress
|
|
188
200
|
|
189
201
|
def build_message(options)
|
190
202
|
current = 0
|
191
|
-
|
203
|
+
reverse_parts = @levels.reverse.map do |level|
|
192
204
|
current = level.to_f(current)
|
193
205
|
|
194
206
|
part = current.zero? ? '......' : format('%5.1f%%', current * 100.0)
|
@@ -198,7 +210,8 @@ class Progress
|
|
198
210
|
end
|
199
211
|
|
200
212
|
level.title ? "#{level.title}: #{part}" : part
|
201
|
-
end
|
213
|
+
end
|
214
|
+
message = reverse_parts.reverse * ' > '
|
202
215
|
|
203
216
|
if options[:finish]
|
204
217
|
message << " (elapsed: #{eta.elapsed})"
|
data/lib/progress/eta.rb
CHANGED
@@ -8,6 +8,7 @@ class Progress
|
|
8
8
|
def left(completed)
|
9
9
|
seconds = seconds_left(completed)
|
10
10
|
return unless seconds && seconds > 0
|
11
|
+
|
11
12
|
seconds_to_string(seconds)
|
12
13
|
end
|
13
14
|
|
@@ -19,6 +20,7 @@ class Progress
|
|
19
20
|
|
20
21
|
def seconds_to_string(seconds)
|
21
22
|
return unless seconds
|
23
|
+
|
22
24
|
case seconds
|
23
25
|
when 0...60
|
24
26
|
format '%.0fs', seconds
|
@@ -34,6 +36,7 @@ class Progress
|
|
34
36
|
def seconds_left(completed)
|
35
37
|
now = Time.now
|
36
38
|
return unless completed > 0 && now - @started_at >= 1
|
39
|
+
|
37
40
|
current_eta = @started_at + (now - @started_at) / completed
|
38
41
|
@left = if @left
|
39
42
|
@left + (current_eta - @left) * (1 + completed) * 0.5
|
data/lib/progress/kernel.rb
CHANGED
data/progress.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'progress'
|
5
|
-
s.version = '3.
|
5
|
+
s.version = '3.5.0'
|
6
6
|
s.summary = %q{Show progress of long running tasks}
|
7
7
|
s.homepage = "http://github.com/toy/#{s.name}"
|
8
8
|
s.authors = ['Ivan Kuchin']
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.require_paths = %w[lib]
|
19
19
|
|
20
20
|
s.add_development_dependency 'rspec', '~> 3.0'
|
21
|
-
if RUBY_VERSION >= '2.
|
22
|
-
s.add_development_dependency 'rubocop', '~> 0.
|
21
|
+
if RUBY_VERSION >= '2.2'
|
22
|
+
s.add_development_dependency 'rubocop', '~> 0.59'
|
23
23
|
end
|
24
24
|
end
|
data/spec/progress_spec.rb
CHANGED
@@ -340,32 +340,32 @@ describe Progress do
|
|
340
340
|
end
|
341
341
|
end
|
342
342
|
|
343
|
-
def title(
|
344
|
-
"\e]0;#{
|
343
|
+
def title(str)
|
344
|
+
"\e]0;#{str}\a"
|
345
345
|
end
|
346
346
|
|
347
|
-
def hl(
|
348
|
-
"\e[1m#{
|
347
|
+
def hl(str)
|
348
|
+
"\e[1m#{str}\e[0m"
|
349
349
|
end
|
350
350
|
|
351
|
-
def unhl(
|
352
|
-
|
351
|
+
def unhl(str)
|
352
|
+
str.gsub(/\e\[\dm/, '')
|
353
353
|
end
|
354
354
|
|
355
|
-
def on_line(
|
356
|
-
"\r" +
|
355
|
+
def on_line(str)
|
356
|
+
"\r" + str + "\e[K"
|
357
357
|
end
|
358
358
|
|
359
|
-
def line(
|
360
|
-
|
359
|
+
def line(str)
|
360
|
+
str + "\n"
|
361
361
|
end
|
362
362
|
|
363
|
-
def on_line_n_title(
|
364
|
-
[on_line(
|
363
|
+
def on_line_n_title(str)
|
364
|
+
[on_line(str), title(unhl(str))]
|
365
365
|
end
|
366
366
|
|
367
|
-
def line_n_title(
|
368
|
-
[line(
|
367
|
+
def line_n_title(str)
|
368
|
+
[line(str), title(unhl(str))]
|
369
369
|
end
|
370
370
|
|
371
371
|
it 'produces valid output when staying on line' do
|
@@ -522,5 +522,50 @@ describe Progress do
|
|
522
522
|
it{ is_expected.to be_truthy }
|
523
523
|
end
|
524
524
|
end
|
525
|
+
|
526
|
+
describe '.without_beeper' do
|
527
|
+
before do
|
528
|
+
allow(Progress).to receive(:start_beeper).and_call_original
|
529
|
+
allow(Progress::Beeper).to receive(:new) do |*, &block|
|
530
|
+
@block = block
|
531
|
+
double(restart: nil, stop: nil)
|
532
|
+
end
|
533
|
+
expect(Progress).to receive(:print_message).exactly(print_times).times
|
534
|
+
end
|
535
|
+
|
536
|
+
context 'when not used' do
|
537
|
+
let(:print_times){ 3 }
|
538
|
+
|
539
|
+
it 'allows beeper to print progress' do
|
540
|
+
Progress.start do
|
541
|
+
@block.call
|
542
|
+
end
|
543
|
+
end
|
544
|
+
end
|
545
|
+
|
546
|
+
context 'when used around progress block' do
|
547
|
+
let(:print_times){ 2 }
|
548
|
+
|
549
|
+
it 'stops beeper from printing progress' do
|
550
|
+
Progress.without_beeper do
|
551
|
+
Progress.start do
|
552
|
+
@block.call
|
553
|
+
end
|
554
|
+
end
|
555
|
+
end
|
556
|
+
end
|
557
|
+
|
558
|
+
context 'when used inside progress block' do
|
559
|
+
let(:print_times){ 2 }
|
560
|
+
|
561
|
+
it 'stops beeper from printing progress' do
|
562
|
+
Progress.start do
|
563
|
+
Progress.without_beeper do
|
564
|
+
@block.call
|
565
|
+
end
|
566
|
+
end
|
567
|
+
end
|
568
|
+
end
|
569
|
+
end
|
525
570
|
end
|
526
571
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: progress
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Kuchin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0.
|
33
|
+
version: '0.59'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0.
|
40
|
+
version: '0.59'
|
41
41
|
description:
|
42
42
|
email:
|
43
43
|
executables: []
|
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
83
|
version: '0'
|
84
84
|
requirements: []
|
85
85
|
rubyforge_project: progress
|
86
|
-
rubygems_version: 2.
|
86
|
+
rubygems_version: 2.7.7
|
87
87
|
signing_key:
|
88
88
|
specification_version: 4
|
89
89
|
summary: Show progress of long running tasks
|