tty-progressbar 0.11.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -0
  3. data/README.md +302 -57
  4. data/examples/failure.rb +14 -0
  5. data/examples/iterator.rb +7 -0
  6. data/examples/multi/main_bar.rb +17 -0
  7. data/examples/multi/simple.rb +15 -0
  8. data/examples/threaded.rb +16 -0
  9. data/lib/tty-progressbar.rb +3 -2
  10. data/lib/tty/progressbar.rb +221 -58
  11. data/lib/tty/progressbar/configuration.rb +4 -0
  12. data/lib/tty/progressbar/converter.rb +2 -1
  13. data/lib/tty/progressbar/formatter.rb +2 -1
  14. data/lib/tty/progressbar/formatter/bar.rb +3 -1
  15. data/lib/tty/progressbar/formatter/byte_rate.rb +2 -1
  16. data/lib/tty/progressbar/formatter/current.rb +2 -1
  17. data/lib/tty/progressbar/formatter/current_byte.rb +2 -1
  18. data/lib/tty/progressbar/formatter/elapsed.rb +2 -1
  19. data/lib/tty/progressbar/formatter/estimated.rb +2 -1
  20. data/lib/tty/progressbar/formatter/mean_byte.rb +2 -1
  21. data/lib/tty/progressbar/formatter/mean_rate.rb +2 -1
  22. data/lib/tty/progressbar/formatter/percent.rb +2 -1
  23. data/lib/tty/progressbar/formatter/rate.rb +2 -1
  24. data/lib/tty/progressbar/formatter/total.rb +2 -1
  25. data/lib/tty/progressbar/formatter/total_byte.rb +2 -1
  26. data/lib/tty/progressbar/meter.rb +2 -1
  27. data/lib/tty/progressbar/multi.rb +221 -0
  28. data/lib/tty/progressbar/version.rb +1 -1
  29. data/spec/unit/events_spec.rb +35 -0
  30. data/spec/unit/formatter/elapsed_spec.rb +0 -1
  31. data/spec/unit/head_spec.rb +34 -0
  32. data/spec/unit/inspect_spec.rb +1 -1
  33. data/spec/unit/iterate_spec.rb +48 -0
  34. data/spec/unit/multi/advance_spec.rb +139 -0
  35. data/spec/unit/multi/events_spec.rb +64 -0
  36. data/spec/unit/multi/finish_spec.rb +19 -0
  37. data/spec/unit/multi/line_inset_spec.rb +67 -0
  38. data/spec/unit/multi/register_spec.rb +36 -0
  39. data/spec/unit/multi/stop_spec.rb +17 -0
  40. data/spec/unit/new_spec.rb +6 -0
  41. data/spec/unit/reset_spec.rb +0 -2
  42. data/spec/unit/stop_spec.rb +21 -0
  43. data/spec/unit/update_spec.rb +24 -0
  44. data/tty-progressbar.gemspec +1 -0
  45. metadata +44 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2eaaf2c7343d9acdfb829ee31ce58673a0e57874
4
- data.tar.gz: 6b7b3f3e8ccef0d0ce4eadb728404b11113330b3
3
+ metadata.gz: 11bc77d708ba9f54e6efc5870c1865ce8937a0fc
4
+ data.tar.gz: 64d970dec5a9324a5639c5713ab922447afbb1b8
5
5
  SHA512:
6
- metadata.gz: c51b18a4f26219bf19628fd1c406e2cfd94d6857fb236c304a535a68723828b21e86f851d8ef524453c77761cada81e1804162d5278f06149921b31c66964ffe
7
- data.tar.gz: b6b3f6800919a9b5dbc31edf85b35c23da38760c3dd580aa611febd0870fa42424bfcb7e44b61dbdd7a14d02d08f05ccd915fb1e5a4e1399b3840e33897c1c1d
6
+ metadata.gz: 01ac6ab2668fea2bec216aa095e226e1c08ef388e442ddbe9a72c9772cf19f749a93e54085a5fac9488fc65c5c363e9f4500f2c4f4d01194abc571885ae47ac2
7
+ data.tar.gz: 81c443f7bf90e2f14a4ae9cd44e8fb5ea180598cae273000e4b5b335b0302cb911dbf84c440f5559bb5e8b8cd890e12378a32d8a5280a499f51e40b2edc3deab
@@ -1,5 +1,24 @@
1
1
  # Change log
2
2
 
3
+ ## [v0.12.0] - 2017-09-03
4
+
5
+ ### Added
6
+ * Add :head option to allow changing bar head progression character
7
+ * Add thread safety to allow sharing progress between multiple threads
8
+ * Add #update to allow changing bar configuration options
9
+ * Add #stop to stop bar in current position and terminate any further progress
10
+ * Add #iterate to progress over a collection
11
+ * Add validation to check if bar formatting string is provided
12
+ * Add ability to listen for completion events such as :done, :progress and :stopped
13
+ * Add TTY::ProgressBar::Multi for creating parallel multiple progress bars
14
+
15
+ ### Changed
16
+ * Change to stop mutating strings
17
+ * Change #reset to stop drawing and use for initialization
18
+
19
+ ### Fixed
20
+ * Fix configuration to add interval option
21
+
3
22
  ## [v0.11.0] - 2017-04-04
4
23
 
5
24
  ### Added
@@ -108,6 +127,7 @@
108
127
 
109
128
  * Initial implementation and release
110
129
 
130
+ [v0.12.0]: https://github.com/peter-murach/tty-progressbar/compare/v0.11.0...v0.12.0
111
131
  [v0.11.0]: https://github.com/peter-murach/tty-progressbar/compare/v0.10.1...v0.11.0
112
132
  [v0.10.1]: https://github.com/peter-murach/tty-progressbar/compare/v0.10.0...v0.10.1
113
133
  [v0.10.0]: https://github.com/peter-murach/tty-progressbar/compare/v0.9.0...v0.10.0
data/README.md CHANGED
@@ -20,9 +20,11 @@
20
20
 
21
21
  ## Features
22
22
 
23
- * Fully [configurable](#2-configuration)
24
- * Extremly flexible progress display [formatting](#3-formatting)
25
- * Ability to define your custom format [tokens](#31-tokens)
23
+ * Fully [configurable](#3-configuration)
24
+ * Extremely flexible progress display [formatting](#4-formatting)
25
+ * Includes many predefined tokens to calculate ETA, Bytes ... [tokens](#41-tokens)
26
+ * Allows to define your [custom tokens](#42-custom-formatters)
27
+ * Supports parallel multi progress bars [multi](#6-ttyprogressbarmulti-api)
26
28
  * Works on all ECMA-48 compatible terminals
27
29
 
28
30
  ## Installation
@@ -44,25 +46,42 @@ Or install it yourself as:
44
46
  ## Contents
45
47
 
46
48
  * [1. Usage](#1-usage)
47
- * [1.1 advance](#11-advance)
48
- * [1.2 current=](#12-current)
49
- * [1.3 ratio=](#13-ratio)
50
- * [1.4 width=](#14-width)
51
- * [1.5 start](#15-start)
52
- * [1.6 finish](#16-finish)
53
- * [1.7 complete?](#17-complete)
54
- * [1.8 reset](#18-reset)
55
- * [1.9 resize](#19-resize)
56
- * [2. Configuration](#2-configuration)
57
- * [2.1 Frequency](#21-frequency)
58
- * [2.2 Interval](#22-interval)
59
- * [3. Formatting](#3-formatting)
60
- * [3.1 Tokens](#31-tokens)
61
- * [3.2 Custom Formatters](#32-custom-formatters)
62
- * [3.3 Custom Tokens](#33-custom-tokens)
63
- * [4. Logging](#4-logging)
64
- * [5. Examples](#5-examples)
65
- * [5.1 Color](#51-color)
49
+ * [2. TTY::ProgressBar::API](#2-ttyprogressbar-api)
50
+ * [2.1 advance](#21-advance)
51
+ * [2.2 iterate](#22-iterate)
52
+ * [2.3 current=](#23-current)
53
+ * [2.4 ratio=](#24-ratio)
54
+ * [2.5 width=](#25-width)
55
+ * [2.6 start](#26-start)
56
+ * [2.7 update](#27-update)
57
+ * [2.8 finish](#28-finish)
58
+ * [2.9 stop](#29-stop)
59
+ * [2.10 reset](#210-reset)
60
+ * [2.11 complete?](#211-complete)
61
+ * [2.12 resize](#212-resize)
62
+ * [2.13 on](#213-on)
63
+ * [3. Configuration](#3-configuration)
64
+ * [3.1 :head](#31-head)
65
+ * [3.2 :frequency](#32-interval)
66
+ * [3.3 :interval](#33-interval)
67
+ * [4. Formatting](#4-formatting)
68
+ * [4.1 Tokens](#41-tokens)
69
+ * [4.2 Custom Formatters](#42-custom-formatters)
70
+ * [4.3 Custom Tokens](#43-custom-tokens)
71
+ * [5. Logging](#5-logging)
72
+ * [6. TTY::ProgressBar::Multi API](#6-ttyprogressbarmulti-api)
73
+ * [6.1 new](#61-new)
74
+ * [6.2 register](#62-register)
75
+ * [6.3 advance](#63-advance)
76
+ * [6.4 start](#64-start)
77
+ * [6.5 finish](#65-finish)
78
+ * [6.6 stop](#66-stop)
79
+ * [6.7 complete?](#67-complete)
80
+ * [6.8 on](#68-on)
81
+ * [6.9 :style](#69-style)
82
+ * [7. Examples](#7-examples)
83
+ * [7.1 Color](#71-color)
84
+ * [7.2 Speed](#72-speed)
66
85
 
67
86
  ## 1. Usage
68
87
 
@@ -79,10 +98,36 @@ end
79
98
  This would produce animation in your terminal:
80
99
 
81
100
  ```ruby
82
- downloading [======================= ]
101
+ # downloading [======================= ]
83
102
  ```
84
103
 
85
- ### 1.1 advance
104
+ Use **TTY::ProgressBar::Multi** to display multiple parallel progress bars:
105
+
106
+ ```ruby
107
+ bars = TTY::ProgressBar::Multi.new("main [:bar] :percent")
108
+
109
+ bar1 = bars.register("one [:bar] :percent", total: 15)
110
+ bar2 = bars.register("two [:bar] :percent", total: 15)
111
+
112
+ bars.start
113
+
114
+ th1 = Thread.new { 15.times { sleep(0.1); bar1.advance } }
115
+ th2 = Thread.new { 15.times { sleep(0.1); bar2.advance } }
116
+
117
+ [th1, th2].each { |t| t.join }
118
+ ```
119
+
120
+ which will produce:
121
+
122
+ ```ruby
123
+ # ┌ main [=============== ] 50%
124
+ # ├── one [===== ] 34%
125
+ # └── two [========== ] 67%
126
+ ```
127
+
128
+ ## 2. TTY::ProgressBar API
129
+
130
+ ### 2.1 advance
86
131
 
87
132
  Once you have **TTY::ProgressBar** instance, you can progress the display by calling `advance` method. By default it will increase by `1` but you can pass any number of steps, for instance, when used to advance number of bytes of downloaded file.
88
133
 
@@ -98,7 +143,36 @@ bar.advance(-1)
98
143
 
99
144
  Note: If a progress bar has already finished then negative steps will not set it back to desired value.
100
145
 
101
- ### 1.2 current=
146
+ ### 2.2 iterate
147
+
148
+ To simplify progressing over an enumerable you can use `iterate` which as a first argument accepts an `Enumerable` and as a second the amount to progress the bar with.
149
+
150
+ First, create a progress bar without a total which will be dynamically handled for you:
151
+
152
+ ```ruby
153
+ bar = TTY::ProgressBar.new
154
+ ```
155
+
156
+ Then, either directly iterate over a collection by yielding values to a block:
157
+
158
+ ```ruby
159
+ bar.iterate(30.times) { |v| ... }
160
+ ```
161
+
162
+ or return an 'Enumerator':
163
+
164
+ ```ruby
165
+ progress = bar.iterate(30.times)
166
+ # => #<Enumerator: #<Enumerator::Generator:0x...:each>
167
+ ```
168
+
169
+ By default, progress bar is advanced by `1` but you can change it by passing second argument:
170
+
171
+ ```ruby
172
+ bar.iterate(30.times, 5)
173
+ ```
174
+
175
+ ### 2.3 current=
102
176
 
103
177
  **TTY::ProgressBar** allows you to set progress to a given value by calling `current=` method.
104
178
 
@@ -108,7 +182,7 @@ bar.current = 50
108
182
 
109
183
  Note: If a progress bar has already finished then negative steps will not set it back to desired value.
110
184
 
111
- ### 1.3 ratio=
185
+ ### 2.4 ratio=
112
186
 
113
187
  In order to update overall completion of a progress bar as an exact percentage use the `ratio=` method. The method accepts values between `0` and `1` inclusive. For example, a ratio of 0.5 will attempt to set the progress bar halfway:
114
188
 
@@ -116,7 +190,7 @@ In order to update overall completion of a progress bar as an exact percentage u
116
190
  bar.ratio = 0.5
117
191
  ```
118
192
 
119
- ### 1.4 width=
193
+ ### 2.5 width=
120
194
 
121
195
  You can set how many terminal columns will the `:bar` actually span excluding any other tokens and/or text. For example if you need the bar to be always 20 columns wwide do:
122
196
 
@@ -130,7 +204,7 @@ or with configuration options:
130
204
  bar = TTY::ProgressBar.new("[:bar]", width: 20)
131
205
  ```
132
206
 
133
- ### 1.5 start
207
+ ### 2.6 start
134
208
 
135
209
  By default the timer for internal time esitamation is started automatically when the `advance` method is called. However, if you require control on when the progression timer is started use `start` call:
136
210
 
@@ -138,7 +212,15 @@ By default the timer for internal time esitamation is started automatically when
138
212
  bar.start # => sets timer and draws initial progress bar
139
213
  ```
140
214
 
141
- ### 1.6 finish
215
+ ### 2.7 update
216
+
217
+ Once the progress bar has been started you can change its configuration option(s) by calling `update`:
218
+
219
+ ```ruby
220
+ bar.update(complete: '+', frequency: 10)
221
+ ```
222
+
223
+ ### 2.8 finish
142
224
 
143
225
  In order to immediately stop and finish the progress call `finish`. This will finish drawing the progress and return to new line.
144
226
 
@@ -146,15 +228,15 @@ In order to immediately stop and finish the progress call `finish`. This will fi
146
228
  bar.finish
147
229
  ```
148
230
 
149
- ### 1.7 complete?
231
+ ### 2.9 stop
150
232
 
151
- During progresion you can check if bar is finished or not by calling `complete?`.
233
+ In order to immediately stop the bar in the current position and thus finish any further progress use `stop`:
152
234
 
153
235
  ```ruby
154
- bar.complete? # => false
236
+ bar.stop
155
237
  ```
156
238
 
157
- ### 1.8 reset
239
+ ### 2.10 reset
158
240
 
159
241
  In order to reset currently running or finished progress bar to its original configuration and initial position use `reset` like so:
160
242
 
@@ -162,7 +244,17 @@ In order to reset currently running or finished progress bar to its original con
162
244
  bar.reset
163
245
  ```
164
246
 
165
- ### 1.9 resize
247
+ After resetting the bar if you wish to draw and start the bar and its timers use `start` call.
248
+
249
+ ### 2.11 complete?
250
+
251
+ During progresion you can check if a bar is finished or not by calling `complete?`. The bar will only return `true` if the progression finished successfuly, otherwise `false` will be returned.
252
+
253
+ ```ruby
254
+ bar.complete? # => false
255
+ ```
256
+
257
+ ### 2.12 resize
166
258
 
167
259
  If you wish for a progress bar to change it's current width, you can use `resize` by passing in a new desired length. However, if you don't provide any width the `resize` will use terminal current width as its base for scaling.
168
260
 
@@ -177,19 +269,42 @@ To handle automatic resizing you can trap `:WINCH` signal:
177
269
  trap(:WINCH) { bar.resize }
178
270
  ```
179
271
 
180
- ## 2. Configuration
272
+ ### 2.13 on
273
+
274
+ The progress bar fires events when it is progressing, stopped or finished. You can register to listen for events using the `on` message.
275
+
276
+ Every time an `advance` is called the `:progress` event gets fired which you can listen for:
277
+
278
+ ```ruby
279
+ bar.on(:progress) { ... }
280
+ ```
281
+
282
+ When the progress bar finishes and completes then the `:done` event is fired. You can listen for this event:
283
+
284
+ ```ruby
285
+ bar.on(:done) { ... }
286
+ ```
287
+
288
+ Alternatively, when the progress bar gets stopped the `:stopped` event is fired. You can listen for this event:
289
+
290
+ ```ruby
291
+ bar.on(:stopped) { ... }
292
+ ```
293
+
294
+ ## 3. Configuration
181
295
 
182
296
  There are number of configuration options that can be provided:
183
297
 
184
- * `total` total number of steps to completion
185
- * `width` of the bars display in terminal columns excluding formatting options. Defaults to total steps
186
- * `complete` completion character by default `=`
187
- * `incomplete` incomplete character by default single space
188
- * `output` the output stream defaulting to `stderr`
189
- * `frequency` used to throttle the output, by default `0` (see [Frequency](#21-frequency))
190
- * `interval` used to measure the speed, by default `1 sec` (see [Interval](#22-interval))
191
- * `hide_cursor` to hide display cursor defaulting to `false`
192
- * `clear` to clear the finished bar defaulting to `false`
298
+ * `:total` total number of steps to completion
299
+ * `:width` of the bars display in terminal columns excluding formatting options. Defaults to total steps
300
+ * `:complete` completion character by default `=`
301
+ * `:incomplete` incomplete character by default single space
302
+ * [:head](#21-head) the head character by default `=`
303
+ * `:output` the output stream defaulting to `stderr`
304
+ * [:frequency](#22-frequency) used to throttle the output, by default `0`
305
+ * [:interval](#23-interval) used to measure the speed, by default `1 sec`
306
+ * `:hide_cursor` to hide display cursor defaulting to `false`
307
+ * `:clear` to clear the finished bar defaulting to `false`
193
308
 
194
309
  All the above options can be passed in as hash options or block parameters:
195
310
 
@@ -201,7 +316,17 @@ TTY::ProgressBar.new "[:bar]" do |config|
201
316
  end
202
317
  ```
203
318
 
204
- ### 2.1 Frequency
319
+ ### 3.1 :head
320
+
321
+ If you prefer for the animated bar to display a specific character for a head of progression then use `:head` option:
322
+
323
+ ```ruby
324
+ bar = TTY::ProressBar.new("[:bar]", head: '>')
325
+ #
326
+ # [=======> ]
327
+ ```
328
+
329
+ ### 3.2 :frequency
205
330
 
206
331
  Each time the `advance` is called it causes the progress bar to repaint. In cases when there is a huge number of updates per second, you may need to limit the rendering process by using the `frequency` option.
207
332
 
@@ -211,7 +336,7 @@ The `frequency` option accepts `integer` representing number of `Hz` units, for
211
336
  TTY::ProgressBar.new("[:bar]", total: 30, frequency: 10) # 10 Hz
212
337
  ```
213
338
 
214
- ### 2.2 Interval
339
+ ### 3.3 :interval
215
340
 
216
341
  For every call of `advance` method the **ProgressBar** takes a sample for speed measurement. By default the samples are grouped per second but you can change that by passing the `interval` option.
217
342
 
@@ -223,7 +348,7 @@ TTY::ProgressBar.new(":rate/minute", total: 100, interval: 60) # 1 minute
223
348
  TTY::ProgressBar.new(":rate/hour", total: 100, interval: 3600) # 1 hour
224
349
  ```
225
350
 
226
- ## 3. Formatting
351
+ ## 4. Formatting
227
352
 
228
353
  Every **TTY::ProgressBar** instance requires a format string, which apart from regular characters accepts special tokens to display dynamic information. For instance, a format to measure download progress could be:
229
354
 
@@ -231,7 +356,7 @@ Every **TTY::ProgressBar** instance requires a format string, which apart from r
231
356
  "downloading [:bar] :elapsed :percent"
232
357
  ```
233
358
 
234
- ### 3.1 Tokens
359
+ ### 4.1 Tokens
235
360
 
236
361
  These are the tokens that are currently supported:
237
362
 
@@ -248,7 +373,7 @@ These are the tokens that are currently supported:
248
373
  * `:mean_rate` the averaged rate of progression per second
249
374
  * `:mean_byte` the averaged rate of progression in bytes per second
250
375
 
251
- ### 3.2 Custom Formatters
376
+ ### 4.2 Custom Formatters
252
377
 
253
378
  If the provided tokens do not meet your needs, you can write your own formatter and instrument formatting pipeline to use a formatter you prefer. This option is preferred if you are going to rely on progress bar internal data such as `rate`, `current` etc. which will all be available on the passed in progress bar instance.
254
379
 
@@ -291,7 +416,7 @@ and then invoke progression:
291
416
  bar.advance
292
417
  ```
293
418
 
294
- ### 3.3 Custom Tokens
419
+ ### 4.3 Custom Tokens
295
420
 
296
421
  You can define custom tokens by passing pairs `name: value` to `advance` method in order to dynamically update formatted bar. This option is useful for lightweight content replacement such as titles that doesn't depend on the internal data of progressbar. For example:
297
422
 
@@ -308,7 +433,7 @@ which outputs:
308
433
  (4) Bye Piotr!
309
434
  ```
310
435
 
311
- ## 4. Logging
436
+ ## 5. Logging
312
437
 
313
438
  If you want to print messages out to terminal along with the progress bar use the `log` method. The messages will appear above the progress bar and will continue scrolling up as more are logged out.
314
439
 
@@ -320,15 +445,135 @@ bar.advance
320
445
  will result in:
321
446
 
322
447
  ```ruby
323
- Piotrrrrr
324
- downloading [======================= ]
448
+ # Piotrrrrr
449
+ # downloading [======================= ]
450
+ ```
451
+
452
+ ## 6. TTY::ProgressBar::Multi API
453
+
454
+ ### 6.1 new
455
+
456
+ The multi progress bar can be created in two ways. If you simply want to group multiple progress bars you can create multi bar like so:
457
+
458
+ ```ruby
459
+ TTY::ProgressBar::Multi.new
460
+ ```
461
+
462
+
463
+ However, if you want a top level multibar that tracks all the registered progress bars then provide a formatted string:
464
+
465
+ ```ruby
466
+ TTY::ProgressBar::Multi.new("main [:bar] :percent")
467
+ ```
468
+
469
+ ### 6.2 register
470
+
471
+ To create a `TTY::ProgressBar` under the multibar use `register` like so:
472
+
473
+ ```ruby
474
+ multibar = TTY::ProgressBar::Multi.new
475
+ bar = multibar.register("[:bar]", total: 30)
476
+ ```
477
+
478
+ The `register` call returns the newly created progress bar which answers all the progress bar api messages.
479
+
480
+ Please remember to specify total value for each registered progress bar, either when sending `register` message or when using `update` to dynamicaly assign the total value.
481
+
482
+ ### 6.3 advance
483
+
484
+ Once multi progress bar has been created you can advance each registered progress bar individually, either by executing them one after the other synchronously or by placing them in separate threads thus progressing each bar asynchronously. The multi bar handles synchronization and display of all bars as they continue their respective rendering.
485
+
486
+ For example, to display two bars async, first register them with the multi bar:
487
+
488
+ ```ruby
489
+ bar1 = multibar.register("one [:bar]", total: 20)
490
+ bar2 = multibar.register("two [:bar]", total: 30)
491
+ ```
492
+
493
+ Next place the progress behaviour in separate process or thread:
494
+
495
+ ```ruby
496
+ th1 = Thread.new { 20.times { expensive_work(); bar1.advance } }
497
+ th2 = Thread.new { 30.times { expensive_work(); bar2.advance } }
498
+ ```
499
+
500
+ Finally, wait for the threads to finish:
501
+
502
+ ```ruby
503
+ [th1, th2].each { |t| t.join }
504
+ ```
505
+
506
+ ### 6.4 start
507
+
508
+ If you want your top level multi bar to be rendered as the first bar in the terminal before any registered bars call `start`:
509
+
510
+ ```ruby
511
+ multibar.start
512
+ ```
513
+
514
+ ### 6.5 finish
515
+
516
+ In order to finish all progress bars call `finish`. This will finish the top level progress bar, if it exists, all any registered progress bars still in progress.
517
+
518
+ ```ruby
519
+ multibar.finish
520
+ ```
521
+
522
+ ### 6.6 stop
523
+
524
+ Use `stop` to terminate immediately all progress bars registered with the multibar.
525
+
526
+ ```ruby
527
+ multibar.stop
528
+ ```
529
+
530
+ ### 6.7 complete?
531
+
532
+ To check if all registered progress bars have been successfully finished use `complete?`
533
+
534
+ ```ruby
535
+ multibar.complete? # => true
536
+ ```
537
+
538
+ ### 6.8 on
539
+
540
+ Similar to `TTY::ProgressBar` the multi bar fires events when it is progressing, stopped or finished. You can register to listen for events using the `on` message.
541
+
542
+ Every time any of the registered progress bars progresses the `:progress` event is fired which you can listen for:
543
+
544
+ ```ruby
545
+ multibar.on(:progress) { ... }
546
+ ```
547
+
548
+ When all the registered progress bars finish and complete then the `:done` event is fired. You can listen for this event:
549
+
550
+ ```ruby
551
+ multibar.on(:done) { ... }
552
+ ```
553
+
554
+ Finally, when any of the progress bars gets stopped the `:stopped` event is fired. You can listen for this event:
555
+
556
+ ```ruby
557
+ multibar.on(:stopped) { ... }
558
+ ```
559
+
560
+ ### 6.9 :style
561
+
562
+ In addition to all [configuration options](#3-configuration) you can style multi progress bar:
563
+
564
+ ```ruby
565
+ TTY::ProgressBar::Multi.new("[:bar]", style: {
566
+ top: '. '
567
+ middle: '|-> '
568
+ bottom: '|__ '
569
+ })
325
570
  ```
326
571
 
327
- ## 5. Examples
572
+ ## 7. Examples
328
573
 
329
574
  This section demonstrates some of the possible uses for the **TTY::ProgressBar**, for more please see examples folder in the source directory.
330
575
 
331
- ### 5.1 Colors
576
+ ### 7.1 Colors
332
577
 
333
578
  Creating a progress bar that displays in color is as simple as coloring the `:complete` and `:incomplete` character options. In order to help with coloring you can use [pastel](https://github.com/piotrmurach/pastel) library like so:
334
579
 
@@ -359,7 +604,7 @@ To see how a progress bar is reported in terminal you can do:
359
604
  end
360
605
  ```
361
606
 
362
- ### 5.2 Speed
607
+ ### 7.2 Speed
363
608
 
364
609
  Commonly a progress bar is utilized to measure download speed per second. This can be done like so:
365
610
 
@@ -373,7 +618,7 @@ end
373
618
  This will result in output similar to:
374
619
 
375
620
  ```ruby
376
- downloading [======================= ] 4.12MB/s
621
+ # downloading [======================= ] 4.12MB/s
377
622
  ```
378
623
 
379
624
  ## Contributing