progress 0.0.9.0 → 0.0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/lib/progress.rb +41 -8
- data/progress.gemspec +3 -3
- metadata +3 -3
data/VERSION.yml
CHANGED
@@ -1 +1 @@
|
|
1
|
-
[0, 0, 9,
|
1
|
+
[0, 0, 9, 1]
|
data/lib/progress.rb
CHANGED
@@ -28,9 +28,9 @@ class Progress
|
|
28
28
|
# end
|
29
29
|
# end
|
30
30
|
# ==== To output progress as lines (not trying to stay on line)
|
31
|
-
# Progress.
|
32
|
-
#
|
33
|
-
#
|
31
|
+
# Progress.lines = true
|
32
|
+
# ==== To force highlight
|
33
|
+
# Progress.highlight = true
|
34
34
|
def self.start(title, total = 1, options = {})
|
35
35
|
levels << new(title, total, levels.length, options)
|
36
36
|
print_message
|
@@ -86,21 +86,54 @@ protected
|
|
86
86
|
@io.puts if levels.empty?
|
87
87
|
end
|
88
88
|
|
89
|
+
def io
|
90
|
+
@io ||= $stderr
|
91
|
+
end
|
92
|
+
|
89
93
|
def io=(io)
|
90
94
|
@io = io
|
91
95
|
end
|
92
96
|
|
97
|
+
def lines=(value)
|
98
|
+
@lines = !!value
|
99
|
+
end
|
100
|
+
def lines?
|
101
|
+
if @lines.nil?
|
102
|
+
@lines = !io.tty?
|
103
|
+
end
|
104
|
+
@lines
|
105
|
+
end
|
106
|
+
|
107
|
+
def highlight=(value)
|
108
|
+
@highlight = !!value
|
109
|
+
end
|
110
|
+
def highlight?
|
111
|
+
if @highlight.nil?
|
112
|
+
@highlight = !!io.tty?
|
113
|
+
end
|
114
|
+
@highlight
|
115
|
+
end
|
116
|
+
|
93
117
|
protected
|
94
118
|
|
95
119
|
def print_message
|
96
120
|
message = levels.map{ |level| level.message } * ' > '
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
121
|
+
io.sync = true
|
122
|
+
|
123
|
+
unless lines?
|
124
|
+
previous_length = @previous_length || 0
|
101
125
|
@previous_length = message.length
|
126
|
+
message = message.ljust(previous_length, '>') + "\r"
|
127
|
+
end
|
128
|
+
|
129
|
+
if highlight?
|
130
|
+
message.gsub!(/\d+\.\d+/){ |s| s == '100.0' ? s : "\e[1m#{s}\e[0m" }
|
131
|
+
end
|
132
|
+
|
133
|
+
unless lines?
|
134
|
+
io.print message
|
102
135
|
else
|
103
|
-
|
136
|
+
io.puts message
|
104
137
|
end
|
105
138
|
end
|
106
139
|
|
data/progress.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{progress}
|
5
|
-
s.version = "0.0.9.
|
5
|
+
s.version = "0.0.9.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["toy"]
|
9
|
-
s.date = %q{2009-07-
|
9
|
+
s.date = %q{2009-07-28}
|
10
10
|
s.description = %q{A library to show progress of long running tasks.}
|
11
11
|
s.email = %q{}
|
12
12
|
s.extra_rdoc_files = ["CHANGELOG", "lib/progress/enumerable.rb", "lib/progress/integer.rb", "lib/progress/with_progress.rb", "lib/progress.rb", "README.rdoc", "tasks/rspec.rake"]
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Progress", "--main", "README.rdoc"]
|
16
16
|
s.require_paths = ["lib"]
|
17
17
|
s.rubyforge_project = %q{progress}
|
18
|
-
s.rubygems_version = %q{1.3.
|
18
|
+
s.rubygems_version = %q{1.3.5}
|
19
19
|
s.summary = %q{A library to show progress of long running tasks.}
|
20
20
|
|
21
21
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: progress
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.9.
|
4
|
+
version: 0.0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- toy
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-07-
|
12
|
+
date: 2009-07-28 00:00:00 +04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -71,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
71
|
requirements: []
|
72
72
|
|
73
73
|
rubyforge_project: progress
|
74
|
-
rubygems_version: 1.3.
|
74
|
+
rubygems_version: 1.3.5
|
75
75
|
signing_key:
|
76
76
|
specification_version: 3
|
77
77
|
summary: A library to show progress of long running tasks.
|