multi_progress_bar 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,4 +2,4 @@
2
2
  :patch: 0
3
3
  :major: 0
4
4
  :build:
5
- :minor: 2
5
+ :minor: 3
@@ -16,7 +16,7 @@ begin
16
16
 
17
17
  machine_names = ["bleeker", "montrose"]
18
18
 
19
- until machine_bars.all? { |bar| bar.title != "(Waiting...)" && bar.current == bar.total }
19
+ until false #machine_bars.all? { |bar| bar.title != "(Waiting...)" && bar.current == bar.total }
20
20
  sleep(0.1)
21
21
 
22
22
  # Simulate machines becoming available.
@@ -29,7 +29,7 @@ begin
29
29
  end
30
30
  end
31
31
 
32
- MultiProgressBar.log(rand(2000))
32
+ # MultiProgressBar.log(rand(2000))
33
33
  end
34
34
  ensure
35
35
  MultiProgressBar.end
@@ -19,6 +19,18 @@ module MultiProgressBar
19
19
  @bars_window = Ncurses::WINDOW.new(1, 0, Ncurses.LINES-1, 0)
20
20
  @log_window = Ncurses::WINDOW.new(Ncurses.LINES-1, 0, 0, 0)
21
21
  @log_window.scrollok(true)
22
+
23
+ trap("SIGWINCH") do
24
+ Ncurses.endwin
25
+ Ncurses.refresh
26
+
27
+ refresh_window_positions
28
+
29
+ @bars.each do |bar|
30
+ bar.width = @bars_window.getmaxx
31
+ bar.show
32
+ end
33
+ end
22
34
  end
23
35
 
24
36
  # Restore the terminal to normal function. Always call this before exiting.
@@ -51,9 +63,7 @@ module MultiProgressBar
51
63
  @bars_window.getmaxx
52
64
  end
53
65
 
54
- def add_bar(bar) #:nodoc:
55
- @bars += [bar]
56
-
66
+ def refresh_window_positions
57
67
  @bars_window.mvwin(Ncurses.LINES-bars.size, @bars_window.getbegx)
58
68
  @bars_window.resize(bars.size, @bars_window.getmaxx)
59
69
  @bars_window.refresh
@@ -62,6 +72,11 @@ module MultiProgressBar
62
72
  @log_window.refresh
63
73
  end
64
74
 
75
+ def add_bar(bar) #:nodoc:
76
+ @bars += [bar]
77
+ refresh_window_positions
78
+ end
79
+
65
80
  def update_bar(bar, rendered_bar) #:nodoc:
66
81
  @bars_window.move(bars.index(bar), 0)
67
82
  @bars_window.attron(Ncurses.COLOR_PAIR(bar.color)) if bar.color
@@ -1,6 +1,7 @@
1
1
  module MultiProgressBar
2
2
  class BarRenderer < ProgressBar #:nodoc:
3
3
  attr_writer :total
4
+ attr_accessor :width
4
5
 
5
6
  def initialize(title, total, width, &block)
6
7
  @block = block
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multi_progress_bar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Jaros
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-20 00:00:00 -05:00
12
+ date: 2009-11-23 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency