progressbar 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +8 -0
- data/lib/progressbar.rb +24 -18
- data/progressbar.gemspec +1 -1
- metadata +15 -15
- data/VERSION +0 -1
data/.travis.yml
ADDED
data/lib/progressbar.rb
CHANGED
@@ -29,13 +29,15 @@ class ProgressBar
|
|
29
29
|
clear
|
30
30
|
show
|
31
31
|
end
|
32
|
+
|
32
33
|
attr_reader :title
|
33
34
|
attr_reader :current
|
34
35
|
attr_reader :total
|
35
36
|
attr_accessor :start_time
|
36
37
|
attr_writer :bar_mark
|
37
38
|
|
38
|
-
|
39
|
+
private
|
40
|
+
|
39
41
|
def fmt_bar
|
40
42
|
bar_width = do_percentage * @terminal_width / 100
|
41
43
|
sprintf("|%s%s|",
|
@@ -120,21 +122,23 @@ class ProgressBar
|
|
120
122
|
end
|
121
123
|
end
|
122
124
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
default_width
|
134
|
-
end
|
135
|
-
rescue Exception
|
136
|
-
default_width
|
125
|
+
DEFAULT_WIDTH = 80
|
126
|
+
def get_term_width
|
127
|
+
if ENV['COLUMNS'] =~ /^\d+$/
|
128
|
+
ENV['COLUMNS'].to_i
|
129
|
+
elsif (RUBY_PLATFORM =~ /java/ || (!STDIN.tty? && ENV['TERM'])) && shell_command_exists?('tput')
|
130
|
+
`tput cols`.to_i
|
131
|
+
elsif STDIN.tty? && shell_command_exists?('stty')
|
132
|
+
`stty size`.scan(/\d+/).map { |s| s.to_i }[1]
|
133
|
+
else
|
134
|
+
DEFAULT_WIDTH
|
137
135
|
end
|
136
|
+
rescue
|
137
|
+
DEFAULT_WIDTH
|
138
|
+
end
|
139
|
+
|
140
|
+
def shell_command_exists?(command)
|
141
|
+
ENV['PATH'].split(File::PATH_SEPARATOR).any?{|d| File.exists? File.join(d, command) }
|
138
142
|
end
|
139
143
|
|
140
144
|
def show
|
@@ -144,7 +148,7 @@ class ProgressBar
|
|
144
148
|
}
|
145
149
|
line = sprintf(@format, *arguments)
|
146
150
|
|
147
|
-
width =
|
151
|
+
width = get_term_width
|
148
152
|
if line.length == width - 1
|
149
153
|
@out.print(line + eol)
|
150
154
|
@out.flush
|
@@ -174,10 +178,11 @@ class ProgressBar
|
|
174
178
|
end
|
175
179
|
end
|
176
180
|
|
177
|
-
|
181
|
+
public
|
182
|
+
|
178
183
|
def clear
|
179
184
|
@out.print "\r"
|
180
|
-
@out.print(" " * (
|
185
|
+
@out.print(" " * (get_term_width - 1))
|
181
186
|
@out.print "\r"
|
182
187
|
end
|
183
188
|
|
@@ -227,6 +232,7 @@ class ProgressBar
|
|
227
232
|
def inspect
|
228
233
|
"#<ProgressBar:#{@current}/#{@total}>"
|
229
234
|
end
|
235
|
+
|
230
236
|
end
|
231
237
|
|
232
238
|
class ReversedProgressBar < ProgressBar
|
data/progressbar.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: progressbar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,12 +10,12 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-11-22 00:00:00.000000000 -02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|
18
|
-
requirement: &
|
18
|
+
requirement: &70165027226020 !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
20
20
|
requirements:
|
21
21
|
- - ! '>='
|
@@ -23,10 +23,10 @@ dependencies:
|
|
23
23
|
version: 1.0.0
|
24
24
|
type: :development
|
25
25
|
prerelease: false
|
26
|
-
version_requirements: *
|
26
|
+
version_requirements: *70165027226020
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: minitest
|
29
|
-
requirement: &
|
29
|
+
requirement: &70165027225560 !ruby/object:Gem::Requirement
|
30
30
|
none: false
|
31
31
|
requirements:
|
32
32
|
- - ! '>='
|
@@ -34,10 +34,10 @@ dependencies:
|
|
34
34
|
version: '0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
|
-
version_requirements: *
|
37
|
+
version_requirements: *70165027225560
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
39
|
name: yard
|
40
|
-
requirement: &
|
40
|
+
requirement: &70165027225100 !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
43
|
- - ! '>='
|
@@ -45,10 +45,10 @@ dependencies:
|
|
45
45
|
version: '0'
|
46
46
|
type: :development
|
47
47
|
prerelease: false
|
48
|
-
version_requirements: *
|
48
|
+
version_requirements: *70165027225100
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
50
|
name: rake
|
51
|
-
requirement: &
|
51
|
+
requirement: &70165027256880 !ruby/object:Gem::Requirement
|
52
52
|
none: false
|
53
53
|
requirements:
|
54
54
|
- - ! '>='
|
@@ -56,10 +56,10 @@ dependencies:
|
|
56
56
|
version: '0'
|
57
57
|
type: :development
|
58
58
|
prerelease: false
|
59
|
-
version_requirements: *
|
59
|
+
version_requirements: *70165027256880
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: simplecov
|
62
|
-
requirement: &
|
62
|
+
requirement: &70165027256420 !ruby/object:Gem::Requirement
|
63
63
|
none: false
|
64
64
|
requirements:
|
65
65
|
- - ! '>='
|
@@ -67,10 +67,10 @@ dependencies:
|
|
67
67
|
version: 0.3.5
|
68
68
|
type: :development
|
69
69
|
prerelease: false
|
70
|
-
version_requirements: *
|
70
|
+
version_requirements: *70165027256420
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: bluecloth
|
73
|
-
requirement: &
|
73
|
+
requirement: &70165027255960 !ruby/object:Gem::Requirement
|
74
74
|
none: false
|
75
75
|
requirements:
|
76
76
|
- - ! '>='
|
@@ -78,7 +78,7 @@ dependencies:
|
|
78
78
|
version: 0.3.5
|
79
79
|
type: :development
|
80
80
|
prerelease: false
|
81
|
-
version_requirements: *
|
81
|
+
version_requirements: *70165027255960
|
82
82
|
description: Ruby/ProgressBar is a text progress bar library for Ruby. It can indicate
|
83
83
|
progress with percentage, a progress bar, and estimated remaining time.
|
84
84
|
email:
|
@@ -90,13 +90,13 @@ extra_rdoc_files: []
|
|
90
90
|
files:
|
91
91
|
- .gitignore
|
92
92
|
- .rvmrc
|
93
|
+
- .travis.yml
|
93
94
|
- ChangeLog
|
94
95
|
- Gemfile
|
95
96
|
- Gemfile.lock
|
96
97
|
- LICENSE
|
97
98
|
- README.rd
|
98
99
|
- Rakefile
|
99
|
-
- VERSION
|
100
100
|
- lib/progressbar.rb
|
101
101
|
- progressbar.gemspec
|
102
102
|
- test/test.rb
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.9.0
|