progress_bar 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/lib/progress_bar/version.rb +1 -1
- data/lib/progress_bar.rb +13 -1
- data/test/progress_bar_test.rb +8 -0
- metadata +20 -7
data/Gemfile
CHANGED
data/lib/progress_bar/version.rb
CHANGED
data/lib/progress_bar.rb
CHANGED
@@ -68,6 +68,7 @@ class ProgressBar
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def to_s
|
71
|
+
self.count = max if count > max
|
71
72
|
meters.inject("") do |text, meter|
|
72
73
|
text << render(meter) + " "
|
73
74
|
end.strip
|
@@ -92,6 +93,7 @@ class ProgressBar
|
|
92
93
|
end
|
93
94
|
|
94
95
|
def render_bar
|
96
|
+
return '' if bar_width < 2
|
95
97
|
"[" +
|
96
98
|
"#" * (ratio * (bar_width - 2)).ceil +
|
97
99
|
" " * ((1-ratio) * (bar_width - 2)).floor +
|
@@ -120,7 +122,17 @@ class ProgressBar
|
|
120
122
|
end
|
121
123
|
|
122
124
|
def terminal_width
|
123
|
-
|
125
|
+
# HighLine check takes a long time, so only update width every second.
|
126
|
+
if @last_width_adjustment.nil? || Time.now - @last_width_adjustment > 1
|
127
|
+
@last_width_adjustment = Time.now
|
128
|
+
@terminal_width = @hl.output_cols.to_i
|
129
|
+
if @terminal_width < 1
|
130
|
+
@terminal_width = 80
|
131
|
+
end
|
132
|
+
@terminal_width
|
133
|
+
else
|
134
|
+
@terminal_width
|
135
|
+
end
|
124
136
|
end
|
125
137
|
|
126
138
|
def bar_width
|
data/test/progress_bar_test.rb
CHANGED
@@ -34,6 +34,14 @@ describe 'ProgressBar bar output' do
|
|
34
34
|
it { should == "[##############] [100/100] [100%] [00:10] [00:00] [ 10.00/s]" }
|
35
35
|
end
|
36
36
|
|
37
|
+
describe 'at count=105' do
|
38
|
+
before do
|
39
|
+
@progress_bar.count = 105
|
40
|
+
end
|
41
|
+
|
42
|
+
it { should == "[##############] [100/100] [100%] [00:10] [00:00] [ 10.00/s]" }
|
43
|
+
end
|
44
|
+
|
37
45
|
end
|
38
46
|
|
39
47
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: progress_bar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-03-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: options
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: 2.3.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.3.0
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: highline
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ~>
|
@@ -32,7 +37,12 @@ dependencies:
|
|
32
37
|
version: 1.6.1
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.6.1
|
36
46
|
description: ! 'Give people feedback about long-running tasks without overloading
|
37
47
|
them with information: Use a progress bar, like Curl or Wget!'
|
38
48
|
email:
|
@@ -76,6 +86,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
76
86
|
- - ! '>='
|
77
87
|
- !ruby/object:Gem::Version
|
78
88
|
version: '0'
|
89
|
+
segments:
|
90
|
+
- 0
|
91
|
+
hash: -672631073319406219
|
79
92
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
93
|
none: false
|
81
94
|
requirements:
|
@@ -84,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
97
|
version: '0'
|
85
98
|
requirements: []
|
86
99
|
rubyforge_project: progress_bar
|
87
|
-
rubygems_version: 1.8.
|
100
|
+
rubygems_version: 1.8.24
|
88
101
|
signing_key:
|
89
102
|
specification_version: 3
|
90
103
|
summary: Simple Progress Bar for output to a terminal
|