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 CHANGED
@@ -1 +1 @@
1
- [0, 1, 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
- @previous_length = message.length
148
- message = message.ljust(previous_length, ' ') + "\r"
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{progress}
5
- s.version = "0.1.1.1"
5
+ s.version = "0.1.1.2"
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"]
@@ -1,11 +1,5 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- Progress.start('Test') do
4
- Progress.start('Test') do
5
- 'qwerty'
6
- end
7
- end
8
-
9
3
  describe Progress do
10
4
  before :each do
11
5
  @io = StringIO.new
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.1.1.1
4
+ version: 0.1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - toy