planter-cli 3.0.1 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.gitmodules +3 -0
  4. data/CHANGELOG.md +10 -0
  5. data/README.md +5 -3
  6. data/bin/plant +1 -1
  7. data/docker/Dockerfile +2 -4
  8. data/docker/Dockerfile-2.6 +3 -5
  9. data/docker/Dockerfile-2.7 +2 -4
  10. data/docker/Dockerfile-3.0 +2 -3
  11. data/docker/Dockerfile-3.3 +11 -0
  12. data/docker/sources.list +11 -0
  13. data/lib/planter/filelist.rb +5 -4
  14. data/lib/planter/plant.rb +3 -3
  15. data/lib/planter/prompt.rb +5 -5
  16. data/lib/planter/string.rb +22 -0
  17. data/lib/planter/tag.rb +39 -2
  18. data/lib/planter/version.rb +1 -1
  19. data/lib/planter.rb +30 -17
  20. data/lib/tty-spinner/.editorconfig +9 -0
  21. data/lib/tty-spinner/.github/FUNDING.yml +1 -0
  22. data/lib/tty-spinner/.github/ISSUE_TEMPLATE/BUG_REPORT.md +31 -0
  23. data/lib/tty-spinner/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md +23 -0
  24. data/lib/tty-spinner/.github/ISSUE_TEMPLATE/config.yml +5 -0
  25. data/lib/tty-spinner/.github/PULL_REQUEST_TEMPLATE.md +19 -0
  26. data/lib/tty-spinner/.github/workflows/ci.yml +59 -0
  27. data/lib/tty-spinner/.gitignore +14 -0
  28. data/lib/tty-spinner/.rspec +2 -0
  29. data/lib/tty-spinner/.rubocop.yml +78 -0
  30. data/lib/tty-spinner/CHANGELOG.md +151 -0
  31. data/lib/tty-spinner/CODE_OF_CONDUCT.md +132 -0
  32. data/lib/tty-spinner/Gemfile +17 -0
  33. data/lib/tty-spinner/LICENSE.txt +22 -0
  34. data/lib/tty-spinner/README.md +581 -0
  35. data/lib/tty-spinner/Rakefile +10 -0
  36. data/lib/tty-spinner/appveyor.yml +33 -0
  37. data/lib/tty-spinner/bin/console +14 -0
  38. data/lib/tty-spinner/bin/setup +8 -0
  39. data/lib/tty-spinner/demo.gif +0 -0
  40. data/lib/tty-spinner/examples/auto_spin.rb +10 -0
  41. data/lib/tty-spinner/examples/basic.rb +10 -0
  42. data/lib/tty-spinner/examples/clear.rb +11 -0
  43. data/lib/tty-spinner/examples/color.rb +14 -0
  44. data/lib/tty-spinner/examples/error.rb +11 -0
  45. data/lib/tty-spinner/examples/formats.rb +13 -0
  46. data/lib/tty-spinner/examples/hide_cursor.rb +14 -0
  47. data/lib/tty-spinner/examples/log.rb +13 -0
  48. data/lib/tty-spinner/examples/multi/basic.rb +15 -0
  49. data/lib/tty-spinner/examples/multi/basic_top_level.rb +15 -0
  50. data/lib/tty-spinner/examples/multi/custom_style.rb +28 -0
  51. data/lib/tty-spinner/examples/multi/files.rb +16 -0
  52. data/lib/tty-spinner/examples/multi/jobs.rb +11 -0
  53. data/lib/tty-spinner/examples/multi/multi.rb +19 -0
  54. data/lib/tty-spinner/examples/multi/multi_top_level.rb +20 -0
  55. data/lib/tty-spinner/examples/multi/pause.rb +28 -0
  56. data/lib/tty-spinner/examples/multi/threaded.rb +30 -0
  57. data/lib/tty-spinner/examples/pause.rb +24 -0
  58. data/lib/tty-spinner/examples/run.rb +20 -0
  59. data/lib/tty-spinner/examples/success.rb +11 -0
  60. data/lib/tty-spinner/examples/threaded.rb +13 -0
  61. data/lib/tty-spinner/examples/update.rb +13 -0
  62. data/lib/tty-spinner/lib/tty/spinner/formats.rb +274 -0
  63. data/lib/tty-spinner/lib/tty/spinner/multi.rb +352 -0
  64. data/lib/tty-spinner/lib/tty/spinner/version.rb +7 -0
  65. data/lib/tty-spinner/lib/tty/spinner.rb +604 -0
  66. data/lib/tty-spinner/lib/tty-spinner.rb +2 -0
  67. data/lib/tty-spinner/spec/spec_helper.rb +52 -0
  68. data/lib/tty-spinner/spec/unit/auto_spin_spec.rb +25 -0
  69. data/lib/tty-spinner/spec/unit/clear_spec.rb +16 -0
  70. data/lib/tty-spinner/spec/unit/error_spec.rb +53 -0
  71. data/lib/tty-spinner/spec/unit/events_spec.rb +35 -0
  72. data/lib/tty-spinner/spec/unit/formats_spec.rb +9 -0
  73. data/lib/tty-spinner/spec/unit/frames_spec.rb +31 -0
  74. data/lib/tty-spinner/spec/unit/hide_cursor_spec.rb +51 -0
  75. data/lib/tty-spinner/spec/unit/job_spec.rb +12 -0
  76. data/lib/tty-spinner/spec/unit/join_spec.rb +10 -0
  77. data/lib/tty-spinner/spec/unit/log_spec.rb +60 -0
  78. data/lib/tty-spinner/spec/unit/multi/auto_spin_spec.rb +32 -0
  79. data/lib/tty-spinner/spec/unit/multi/error_spec.rb +107 -0
  80. data/lib/tty-spinner/spec/unit/multi/line_inset_spec.rb +57 -0
  81. data/lib/tty-spinner/spec/unit/multi/on_spec.rb +11 -0
  82. data/lib/tty-spinner/spec/unit/multi/register_spec.rb +46 -0
  83. data/lib/tty-spinner/spec/unit/multi/spin_spec.rb +101 -0
  84. data/lib/tty-spinner/spec/unit/multi/stop_spec.rb +95 -0
  85. data/lib/tty-spinner/spec/unit/multi/success_spec.rb +108 -0
  86. data/lib/tty-spinner/spec/unit/new_spec.rb +25 -0
  87. data/lib/tty-spinner/spec/unit/pause_spec.rb +43 -0
  88. data/lib/tty-spinner/spec/unit/reset_spec.rb +19 -0
  89. data/lib/tty-spinner/spec/unit/run_spec.rb +30 -0
  90. data/lib/tty-spinner/spec/unit/spin_spec.rb +117 -0
  91. data/lib/tty-spinner/spec/unit/stop_spec.rb +88 -0
  92. data/lib/tty-spinner/spec/unit/success_spec.rb +53 -0
  93. data/lib/tty-spinner/spec/unit/tty_spec.rb +8 -0
  94. data/lib/tty-spinner/spec/unit/update_spec.rb +85 -0
  95. data/lib/tty-spinner/tasks/console.rake +11 -0
  96. data/lib/tty-spinner/tasks/coverage.rake +11 -0
  97. data/lib/tty-spinner/tasks/spec.rake +29 -0
  98. data/lib/tty-spinner/tty-spinner.gemspec +36 -0
  99. data/scripts/runtests.sh +1 -1
  100. data/spec/cli_spec.rb +27 -0
  101. data/spec/spec_helper.rb +26 -0
  102. data/spec/templates/test/_planter.yml +3 -6
  103. data/src/_README.md +5 -3
  104. metadata +86 -2
@@ -0,0 +1,581 @@
1
+ <div align="center">
2
+ <a href="https://ttytoolkit.org"><img width="130" src="https://github.com/piotrmurach/tty/raw/master/images/tty.png" alt="tty logo" /></a>
3
+ </div>
4
+
5
+ # TTY::Spinner
6
+
7
+ [![Gem Version](https://badge.fury.io/rb/tty-spinner.svg)][gem]
8
+ [![Actions CI](https://github.com/piotrmurach/tty-spinner/actions/workflows/ci.yml/badge.svg)][gh_actions_ci]
9
+ [![Build status](https://ci.appveyor.com/api/projects/status/2i5lx3tvyi5l8x3j?svg=true)][appveyor]
10
+ [![Maintainability](https://api.codeclimate.com/v1/badges/d5ae2219e194ac99be58/maintainability)][codeclimate]
11
+ [![Coverage Status](https://coveralls.io/repos/piotrmurach/tty-spinner/badge.svg)][coverage]
12
+
13
+ [gem]: https://badge.fury.io/rb/tty-spinner
14
+ [gh_actions_ci]: https://github.com/piotrmurach/tty-spinner/actions/workflows/ci.yml
15
+ [appveyor]: https://ci.appveyor.com/project/piotrmurach/tty-spinner
16
+ [codeclimate]: https://codeclimate.com/github/piotrmurach/tty-spinner/maintainability
17
+ [coverage]: https://coveralls.io/r/piotrmurach/tty-spinner
18
+
19
+ > A terminal spinner for tasks that have non-deterministic time frame.
20
+
21
+ **TTY::Spinner** provides independent spinner component for [TTY](https://github.com/piotrmurach/tty) toolkit.
22
+
23
+ <div align="center">
24
+ <img alt="Available spinner formats demo" src="demo.gif" width="370" height="376">
25
+ </div>
26
+
27
+ ## Installation
28
+
29
+ Add this line to your application's Gemfile:
30
+
31
+ ```ruby
32
+ gem "tty-spinner"
33
+ ```
34
+
35
+ And then execute:
36
+
37
+ $ bundle
38
+
39
+ Or install it yourself as:
40
+
41
+ $ gem install tty-spinner
42
+
43
+ ## Contents
44
+
45
+ * [1. Usage](#1-usage)
46
+ * [2. TTY::Spinner API](#2-ttyspinner-api)
47
+ * [2.1 spin](#21-spin)
48
+ * [2.2 auto_spin](#22-auto_spin)
49
+ * [2.2.1 pause](#221-pause)
50
+ * [2.2.2 resume](#222-resume)
51
+ * [2.3 run](#23-run)
52
+ * [2.4 start](#24-start)
53
+ * [2.5 stop](#25-stop)
54
+ * [2.5.1 success](#251-success)
55
+ * [2.5.2 error](#252-error)
56
+ * [2.6 update](#26-update)
57
+ * [2.7 reset](#27-reset)
58
+ * [2.8 join](#28-join)
59
+ * [2.9 tty?](#29-tty)
60
+ * [2.10 log](#210-log)
61
+ * [3. Configuration](#3-configuration)
62
+ * [3.1 :format](#31-format)
63
+ * [3.2 :frames](#32-frames)
64
+ * [3.3 :interval](#33-interval)
65
+ * [3.4 :hide_cursor](#34-hide_cursor)
66
+ * [3.5 :clear](#35-clear)
67
+ * [3.6 :success_mark](#36-success_mark)
68
+ * [3.7 :error_mark](#37-error_mark)
69
+ * [3.8 :output](#38-output)
70
+ * [4. Events](#4-events)
71
+ * [4.1 done](#41-done)
72
+ * [4.2 success](#42-success)
73
+ * [4.3 error](#43-error)
74
+ * [5. TTY::Spinner::Multi API](#5-ttyspinnermulti-api)
75
+ * [5.1 register](#51-register)
76
+ * [5.2 auto_spin](#52-auto_spin)
77
+ * [5.2.1 manual async](#521-manual-async)
78
+ * [5.2.2 auto async tasks](#522-auto-async-tasks)
79
+ * [5.3 stop](#53-stop)
80
+ * [5.3.1 success](#531-success)
81
+ * [5.3.2 error](#532-error)
82
+ * [5.4 :style](#54-style)
83
+
84
+ ## 1. Usage
85
+
86
+ **TTY::Spinner** by default uses `:classic` type of formatter and requires no parameters:
87
+
88
+ ```ruby
89
+ spinner = TTY::Spinner.new
90
+ ```
91
+
92
+ In addition you can provide a message with `:spinner` token and format type you would like for the spinning display:
93
+
94
+ ```ruby
95
+ spinner = TTY::Spinner.new("[:spinner] Loading ...", format: :pulse_2)
96
+
97
+ spinner.auto_spin # Automatic animation with default interval
98
+
99
+ sleep(2) # Perform task
100
+
101
+ spinner.stop("Done!") # Stop animation
102
+ ```
103
+
104
+ This would produce animation in your terminal:
105
+
106
+ ```
107
+ ⎺ Loading ...
108
+ ```
109
+
110
+ And when finished output:
111
+
112
+ ```
113
+ _ Loading ... Done!
114
+ ```
115
+
116
+ Use **TTY::Spinner::Multi** to synchronize multiple spinners:
117
+
118
+ ```ruby
119
+ spinners = TTY::Spinner::Multi.new("[:spinner] top")
120
+
121
+ sp1 = spinners.register "[:spinner] one"
122
+ # or sp1 = ::TTY::Spinner.new("[:spinner] one")
123
+ # spinners.register sp1
124
+ sp2 = spinners.register "[:spinner] two"
125
+
126
+ sp1.auto_spin
127
+ sp2.auto_spin
128
+
129
+ sleep(2) # Perform work
130
+
131
+ sp1.success
132
+ sp2.success
133
+ ```
134
+
135
+ The spinners when done will display:
136
+
137
+ ```
138
+ ┌ [✔] top
139
+ ├── [✔] one
140
+ └── [✔] two
141
+ ```
142
+
143
+ For more usage examples please see [examples directory](https://github.com/piotrmurach/tty-spinner/tree/master/examples)
144
+
145
+ ## 2. TTY::Spinner API
146
+
147
+ ### 2.1 spin
148
+
149
+ The main workhorse of the spinner is the `spin` method.
150
+
151
+ Looping over `spin` method will animate a given spinner.
152
+
153
+ ```ruby
154
+ loop do
155
+ spinner.spin
156
+ end
157
+ ```
158
+
159
+ ### 2.2 auto_spin
160
+
161
+ To perform automatic spinning animation use `auto_spin` method like so:
162
+
163
+ ```ruby
164
+ spinner.auto_spin
165
+ ```
166
+
167
+ The speed with which the spinning happens is determined by the `:interval` parameter. All the spinner formats have their default intervals specified ([see](https://github.com/piotrmurach/tty-spinner/blob/master/lib/tty/spinner/formats.rb)).
168
+
169
+ ### 2.2.1 pause
170
+
171
+ After calling `auto_spin` you can pause spinner execution:
172
+
173
+ ```ruby
174
+ spinner.pause
175
+ ```
176
+
177
+ ### 2.2.2 resume
178
+
179
+ You can continue any paused spinner:
180
+
181
+ ```ruby
182
+ spinner.resume
183
+ ```
184
+
185
+ ### 2.3 run
186
+
187
+ Use `run` passing a block with a job that will automatically display spinning animation while the block executes and finish animation when the block terminates. The block yields a spinner instance.
188
+
189
+ ```ruby
190
+ spinner.run do |spinner|
191
+ ...
192
+ end
193
+ ```
194
+
195
+ Optionally you can provide a stop message to display when animation is finished.
196
+
197
+ ```ruby
198
+ spinner.run("Done!") do |spinner|
199
+ ...
200
+ end
201
+ ```
202
+
203
+ ### 2.4 start
204
+
205
+ In order to set start time or reuse the same spinner after it has stopped, call `start` method:
206
+
207
+ ```ruby
208
+ spinner.start
209
+ ```
210
+
211
+ ### 2.5 stop
212
+
213
+ In order to stop the spinner call `stop`. This will finish drawing the spinning animation and return to new line.
214
+
215
+ ```ruby
216
+ spinner.stop
217
+ ```
218
+
219
+ You can further pass a message to print when animation is finished.
220
+
221
+ ```ruby
222
+ spinner.stop("Done!")
223
+ ```
224
+
225
+ #### 2.5.1 success
226
+
227
+ Use `success` call to stop the spinning animation and replace the spinning symbol with check mark character to indicate successful completion.
228
+
229
+ ```ruby
230
+ spinner = TTY::Spinner.new("[:spinner] Task name")
231
+ spinner.success("(successful)")
232
+ ```
233
+
234
+ This will produce:
235
+
236
+ ```
237
+ [✔] Task name (successful)
238
+ ```
239
+
240
+ #### 2.5.2 error
241
+
242
+ Use `error` call to stop the spinning animation and replace the spinning symbol with cross character to indicate error completion.
243
+
244
+ ```ruby
245
+ spinner = TTY::Spinner.new("[:spinner] Task name")
246
+ spinner.error("(error)")
247
+ ```
248
+
249
+ This will produce:
250
+
251
+ ```
252
+ [✖] Task name (error)
253
+ ```
254
+
255
+ ### 2.6 update
256
+
257
+ Use `update` call to dynamically change label name(s).
258
+
259
+ Provide an arbitrary token name(s) in the message string, such as `:title`
260
+
261
+ ```ruby
262
+ spinner = TTY::Spinner.new("[:spinner] :title")
263
+ ```
264
+
265
+ and then pass token name and value:
266
+
267
+ ```ruby
268
+ spinner.update(title: "Downloading file1")
269
+ ```
270
+
271
+ next start animation:
272
+
273
+ ```ruby
274
+ spinner.run { ... }
275
+ # => | Downloading file1
276
+ ```
277
+
278
+ Once animation finishes you can kick start another one with a different name:
279
+
280
+ ```ruby
281
+ spinner.update(title: "Downloading file2")
282
+ spinner.run { ... }
283
+ ```
284
+
285
+ ### 2.7 reset
286
+
287
+ In order to reset the spinner to its initial frame do:
288
+
289
+ ```ruby
290
+ spinner.reset
291
+ ```
292
+
293
+ ### 2.8 join
294
+
295
+ One way to wait while the spinning animates is to join the thread started with `start` method:
296
+
297
+ ```ruby
298
+ spinner.join
299
+ ```
300
+
301
+ Optionally you can provide timeout:
302
+
303
+ ```ruby
304
+ spinner.join(0.5)
305
+ ```
306
+
307
+ ### 2.9 tty?
308
+
309
+ The spinner will not write any output if the output stream is not a TTY. You can check this with:
310
+
311
+ ```ruby
312
+ spinner.tty?
313
+ ```
314
+
315
+ ### 2.10 log
316
+
317
+ To output log messages to the console above a spinner use the `log` method:
318
+
319
+ ```ruby
320
+ spinner.log("Print this log message to the console")
321
+ ```
322
+
323
+ ## 3. Configuration
324
+
325
+ There are number of configuration options that can be provided to customise the behaviour of a spinner.
326
+
327
+ ### 3.1 :format
328
+
329
+ Use one of the predefined spinner styles by passing the formatting token `:format`
330
+
331
+ ```ruby
332
+ spinner = TTY::Spinner.new(format: :pulse_2)
333
+ ```
334
+
335
+ All spinner formats that **TTY::Spinner** accepts are defined in [/lib/tty/spinner/formats.rb](https://github.com/piotrmurach/tty-spinner/blob/master/lib/tty/spinner/formats.rb)
336
+
337
+ If you wish to see all available formats in action run the `formats.rb` file in examples folder like so:
338
+
339
+ ```ruby
340
+ bundle exec ruby examples/formats.rb
341
+ ```
342
+
343
+ ### 3.2 :frames
344
+
345
+ If you wish to use custom formatting use the `:frames` option with either `array` or `string` of characters.
346
+
347
+ ```ruby
348
+ spinner = TTY::Spinner.new(frames: [".", "o", "0", "@", "*"])
349
+ ```
350
+
351
+ ### 3.3 :interval
352
+
353
+ The `:interval` option accepts `integer` representing number of `Hz` units, for instance, frequency of 10 will mean that the spinning animation will be displayed 10 times per second.
354
+
355
+ ```ruby
356
+ spinner = TTY::Spinner.new(interval: 20) # 20 Hz (20 times per second)
357
+ ```
358
+
359
+ ### 3.4 :hide_cursor
360
+
361
+ Hides cursor when spinning animation performs. Defaults to `false`.
362
+
363
+ ```ruby
364
+ spinner = TTY::Spinner.new(hide_cursor: true)
365
+ ```
366
+
367
+ ### 3.5 :clear
368
+
369
+ After spinner is finished clears its output. Defaults to `false`.
370
+
371
+ ```ruby
372
+ spinner = TTY::Spinner.new(clear: true)
373
+ ```
374
+
375
+ ### 3.6 :success_mark
376
+
377
+ To change marker indicating successful completion use the `:success_mark` option:
378
+
379
+ ```ruby
380
+ spinner = TTY::Spinner.new(success_mark: "+")
381
+ ```
382
+
383
+ ### 3.7 :error_mark
384
+
385
+ To change marker indicating error completion use the `:error_mark` option:
386
+
387
+ ```ruby
388
+ spinner = TTY::Spinner.new(error_mark: "x")
389
+ ```
390
+
391
+ ### 3.8 :output
392
+
393
+ The spinner only outputs to a console and when output is redirected to a file or a pipe it does nothing. This is so, for example, your error logs do not overflow with spinner output.
394
+
395
+ You can change where console output is streamed with `:output` option:
396
+
397
+ ```ruby
398
+ spinner = TTY::Spinner.new(output: $stdout)
399
+ ```
400
+
401
+ The output stream defaults to `stderr`.
402
+
403
+ ## 4. Events
404
+
405
+ **TTY::Spinner** emits `:done`, `:success` and `:error` event types when spinner is stopped.
406
+
407
+ ### 4.1 done
408
+
409
+ This event is emitted irrespective of the completion method. In order to listen for this event you need to register callback:
410
+
411
+ ```ruby
412
+ spinner.on(:done) { ... }
413
+ ```
414
+
415
+ ### 4.2 success
416
+
417
+ This event is fired when `success` call is made. In order to respond to the event, you need to register callback:
418
+
419
+ ```ruby
420
+ spinner.on(:success) { ... }
421
+ ```
422
+
423
+ ### 4.3 error
424
+
425
+ This event is fired when `error` completion is called. In order to respond to the event, you need to register callback:
426
+
427
+ ```ruby
428
+ spinner.on(:error) { ... }
429
+ ```
430
+
431
+ ## 5. TTY::Spinner::Multi API
432
+
433
+ ### 5.1 register
434
+
435
+ Create and register a `TTY::Spinner` under the multispinner
436
+
437
+ ```ruby
438
+ new_spinner = multi_spinner.register("[:spinner] Task 1 name", options)
439
+ # or
440
+ # spinner = ::TTY::Spinner.new("[:spinner] one")
441
+ # sp1 = multi_spinner.register(spinner)
442
+ ```
443
+
444
+ If no options are given it will use the options given to the multi_spinner when it was initialized to create the new spinner.
445
+ If options are passed, they will override any options given to the multi spinner.
446
+
447
+ ### 5.2 auto_spin
448
+
449
+ To create a top level spinner that tracks activity of all the registered spinners, the multispinner has to have been given a message on initialization:
450
+
451
+ ```ruby
452
+ multi_spinner = TTY::Spinner::Multi.new("[:spinner] Top level spinner")
453
+ ```
454
+
455
+ The top level multi spinner will perform spinning animation automatically when at least one of the registered spinners starts spinning.
456
+
457
+ If you register spinners without any tasks then you will have to manually control when the `multi_spinner` finishes by calling `stop`, `success` or `error` (see [manual](#521-manual-async)).
458
+
459
+ Alternatively, you can register spinners with tasks that will automatically animate and finish spinners when respective tasks are done (see [async tasks](#522-auto-async-tasks)).
460
+
461
+ The speed with which the spinning happens is determined by the `:interval` parameter. All the spinner formats have their default intervals specified ([see](https://github.com/piotrmurach/tty-spinner/blob/master/lib/tty/spinner/formats.rb)).
462
+
463
+ #### 5.2.1 manual async
464
+
465
+ In case when you wish to have full control over multiple spinners, you will need to perform all actions manually.
466
+
467
+ For example, create a multi spinner that will track status of all registered spinners:
468
+
469
+ ```ruby
470
+ multi_spinner = TTY::Spinner::Multi.new("[:spinner] top")
471
+ ```
472
+
473
+ and then register spinners with their formats:
474
+
475
+ ```
476
+ spinner_1 = spinners.register "[:spinner] one"
477
+ spinner_2 = spinners.register "[:spinner] two"
478
+ ```
479
+
480
+ Once registered, you can set spinners running in separate threads:
481
+
482
+ ```ruby
483
+ spinner_1.auto_spin
484
+ spinner_2.auto_spin
485
+ ```
486
+
487
+ Finally, you need to stop each spinner manually, in our case we mark the second spinner as failure which in turn will stop the top level multi spinner automatically and mark it as failure:
488
+
489
+ ```ruby
490
+ spinner_1.success
491
+ spinner_2.error
492
+ ```
493
+
494
+ The result may look like this:
495
+
496
+ ```ruby
497
+ ┌ [✖] top
498
+ ├── [✔] one
499
+ └── [✖] two
500
+ ```
501
+
502
+ #### 5.2.2 auto async tasks
503
+
504
+ In case when you wish to execute async tasks and update individual spinners automatically, in any order, about their task status use `#register` and pass additional block parameter with the job to be executed.
505
+
506
+ For example, create a multi spinner that will track status of all registered spinners:
507
+
508
+ ```ruby
509
+ multi_spinner = TTY::Spinner::Multi.new("[:spinner] top")
510
+ ```
511
+
512
+ and then register spinners with their respective tasks:
513
+
514
+ ```ruby
515
+ multi_spinner.register("[:spinner] one") { |sp| sleep(2); sp.success("yes 2") }
516
+ multi_spinner.register("[:spinner] two") { |sp| sleep(3); sp.error("no 2") }
517
+ ```
518
+
519
+ Finally, call `#auto_spin` to kick things off:
520
+
521
+ ```ruby
522
+ multi_spinner.auto_spin
523
+ ```
524
+
525
+ If any of the child spinner stops with error then the top level spinner will be marked as failure.
526
+
527
+ ### 5.3 stop
528
+
529
+ In order to stop the multi spinner call `stop`. This will stop the top level spinner, if it exists, and any sub-spinners still spinning.
530
+
531
+ ```ruby
532
+ multi_spinner.stop
533
+ ```
534
+
535
+ #### 5.3.1 success
536
+
537
+ Use `success` call to stop the spinning animation and replace the spinning symbol with a check mark character to indicate successful completion.
538
+ This will also call `#success` on any sub-spinners that are still spinning.
539
+
540
+ ```ruby
541
+ multi_spinner.success
542
+ ```
543
+
544
+ #### 5.3.2 error
545
+
546
+ Use `error` call to stop the spinning animation and replace the spinning symbol with cross character to indicate error completion.
547
+ This will also call `#error` on any sub-spinners that are still spinning.
548
+
549
+ ```ruby
550
+ multi_spinner.error
551
+ ```
552
+
553
+ ### 5.4 :style
554
+
555
+ In addition to all [configuration options](#3-configuration) you can style multi spinner like so:
556
+
557
+ ```ruby
558
+ multi_spinner = TTY::Spinner::Multi.new("[:spinner] parent", style: {
559
+ top: ". "
560
+ middle: "|-> "
561
+ bottom: "|__ "
562
+ })
563
+ ```
564
+
565
+ ## Contributing
566
+
567
+ Bug reports and pull requests are welcome on GitHub at https://github.com/piotrmurach/tty-spinner. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/piotrmurach/tty-spinner/blob/master/CODE_OF_CONDUCT.md).
568
+
569
+ 1. Fork it ( https://github.com/piotrmurach/tty-spinner/fork )
570
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
571
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
572
+ 4. Push to the branch (`git push origin my-new-feature`)
573
+ 5. Create a new Pull Request
574
+
575
+ ## Code of Conduct
576
+
577
+ Everyone interacting in the TTY::Spinner project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/piotrmurach/tty-spinner/blob/master/CODE_OF_CONDUCT.md).
578
+
579
+ ## Copyright
580
+
581
+ Copyright (c) 2014 Piotr Murach. See LICENSE for further details.
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+
5
+ FileList["tasks/**/*.rake"].each(&method(:import))
6
+
7
+ desc "Run all specs"
8
+ task ci: %w[ spec ]
9
+
10
+ task default: :spec
@@ -0,0 +1,33 @@
1
+ ---
2
+ skip_commits:
3
+ files:
4
+ - "bin/**"
5
+ - "examples/**"
6
+ - "*.md"
7
+ install:
8
+ - SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
9
+ - gem install bundler -v '< 2.0'
10
+ - bundle install
11
+ before_test:
12
+ - ruby -v
13
+ - gem -v
14
+ - bundle -v
15
+ build: off
16
+ test_script:
17
+ - bundle exec rake ci
18
+ environment:
19
+ matrix:
20
+ - ruby_version: "200"
21
+ - ruby_version: "200-x64"
22
+ - ruby_version: "21"
23
+ - ruby_version: "21-x64"
24
+ - ruby_version: "22"
25
+ - ruby_version: "22-x64"
26
+ - ruby_version: "23"
27
+ - ruby_version: "23-x64"
28
+ - ruby_version: "24"
29
+ - ruby_version: "24-x64"
30
+ - ruby_version: "25"
31
+ - ruby_version: "25-x64"
32
+ - ruby_version: "26"
33
+ - ruby_version: "26-x64"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "tty/spinner"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
Binary file
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../lib/tty-spinner"
4
+
5
+ spinner = TTY::Spinner.new("Loading :spinner ...", format: :bouncing_ball)
6
+ spinner.auto_spin
7
+
8
+ sleep 1 # Some long task
9
+
10
+ spinner.stop("done")
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../lib/tty-spinner"
4
+
5
+ spinner = TTY::Spinner.new("Loading :spinner ... ", format: :spin_2)
6
+ 20.times do
7
+ spinner.spin
8
+ sleep(0.1)
9
+ end
10
+ spinner.stop("done")
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../lib/tty-spinner"
4
+
5
+ spinner = TTY::Spinner.new("[:spinner] Task name", format: :bouncing_ball)
6
+ 20.times do
7
+ spinner.spin
8
+ sleep(0.1)
9
+ end
10
+
11
+ spinner.success
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "pastel"
4
+ require_relative "../lib/tty-spinner"
5
+
6
+ pastel = Pastel.new
7
+
8
+ format = "[#{pastel.yellow(":spinner")}] " + pastel.yellow("Task name")
9
+ spinner = TTY::Spinner.new(format, success_mark: pastel.green("+"))
10
+ 20.times do
11
+ spinner.spin
12
+ sleep(0.1)
13
+ end
14
+ spinner.success(pastel.green("(successful)"))