progress-monitor 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/progress-monitor.rb +9 -6
  2. metadata +2 -2
@@ -27,8 +27,8 @@ class Progress
27
27
  monitor_step = nil unless defined? monitor_step
28
28
 
29
29
  res = self.send(orig_name.to_sym) {|v|
30
- progress_meter.tick(monitor_step) if progress_meter
31
- puts announcement.call(v) if announcement
30
+ progress_meter.tick(monitor_step) if progress_meter
31
+ Progress.print_announcement(announcement.call(v)) if announcement
32
32
  block.call(v)
33
33
  }
34
34
 
@@ -57,7 +57,7 @@ class Progress
57
57
 
58
58
  res = self.send(orig_name.to_sym) {|v1,v2|
59
59
  progress_meter.tick(monitor_step) if progress_meter
60
- puts announcement.call(v1,v2) if announcement
60
+ Progress.print_announcement(announcement.call(v1,v2)) if announcement
61
61
  block.call(v1,v2);
62
62
  }
63
63
 
@@ -237,12 +237,15 @@ class Progress
237
237
  used = (Time.now - @time).to_i
238
238
  used = [used/3600, used/60 % 60, used % 60].map{|t| t.to_s.rjust(2, '0')}.join(':')
239
239
 
240
-
241
-
242
240
  indicator += " (Time left #{eta} seconds) (Started #{used} seconds ago)"
243
241
 
244
- $stderr.print("\033[#{@depth + 1}F\033[2K" + indicator + "\033[#{@depth + 1}E" )
242
+ $stderr.print("\033[#{@depth + 1}F\033[2K" + indicator + "\033[#{@depth + 1}E")
243
+ end
245
244
 
245
+ def self.print_announcement(message = nil)
246
+ return if message.nil?
247
+ total_depth = @@progress_meters.length + 1
248
+ $stderr.print("\033[#{total_depth}F\033[2K" + message + "\033[#{total_depth}E")
246
249
  end
247
250
  end
248
251
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: progress-monitor
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-03 00:00:00 +01:00
12
+ date: 2010-02-08 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15