progress 0.1.1.1 → 0.1.1.2
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 +8 -7
- data/progress.gemspec +1 -1
- data/spec/progress_spec.rb +0 -6
- metadata +1 -1
data/VERSION.yml
CHANGED
@@ -1 +1 @@
|
|
1
|
-
[0, 1, 1,
|
1
|
+
[0, 1, 1, 2]
|
data/lib/progress.rb
CHANGED
@@ -131,25 +131,26 @@ class Progress
|
|
131
131
|
|
132
132
|
def print_message
|
133
133
|
messages = []
|
134
|
-
messages_hl = []
|
135
134
|
inner = 0
|
136
135
|
levels.reverse.each do |l|
|
137
136
|
current = l.to_f(inner)
|
138
137
|
value = current == 0 ? '......' : '%5.1f%%' % (current * 100.0)
|
139
|
-
messages << "#{l.title}: #{value}"
|
140
|
-
messages_hl << "#{l.title}: #{value == '100.0' ? value : "\e[1m#{value}\e[0m"}" if highlight?
|
138
|
+
messages << "#{l.title}: #{!highlight? || value == '100.0%' ? value : "\e[1m#{value}\e[0m"}"
|
141
139
|
inner = current
|
142
140
|
end
|
143
141
|
message = messages.reverse * ' > '
|
144
142
|
|
145
143
|
unless lines?
|
146
144
|
previous_length = @previous_length || 0
|
147
|
-
|
148
|
-
|
145
|
+
message_cl = if highlight?
|
146
|
+
message.gsub(/\033\[(0|1)m/, '')
|
147
|
+
else
|
148
|
+
message
|
149
|
+
end
|
150
|
+
@previous_length = message_cl.length
|
151
|
+
message = "#{message}#{' ' * [previous_length - message_cl.length, 0].max}]\r"
|
149
152
|
end
|
150
153
|
|
151
|
-
message = messages_hl.reverse * ' > ' if highlight?
|
152
|
-
|
153
154
|
lines? ? io.puts(message) : io.print(message)
|
154
155
|
end
|
155
156
|
end
|
data/progress.gemspec
CHANGED
data/spec/progress_spec.rb
CHANGED