ruby-progressbar 1.4.1 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -253,6 +253,19 @@ Becomes:
|
|
253
253
|
|
254
254
|
Notice that the absolute length doesn't get any longer, the bar just shrinks to fill the remaining space.
|
255
255
|
|
256
|
+
Want to play a game of PAC-MAN while you wait for your progress?
|
257
|
+
|
258
|
+
```ruby
|
259
|
+
ProgressBar.create( :format => '%a %bᗧ%i %p%% %t',
|
260
|
+
:progress_mark => ' ',
|
261
|
+
:remainder_mark => '・',
|
262
|
+
:starting_at => 10)
|
263
|
+
```
|
264
|
+
|
265
|
+
Becomes **PAC-MAN**!
|
266
|
+
|
267
|
+
Time: --:--:-- ᗧ・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・ 10% Progress
|
268
|
+
|
256
269
|
### Overriding the Length
|
257
270
|
|
258
271
|
By default, the progressbar will try to be as smart as possible about how wide it can be. Under most Unix systems, it should be as wide as the terminal will allow while still fitting on one line. If you wish to override this behavior, you can pass in the `:length` option when creating the bar like so:
|
@@ -32,7 +32,7 @@ class ProgressBar
|
|
32
32
|
|
33
33
|
private
|
34
34
|
def estimated_time
|
35
|
-
return '??:??:??' if
|
35
|
+
return '??:??:??' if running_average.zero? || total.nil?
|
36
36
|
|
37
37
|
hours, minutes, seconds = *divide_seconds(estimated_seconds_remaining)
|
38
38
|
|
@@ -43,14 +43,8 @@ class ProgressBar
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
def average_seconds_per_each
|
47
|
-
return 0 if self.running_average.zero?
|
48
|
-
|
49
|
-
elapsed_whole_seconds.to_f / self.running_average
|
50
|
-
end
|
51
|
-
|
52
46
|
def estimated_seconds_remaining
|
53
|
-
(
|
47
|
+
(elapsed_seconds * (self.total / self.running_average - 1)).round
|
54
48
|
end
|
55
49
|
|
56
50
|
def out_of_bounds_time
|
@@ -654,7 +654,7 @@ describe ProgressBar::Base do
|
|
654
654
|
end
|
655
655
|
|
656
656
|
it 'displays the estimated time remaining when using the "%e" flag' do
|
657
|
-
progressbar.to_s('%e').should match /^ ETA: 01:02:
|
657
|
+
progressbar.to_s('%e').should match /^ ETA: 01:02:03\z/
|
658
658
|
end
|
659
659
|
end
|
660
660
|
|
@@ -155,11 +155,39 @@ describe ProgressBar::Components::EstimatedTimer do
|
|
155
155
|
end
|
156
156
|
|
157
157
|
it 'displays the correct time remaining' do
|
158
|
-
@estimated_time.to_s.should eql ' ETA: 105:33:
|
158
|
+
@estimated_time.to_s.should eql ' ETA: 105:33:20'
|
159
159
|
end
|
160
160
|
end
|
161
161
|
end
|
162
162
|
end
|
163
|
+
|
164
|
+
it 'displays a good estimate for regular increments' do
|
165
|
+
begin
|
166
|
+
Timecop.freeze(t = Time.now)
|
167
|
+
n = 10
|
168
|
+
estimated_time = ProgressBar::Components::EstimatedTimer.new(:total => n)
|
169
|
+
estimated_time.start
|
170
|
+
results = (1..n).map do |i|
|
171
|
+
Timecop.freeze(t + 0.5 * i)
|
172
|
+
estimated_time.increment
|
173
|
+
estimated_time.to_s
|
174
|
+
end
|
175
|
+
results.should == [
|
176
|
+
' ETA: 00:00:05',
|
177
|
+
' ETA: 00:00:04',
|
178
|
+
' ETA: 00:00:04',
|
179
|
+
' ETA: 00:00:03',
|
180
|
+
' ETA: 00:00:03',
|
181
|
+
' ETA: 00:00:02',
|
182
|
+
' ETA: 00:00:02',
|
183
|
+
' ETA: 00:00:01',
|
184
|
+
' ETA: 00:00:01',
|
185
|
+
' ETA: 00:00:00',
|
186
|
+
]
|
187
|
+
ensure
|
188
|
+
Timecop.return
|
189
|
+
end
|
190
|
+
end
|
163
191
|
end
|
164
192
|
|
165
193
|
describe '#out_of_bounds_time_format=' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-progressbar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-01
|
13
|
+
date: 2014-03-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|