progress_bar 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a07562e4e740ecee296310b6d4c9600748fbc86f
4
- data.tar.gz: f27d4a1053f6a01c29b82976973d214639075c1f
3
+ metadata.gz: 40985cca5f77a94078a72ab95f7b57e9f0404a9c
4
+ data.tar.gz: be48f2441f9b3810f186d1f7e02a406737fbcb8a
5
5
  SHA512:
6
- metadata.gz: ce5db1fecd0c834b67330b366bede9c571fce4e3dc8d046df5e12e5bc811ba29146d16f395d3459177fcef59d6a0ecb47671a04fec5a1ca68a4723fe8c069f39
7
- data.tar.gz: 6cfa098ce5efcffbb81318e8e2fce719735774ab91010ba36a76f5ec248250ace1977f4a2a79d04c783aae30ca1fc24dcc923b2aa8e5f2f191be9332edce1c69
6
+ metadata.gz: 08e3f5b64719f3d271b33f801bf15298922c9e34f2fb49452f173d96ef2c8434057465d98f9dbc918cb9c12996a472e13935fd3e892a833f8246e28c85962ba9
7
+ data.tar.gz: ec975577846e1793cb197af3f639446325b84e1ee5c50f1b7d4a0726cf60e37b306d89b96a8cc2e34ebde2301ba8ef9b1c65fadeb61bb4513c19be8468da185a
data/lib/progress_bar.rb CHANGED
@@ -44,7 +44,7 @@ class ProgressBar
44
44
  end
45
45
 
46
46
  def ratio
47
- count.to_f / max
47
+ [count.to_f / max, 1.0].min # never go above 1, even if count > max
48
48
  end
49
49
 
50
50
  def percentage
@@ -127,7 +127,9 @@ class ProgressBar
127
127
 
128
128
  def terminal_width
129
129
  # HighLine check takes a long time, so only update width every second.
130
- if @last_width_adjustment.nil? || ::Time.now - @last_width_adjustment > 1
130
+ if @terminal_width.nil? || @last_width_adjustment.nil? ||
131
+ ::Time.now - @last_width_adjustment > 1
132
+
131
133
  @last_width_adjustment = ::Time.now
132
134
  @terminal_width = @hl.output_cols.to_i
133
135
  if @terminal_width < 1
@@ -1,3 +1,3 @@
1
1
  class ProgressBar
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: progress_bar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Sadauskas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-12 00:00:00.000000000 Z
11
+ date: 2014-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: options