whirly 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +24 -0
- data/Gemfile +2 -0
- data/MIT-LICENSE.txt +1 -1
- data/README.md +11 -11
- data/Rakefile +1 -1
- data/data/cli-spinners.json +592 -0
- data/data/whirly-static-spinners.json +99 -0
- data/examples/euruko.rb +1 -1
- data/examples/single.rb +1 -1
- data/lib/whirly.rb +15 -10
- data/lib/whirly/spinners/whirly.rb +1 -5
- data/lib/whirly/version.rb +3 -2
- data/spec/whirly_spec.rb +132 -5
- data/whirly.gemspec +3 -3
- metadata +10 -9
- data/.travis.yml +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0d29fbecff7cd421276c1212e4f78775d153dbdaa911c9c0ab4455cc95f7af02
|
4
|
+
data.tar.gz: a390b99e94244688c8bc6a283b1f8e407d2031f03fec6be9f9e7bfd0727c0e83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5ad854b00b8d9b8e620cbe96b456fbaa98ec116233ca531e840f4204986f9397a32494e2aea1bf73057a97dc7541a6c0f868a6c901441cdf6e19a3602e2ff78
|
7
|
+
data.tar.gz: 85171c117d3f3d1d77b1fbfd9af2e864b6e2bd39d55d3673c63d8247e404c36d4f89a7de2acb4aabd250d7c247131f91833651d18c7f9b4ccabd1423b38ae11a
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,29 @@
|
|
1
1
|
## CHANGELOG
|
2
2
|
|
3
|
+
### 0.3.0
|
4
|
+
|
5
|
+
- Allow more recent versions of Ruby and unicode-display_width gem
|
6
|
+
- Update CLI spinners to 2.6.0
|
7
|
+
|
8
|
+
### 0.2.6
|
9
|
+
|
10
|
+
- Update CLI spinners to 1.1.0 (adds "weather" and "christmas")
|
11
|
+
|
12
|
+
### 0.2.5
|
13
|
+
|
14
|
+
- Update CLI spinners to 1.0.1
|
15
|
+
|
16
|
+
### 0.2.4
|
17
|
+
|
18
|
+
- Fix bug that the Whirly thread will also stop when main thread throws error
|
19
|
+
(patch by @monkbroc)
|
20
|
+
- New spinner: xberg
|
21
|
+
|
22
|
+
### 0.2.3
|
23
|
+
|
24
|
+
- Fix bug that in some cases whirly output would be shown on non-ttys
|
25
|
+
- New spinners: card, cloud, photo, banknote, white_square
|
26
|
+
|
3
27
|
### 0.2.2
|
4
28
|
|
5
29
|
- More emotions for whirly (the spinner)
|
data/Gemfile
CHANGED
data/MIT-LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# Whirly 😀 [![[version]](https://badge.fury.io/rb/whirly.svg)](
|
1
|
+
# Whirly 😀 [![[version]](https://badge.fury.io/rb/whirly.svg)](https://badge.fury.io/rb/whirly) [<img src="https://github.com/janlelis/whirly/workflows/Test/badge.svg" />](https://github.com/janlelis/whirly/actions/workflows/test.yml)
|
2
2
|
|
3
|
-
A simple, colorful and customizable terminal spinner library for Ruby. It comes with
|
3
|
+
A simple, colorful and customizable terminal spinner library for Ruby. It comes with 24 custom spinners and also includes those from the [cli-spinners](https://github.com/sindresorhus/cli-spinners) project.
|
4
4
|
|
5
5
|
## Demonstration
|
6
6
|
|
@@ -12,7 +12,7 @@ A simple, colorful and customizable terminal spinner library for Ruby. It comes
|
|
12
12
|
|
13
13
|
### Bundled Spinners from CLI Spinners
|
14
14
|
|
15
|
-
![](https://raw.githubusercontent.com/sindresorhus/cli-spinners/
|
15
|
+
![](https://raw.githubusercontent.com/sindresorhus/cli-spinners/main/screenshot.gif)
|
16
16
|
|
17
17
|
[Play on asciinema](https://asciinema.org/a/9mlcoussb137m32swwuqtb2p1?size=big)
|
18
18
|
|
@@ -60,12 +60,12 @@ Whirly.stop
|
|
60
60
|
The `start` method takes a lot of options, like which spinner to use or an initial status. See further below for the full description of available options.
|
61
61
|
|
62
62
|
```ruby
|
63
|
-
Whirly.start spinner: "pong",
|
63
|
+
Whirly.start spinner: "pong", color: false, status: "The Game of Pong" do
|
64
64
|
sleep 10
|
65
65
|
end
|
66
66
|
```
|
67
67
|
|
68
|
-
Also see the [examples directory](https://github.com/janlelis/whirly/tree/
|
68
|
+
Also see the [examples directory](https://github.com/janlelis/whirly/tree/main/examples) for example scripts.
|
69
69
|
|
70
70
|
### Configuring Whirly
|
71
71
|
|
@@ -99,7 +99,7 @@ end
|
|
99
99
|
|
100
100
|
### Included Spinners
|
101
101
|
|
102
|
-
See [`data/whirly-static-spinnes.json`](https://github.com/janlelis/whirly/blob/
|
102
|
+
See [`data/whirly-static-spinnes.json`](https://github.com/janlelis/whirly/blob/main/data/whirly-static-spinners.json), [`lib/whirly/spinners/whirly.rb`](https://github.com/janlelis/whirly/blob/main/lib/whirly/spinners/whirly.rb) and [cli-spinners](https://github.com/sindresorhus/cli-spinners). You can get a demonstration of all bundled spinners by running the [`examples/all_spinners.rb`](https://github.com/janlelis/whirly/blob/main/examples/all_spinners.rb) script.
|
103
103
|
|
104
104
|
## All `Whirly.start` / `Whirly.configure` Configuration Options
|
105
105
|
|
@@ -212,7 +212,7 @@ Whirly comes with spinners from different sources. This options defines which so
|
|
212
212
|
|
213
213
|
*Default:* `$stdout`
|
214
214
|
|
215
|
-
You can pass in an [IO](https://ruby-doc.org/core
|
215
|
+
You can pass in an [IO](https://ruby-doc.org/core/IO.html)-like object, if you want to display *Whirly* on an other stream than `$stdout`.
|
216
216
|
|
217
217
|
## Full Spinner Hash Format
|
218
218
|
|
@@ -220,7 +220,7 @@ A full spinner is defined by a hash which can have the following key-value pairs
|
|
220
220
|
|
221
221
|
### `"frames"`
|
222
222
|
|
223
|
-
An [Array](https://ruby-doc.org/core
|
223
|
+
An [Array](https://ruby-doc.org/core/Array.html) or [Enumerable](https://ruby-doc.org/core/Enumerable.html) of strings that will be used as the spinner icon.
|
224
224
|
|
225
225
|
### `"proc"`
|
226
226
|
|
@@ -239,7 +239,7 @@ The order in which frames should be played. It can be one of the following:
|
|
239
239
|
- `"swing"`: Cycle through all frames in normal order, and then in reverse order, but only play first and last frame once each round
|
240
240
|
- `"random"`: Play random frames
|
241
241
|
|
242
|
-
Please note: While `"linear"` also works with frames that are just an [Enumerable](https://ruby-doc.org/core
|
242
|
+
Please note: While `"linear"` also works with frames that are just an [Enumerable](https://ruby-doc.org/core/Enumerable.html), all other frame modes require the object to be representable as an [Array](https://ruby-doc.org/core/Array.html).
|
243
243
|
|
244
244
|
### `"stop"`
|
245
245
|
|
@@ -250,9 +250,9 @@ A frame to be used to end the spinner icon animation.
|
|
250
250
|
- Interval is milliseconds, but don't rely on exact timing
|
251
251
|
- Will not do anything if stream is not a real console (or `non_tty: true` is passed)
|
252
252
|
- Colors not working? Be sure to include the [paint](https://github.com/janlelis/paint/) gem in your Gemfile
|
253
|
-
- Don't set very short intervals (or it might affect performance
|
253
|
+
- Don't set very short intervals (or it might affect performance substantially)
|
254
254
|
|
255
255
|
## MIT License
|
256
256
|
|
257
|
-
- Copyright (C) 2016 Jan Lelis <
|
257
|
+
- Copyright (C) 2016 Jan Lelis <https://janlelis.com>. Released under the MIT license.
|
258
258
|
- Contains data from cli-spinners: MIT License, Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
data/Rakefile
CHANGED
data/data/cli-spinners.json
CHANGED
@@ -274,6 +274,267 @@
|
|
274
274
|
"⠀⡀"
|
275
275
|
]
|
276
276
|
},
|
277
|
+
"dots8Bit": {
|
278
|
+
"interval": 80,
|
279
|
+
"frames": [
|
280
|
+
"⠀",
|
281
|
+
"⠁",
|
282
|
+
"⠂",
|
283
|
+
"⠃",
|
284
|
+
"⠄",
|
285
|
+
"⠅",
|
286
|
+
"⠆",
|
287
|
+
"⠇",
|
288
|
+
"⡀",
|
289
|
+
"⡁",
|
290
|
+
"⡂",
|
291
|
+
"⡃",
|
292
|
+
"⡄",
|
293
|
+
"⡅",
|
294
|
+
"⡆",
|
295
|
+
"⡇",
|
296
|
+
"⠈",
|
297
|
+
"⠉",
|
298
|
+
"⠊",
|
299
|
+
"⠋",
|
300
|
+
"⠌",
|
301
|
+
"⠍",
|
302
|
+
"⠎",
|
303
|
+
"⠏",
|
304
|
+
"⡈",
|
305
|
+
"⡉",
|
306
|
+
"⡊",
|
307
|
+
"⡋",
|
308
|
+
"⡌",
|
309
|
+
"⡍",
|
310
|
+
"⡎",
|
311
|
+
"⡏",
|
312
|
+
"⠐",
|
313
|
+
"⠑",
|
314
|
+
"⠒",
|
315
|
+
"⠓",
|
316
|
+
"⠔",
|
317
|
+
"⠕",
|
318
|
+
"⠖",
|
319
|
+
"⠗",
|
320
|
+
"⡐",
|
321
|
+
"⡑",
|
322
|
+
"⡒",
|
323
|
+
"⡓",
|
324
|
+
"⡔",
|
325
|
+
"⡕",
|
326
|
+
"⡖",
|
327
|
+
"⡗",
|
328
|
+
"⠘",
|
329
|
+
"⠙",
|
330
|
+
"⠚",
|
331
|
+
"⠛",
|
332
|
+
"⠜",
|
333
|
+
"⠝",
|
334
|
+
"⠞",
|
335
|
+
"⠟",
|
336
|
+
"⡘",
|
337
|
+
"⡙",
|
338
|
+
"⡚",
|
339
|
+
"⡛",
|
340
|
+
"⡜",
|
341
|
+
"⡝",
|
342
|
+
"⡞",
|
343
|
+
"⡟",
|
344
|
+
"⠠",
|
345
|
+
"⠡",
|
346
|
+
"⠢",
|
347
|
+
"⠣",
|
348
|
+
"⠤",
|
349
|
+
"⠥",
|
350
|
+
"⠦",
|
351
|
+
"⠧",
|
352
|
+
"⡠",
|
353
|
+
"⡡",
|
354
|
+
"⡢",
|
355
|
+
"⡣",
|
356
|
+
"⡤",
|
357
|
+
"⡥",
|
358
|
+
"⡦",
|
359
|
+
"⡧",
|
360
|
+
"⠨",
|
361
|
+
"⠩",
|
362
|
+
"⠪",
|
363
|
+
"⠫",
|
364
|
+
"⠬",
|
365
|
+
"⠭",
|
366
|
+
"⠮",
|
367
|
+
"⠯",
|
368
|
+
"⡨",
|
369
|
+
"⡩",
|
370
|
+
"⡪",
|
371
|
+
"⡫",
|
372
|
+
"⡬",
|
373
|
+
"⡭",
|
374
|
+
"⡮",
|
375
|
+
"⡯",
|
376
|
+
"⠰",
|
377
|
+
"⠱",
|
378
|
+
"⠲",
|
379
|
+
"⠳",
|
380
|
+
"⠴",
|
381
|
+
"⠵",
|
382
|
+
"⠶",
|
383
|
+
"⠷",
|
384
|
+
"⡰",
|
385
|
+
"⡱",
|
386
|
+
"⡲",
|
387
|
+
"⡳",
|
388
|
+
"⡴",
|
389
|
+
"⡵",
|
390
|
+
"⡶",
|
391
|
+
"⡷",
|
392
|
+
"⠸",
|
393
|
+
"⠹",
|
394
|
+
"⠺",
|
395
|
+
"⠻",
|
396
|
+
"⠼",
|
397
|
+
"⠽",
|
398
|
+
"⠾",
|
399
|
+
"⠿",
|
400
|
+
"⡸",
|
401
|
+
"⡹",
|
402
|
+
"⡺",
|
403
|
+
"⡻",
|
404
|
+
"⡼",
|
405
|
+
"⡽",
|
406
|
+
"⡾",
|
407
|
+
"⡿",
|
408
|
+
"⢀",
|
409
|
+
"⢁",
|
410
|
+
"⢂",
|
411
|
+
"⢃",
|
412
|
+
"⢄",
|
413
|
+
"⢅",
|
414
|
+
"⢆",
|
415
|
+
"⢇",
|
416
|
+
"⣀",
|
417
|
+
"⣁",
|
418
|
+
"⣂",
|
419
|
+
"⣃",
|
420
|
+
"⣄",
|
421
|
+
"⣅",
|
422
|
+
"⣆",
|
423
|
+
"⣇",
|
424
|
+
"⢈",
|
425
|
+
"⢉",
|
426
|
+
"⢊",
|
427
|
+
"⢋",
|
428
|
+
"⢌",
|
429
|
+
"⢍",
|
430
|
+
"⢎",
|
431
|
+
"⢏",
|
432
|
+
"⣈",
|
433
|
+
"⣉",
|
434
|
+
"⣊",
|
435
|
+
"⣋",
|
436
|
+
"⣌",
|
437
|
+
"⣍",
|
438
|
+
"⣎",
|
439
|
+
"⣏",
|
440
|
+
"⢐",
|
441
|
+
"⢑",
|
442
|
+
"⢒",
|
443
|
+
"⢓",
|
444
|
+
"⢔",
|
445
|
+
"⢕",
|
446
|
+
"⢖",
|
447
|
+
"⢗",
|
448
|
+
"⣐",
|
449
|
+
"⣑",
|
450
|
+
"⣒",
|
451
|
+
"⣓",
|
452
|
+
"⣔",
|
453
|
+
"⣕",
|
454
|
+
"⣖",
|
455
|
+
"⣗",
|
456
|
+
"⢘",
|
457
|
+
"⢙",
|
458
|
+
"⢚",
|
459
|
+
"⢛",
|
460
|
+
"⢜",
|
461
|
+
"⢝",
|
462
|
+
"⢞",
|
463
|
+
"⢟",
|
464
|
+
"⣘",
|
465
|
+
"⣙",
|
466
|
+
"⣚",
|
467
|
+
"⣛",
|
468
|
+
"⣜",
|
469
|
+
"⣝",
|
470
|
+
"⣞",
|
471
|
+
"⣟",
|
472
|
+
"⢠",
|
473
|
+
"⢡",
|
474
|
+
"⢢",
|
475
|
+
"⢣",
|
476
|
+
"⢤",
|
477
|
+
"⢥",
|
478
|
+
"⢦",
|
479
|
+
"⢧",
|
480
|
+
"⣠",
|
481
|
+
"⣡",
|
482
|
+
"⣢",
|
483
|
+
"⣣",
|
484
|
+
"⣤",
|
485
|
+
"⣥",
|
486
|
+
"⣦",
|
487
|
+
"⣧",
|
488
|
+
"⢨",
|
489
|
+
"⢩",
|
490
|
+
"⢪",
|
491
|
+
"⢫",
|
492
|
+
"⢬",
|
493
|
+
"⢭",
|
494
|
+
"⢮",
|
495
|
+
"⢯",
|
496
|
+
"⣨",
|
497
|
+
"⣩",
|
498
|
+
"⣪",
|
499
|
+
"⣫",
|
500
|
+
"⣬",
|
501
|
+
"⣭",
|
502
|
+
"⣮",
|
503
|
+
"⣯",
|
504
|
+
"⢰",
|
505
|
+
"⢱",
|
506
|
+
"⢲",
|
507
|
+
"⢳",
|
508
|
+
"⢴",
|
509
|
+
"⢵",
|
510
|
+
"⢶",
|
511
|
+
"⢷",
|
512
|
+
"⣰",
|
513
|
+
"⣱",
|
514
|
+
"⣲",
|
515
|
+
"⣳",
|
516
|
+
"⣴",
|
517
|
+
"⣵",
|
518
|
+
"⣶",
|
519
|
+
"⣷",
|
520
|
+
"⢸",
|
521
|
+
"⢹",
|
522
|
+
"⢺",
|
523
|
+
"⢻",
|
524
|
+
"⢼",
|
525
|
+
"⢽",
|
526
|
+
"⢾",
|
527
|
+
"⢿",
|
528
|
+
"⣸",
|
529
|
+
"⣹",
|
530
|
+
"⣺",
|
531
|
+
"⣻",
|
532
|
+
"⣼",
|
533
|
+
"⣽",
|
534
|
+
"⣾",
|
535
|
+
"⣿"
|
536
|
+
]
|
537
|
+
},
|
277
538
|
"line": {
|
278
539
|
"interval": 130,
|
279
540
|
"frames": [
|
@@ -659,6 +920,13 @@
|
|
659
920
|
"bouncingBar": {
|
660
921
|
"interval": 80,
|
661
922
|
"frames": [
|
923
|
+
"[ ]",
|
924
|
+
"[= ]",
|
925
|
+
"[== ]",
|
926
|
+
"[=== ]",
|
927
|
+
"[ ===]",
|
928
|
+
"[ ==]",
|
929
|
+
"[ =]",
|
662
930
|
"[ ]",
|
663
931
|
"[ =]",
|
664
932
|
"[ ==]",
|
@@ -713,6 +981,7 @@
|
|
713
981
|
"clock": {
|
714
982
|
"interval": 100,
|
715
983
|
"frames": [
|
984
|
+
"🕛 ",
|
716
985
|
"🕐 ",
|
717
986
|
"🕑 ",
|
718
987
|
"🕒 ",
|
@@ -734,6 +1003,103 @@
|
|
734
1003
|
"🌏 "
|
735
1004
|
]
|
736
1005
|
},
|
1006
|
+
"material": {
|
1007
|
+
"interval": 17,
|
1008
|
+
"frames": [
|
1009
|
+
"█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
1010
|
+
"██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
1011
|
+
"███▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
1012
|
+
"████▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
1013
|
+
"██████▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
1014
|
+
"██████▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
1015
|
+
"███████▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
1016
|
+
"████████▁▁▁▁▁▁▁▁▁▁▁▁",
|
1017
|
+
"█████████▁▁▁▁▁▁▁▁▁▁▁",
|
1018
|
+
"█████████▁▁▁▁▁▁▁▁▁▁▁",
|
1019
|
+
"██████████▁▁▁▁▁▁▁▁▁▁",
|
1020
|
+
"███████████▁▁▁▁▁▁▁▁▁",
|
1021
|
+
"█████████████▁▁▁▁▁▁▁",
|
1022
|
+
"██████████████▁▁▁▁▁▁",
|
1023
|
+
"██████████████▁▁▁▁▁▁",
|
1024
|
+
"▁██████████████▁▁▁▁▁",
|
1025
|
+
"▁██████████████▁▁▁▁▁",
|
1026
|
+
"▁██████████████▁▁▁▁▁",
|
1027
|
+
"▁▁██████████████▁▁▁▁",
|
1028
|
+
"▁▁▁██████████████▁▁▁",
|
1029
|
+
"▁▁▁▁█████████████▁▁▁",
|
1030
|
+
"▁▁▁▁██████████████▁▁",
|
1031
|
+
"▁▁▁▁██████████████▁▁",
|
1032
|
+
"▁▁▁▁▁██████████████▁",
|
1033
|
+
"▁▁▁▁▁██████████████▁",
|
1034
|
+
"▁▁▁▁▁██████████████▁",
|
1035
|
+
"▁▁▁▁▁▁██████████████",
|
1036
|
+
"▁▁▁▁▁▁██████████████",
|
1037
|
+
"▁▁▁▁▁▁▁█████████████",
|
1038
|
+
"▁▁▁▁▁▁▁█████████████",
|
1039
|
+
"▁▁▁▁▁▁▁▁████████████",
|
1040
|
+
"▁▁▁▁▁▁▁▁████████████",
|
1041
|
+
"▁▁▁▁▁▁▁▁▁███████████",
|
1042
|
+
"▁▁▁▁▁▁▁▁▁███████████",
|
1043
|
+
"▁▁▁▁▁▁▁▁▁▁██████████",
|
1044
|
+
"▁▁▁▁▁▁▁▁▁▁██████████",
|
1045
|
+
"▁▁▁▁▁▁▁▁▁▁▁▁████████",
|
1046
|
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁███████",
|
1047
|
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁██████",
|
1048
|
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████",
|
1049
|
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████",
|
1050
|
+
"█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████",
|
1051
|
+
"██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███",
|
1052
|
+
"██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███",
|
1053
|
+
"███▁▁▁▁▁▁▁▁▁▁▁▁▁▁███",
|
1054
|
+
"████▁▁▁▁▁▁▁▁▁▁▁▁▁▁██",
|
1055
|
+
"█████▁▁▁▁▁▁▁▁▁▁▁▁▁▁█",
|
1056
|
+
"█████▁▁▁▁▁▁▁▁▁▁▁▁▁▁█",
|
1057
|
+
"██████▁▁▁▁▁▁▁▁▁▁▁▁▁█",
|
1058
|
+
"████████▁▁▁▁▁▁▁▁▁▁▁▁",
|
1059
|
+
"█████████▁▁▁▁▁▁▁▁▁▁▁",
|
1060
|
+
"█████████▁▁▁▁▁▁▁▁▁▁▁",
|
1061
|
+
"█████████▁▁▁▁▁▁▁▁▁▁▁",
|
1062
|
+
"█████████▁▁▁▁▁▁▁▁▁▁▁",
|
1063
|
+
"███████████▁▁▁▁▁▁▁▁▁",
|
1064
|
+
"████████████▁▁▁▁▁▁▁▁",
|
1065
|
+
"████████████▁▁▁▁▁▁▁▁",
|
1066
|
+
"██████████████▁▁▁▁▁▁",
|
1067
|
+
"██████████████▁▁▁▁▁▁",
|
1068
|
+
"▁██████████████▁▁▁▁▁",
|
1069
|
+
"▁██████████████▁▁▁▁▁",
|
1070
|
+
"▁▁▁█████████████▁▁▁▁",
|
1071
|
+
"▁▁▁▁▁████████████▁▁▁",
|
1072
|
+
"▁▁▁▁▁████████████▁▁▁",
|
1073
|
+
"▁▁▁▁▁▁███████████▁▁▁",
|
1074
|
+
"▁▁▁▁▁▁▁▁█████████▁▁▁",
|
1075
|
+
"▁▁▁▁▁▁▁▁█████████▁▁▁",
|
1076
|
+
"▁▁▁▁▁▁▁▁▁█████████▁▁",
|
1077
|
+
"▁▁▁▁▁▁▁▁▁█████████▁▁",
|
1078
|
+
"▁▁▁▁▁▁▁▁▁▁█████████▁",
|
1079
|
+
"▁▁▁▁▁▁▁▁▁▁▁████████▁",
|
1080
|
+
"▁▁▁▁▁▁▁▁▁▁▁████████▁",
|
1081
|
+
"▁▁▁▁▁▁▁▁▁▁▁▁███████▁",
|
1082
|
+
"▁▁▁▁▁▁▁▁▁▁▁▁███████▁",
|
1083
|
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁███████",
|
1084
|
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁███████",
|
1085
|
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████",
|
1086
|
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████",
|
1087
|
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████",
|
1088
|
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████",
|
1089
|
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███",
|
1090
|
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███",
|
1091
|
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██",
|
1092
|
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██",
|
1093
|
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██",
|
1094
|
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█",
|
1095
|
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█",
|
1096
|
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█",
|
1097
|
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
1098
|
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
1099
|
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁",
|
1100
|
+
"▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁"
|
1101
|
+
]
|
1102
|
+
},
|
737
1103
|
"moon": {
|
738
1104
|
"interval": 80,
|
739
1105
|
"frames": [
|
@@ -819,5 +1185,231 @@
|
|
819
1185
|
"▐_/|___________▌",
|
820
1186
|
"▐/|____________▌"
|
821
1187
|
]
|
1188
|
+
},
|
1189
|
+
"dqpb": {
|
1190
|
+
"interval": 100,
|
1191
|
+
"frames": [
|
1192
|
+
"d",
|
1193
|
+
"q",
|
1194
|
+
"p",
|
1195
|
+
"b"
|
1196
|
+
]
|
1197
|
+
},
|
1198
|
+
"weather": {
|
1199
|
+
"interval": 100,
|
1200
|
+
"frames": [
|
1201
|
+
"☀️ ",
|
1202
|
+
"☀️ ",
|
1203
|
+
"☀️ ",
|
1204
|
+
"🌤 ",
|
1205
|
+
"⛅️ ",
|
1206
|
+
"🌥 ",
|
1207
|
+
"☁️ ",
|
1208
|
+
"🌧 ",
|
1209
|
+
"🌨 ",
|
1210
|
+
"🌧 ",
|
1211
|
+
"🌨 ",
|
1212
|
+
"🌧 ",
|
1213
|
+
"🌨 ",
|
1214
|
+
"⛈ ",
|
1215
|
+
"🌨 ",
|
1216
|
+
"🌧 ",
|
1217
|
+
"🌨 ",
|
1218
|
+
"☁️ ",
|
1219
|
+
"🌥 ",
|
1220
|
+
"⛅️ ",
|
1221
|
+
"🌤 ",
|
1222
|
+
"☀️ ",
|
1223
|
+
"☀️ "
|
1224
|
+
]
|
1225
|
+
},
|
1226
|
+
"christmas": {
|
1227
|
+
"interval": 400,
|
1228
|
+
"frames": [
|
1229
|
+
"🌲",
|
1230
|
+
"🎄"
|
1231
|
+
]
|
1232
|
+
},
|
1233
|
+
"grenade": {
|
1234
|
+
"interval": 80,
|
1235
|
+
"frames": [
|
1236
|
+
"، ",
|
1237
|
+
"′ ",
|
1238
|
+
" ´ ",
|
1239
|
+
" ‾ ",
|
1240
|
+
" ⸌",
|
1241
|
+
" ⸊",
|
1242
|
+
" |",
|
1243
|
+
" ⁎",
|
1244
|
+
" ⁕",
|
1245
|
+
" ෴ ",
|
1246
|
+
" ⁓",
|
1247
|
+
" ",
|
1248
|
+
" ",
|
1249
|
+
" "
|
1250
|
+
]
|
1251
|
+
},
|
1252
|
+
"point": {
|
1253
|
+
"interval": 125,
|
1254
|
+
"frames": [
|
1255
|
+
"∙∙∙",
|
1256
|
+
"●∙∙",
|
1257
|
+
"∙●∙",
|
1258
|
+
"∙∙●",
|
1259
|
+
"∙∙∙"
|
1260
|
+
]
|
1261
|
+
},
|
1262
|
+
"layer": {
|
1263
|
+
"interval": 150,
|
1264
|
+
"frames": [
|
1265
|
+
"-",
|
1266
|
+
"=",
|
1267
|
+
"≡"
|
1268
|
+
]
|
1269
|
+
},
|
1270
|
+
"betaWave": {
|
1271
|
+
"interval": 80,
|
1272
|
+
"frames": [
|
1273
|
+
"ρββββββ",
|
1274
|
+
"βρβββββ",
|
1275
|
+
"ββρββββ",
|
1276
|
+
"βββρβββ",
|
1277
|
+
"ββββρββ",
|
1278
|
+
"βββββρβ",
|
1279
|
+
"ββββββρ"
|
1280
|
+
]
|
1281
|
+
},
|
1282
|
+
"fingerDance": {
|
1283
|
+
"interval": 160,
|
1284
|
+
"frames": [
|
1285
|
+
"🤘 ",
|
1286
|
+
"🤟 ",
|
1287
|
+
"🖖 ",
|
1288
|
+
"✋ ",
|
1289
|
+
"🤚 ",
|
1290
|
+
"👆 "
|
1291
|
+
]
|
1292
|
+
},
|
1293
|
+
"fistBump": {
|
1294
|
+
"interval": 80,
|
1295
|
+
"frames": [
|
1296
|
+
"🤜\u3000\u3000\u3000\u3000🤛 ",
|
1297
|
+
"🤜\u3000\u3000\u3000\u3000🤛 ",
|
1298
|
+
"🤜\u3000\u3000\u3000\u3000🤛 ",
|
1299
|
+
"\u3000🤜\u3000\u3000🤛\u3000 ",
|
1300
|
+
"\u3000\u3000🤜🤛\u3000\u3000 ",
|
1301
|
+
"\u3000🤜✨🤛\u3000\u3000 ",
|
1302
|
+
"🤜\u3000✨\u3000🤛\u3000 "
|
1303
|
+
]
|
1304
|
+
},
|
1305
|
+
"soccerHeader": {
|
1306
|
+
"interval": 80,
|
1307
|
+
"frames": [
|
1308
|
+
" 🧑⚽️ 🧑 ",
|
1309
|
+
"🧑 ⚽️ 🧑 ",
|
1310
|
+
"🧑 ⚽️ 🧑 ",
|
1311
|
+
"🧑 ⚽️ 🧑 ",
|
1312
|
+
"🧑 ⚽️ 🧑 ",
|
1313
|
+
"🧑 ⚽️ 🧑 ",
|
1314
|
+
"🧑 ⚽️🧑 ",
|
1315
|
+
"🧑 ⚽️ 🧑 ",
|
1316
|
+
"🧑 ⚽️ 🧑 ",
|
1317
|
+
"🧑 ⚽️ 🧑 ",
|
1318
|
+
"🧑 ⚽️ 🧑 ",
|
1319
|
+
"🧑 ⚽️ 🧑 "
|
1320
|
+
]
|
1321
|
+
},
|
1322
|
+
"mindblown": {
|
1323
|
+
"interval": 160,
|
1324
|
+
"frames": [
|
1325
|
+
"😐 ",
|
1326
|
+
"😐 ",
|
1327
|
+
"😮 ",
|
1328
|
+
"😮 ",
|
1329
|
+
"😦 ",
|
1330
|
+
"😦 ",
|
1331
|
+
"😧 ",
|
1332
|
+
"😧 ",
|
1333
|
+
"🤯 ",
|
1334
|
+
"💥 ",
|
1335
|
+
"✨ ",
|
1336
|
+
"\u3000 ",
|
1337
|
+
"\u3000 ",
|
1338
|
+
"\u3000 "
|
1339
|
+
]
|
1340
|
+
},
|
1341
|
+
"speaker": {
|
1342
|
+
"interval": 160,
|
1343
|
+
"frames": [
|
1344
|
+
"🔈 ",
|
1345
|
+
"🔉 ",
|
1346
|
+
"🔊 ",
|
1347
|
+
"🔉 "
|
1348
|
+
]
|
1349
|
+
},
|
1350
|
+
"orangePulse": {
|
1351
|
+
"interval": 100,
|
1352
|
+
"frames": [
|
1353
|
+
"🔸 ",
|
1354
|
+
"🔶 ",
|
1355
|
+
"🟠 ",
|
1356
|
+
"🟠 ",
|
1357
|
+
"🔶 "
|
1358
|
+
]
|
1359
|
+
},
|
1360
|
+
"bluePulse": {
|
1361
|
+
"interval": 100,
|
1362
|
+
"frames": [
|
1363
|
+
"🔹 ",
|
1364
|
+
"🔷 ",
|
1365
|
+
"🔵 ",
|
1366
|
+
"🔵 ",
|
1367
|
+
"🔷 "
|
1368
|
+
]
|
1369
|
+
},
|
1370
|
+
"orangeBluePulse": {
|
1371
|
+
"interval": 100,
|
1372
|
+
"frames": [
|
1373
|
+
"🔸 ",
|
1374
|
+
"🔶 ",
|
1375
|
+
"🟠 ",
|
1376
|
+
"🟠 ",
|
1377
|
+
"🔶 ",
|
1378
|
+
"🔹 ",
|
1379
|
+
"🔷 ",
|
1380
|
+
"🔵 ",
|
1381
|
+
"🔵 ",
|
1382
|
+
"🔷 "
|
1383
|
+
]
|
1384
|
+
},
|
1385
|
+
"timeTravel": {
|
1386
|
+
"interval": 100,
|
1387
|
+
"frames": [
|
1388
|
+
"🕛 ",
|
1389
|
+
"🕚 ",
|
1390
|
+
"🕙 ",
|
1391
|
+
"🕘 ",
|
1392
|
+
"🕗 ",
|
1393
|
+
"🕖 ",
|
1394
|
+
"🕕 ",
|
1395
|
+
"🕔 ",
|
1396
|
+
"🕓 ",
|
1397
|
+
"🕒 ",
|
1398
|
+
"🕑 ",
|
1399
|
+
"🕐 "
|
1400
|
+
]
|
1401
|
+
},
|
1402
|
+
"aesthetic": {
|
1403
|
+
"interval": 80,
|
1404
|
+
"frames": [
|
1405
|
+
"▰▱▱▱▱▱▱",
|
1406
|
+
"▰▰▱▱▱▱▱",
|
1407
|
+
"▰▰▰▱▱▱▱",
|
1408
|
+
"▰▰▰▰▱▱▱",
|
1409
|
+
"▰▰▰▰▰▱▱",
|
1410
|
+
"▰▰▰▰▰▰▱",
|
1411
|
+
"▰▰▰▰▰▰▰",
|
1412
|
+
"▰▱▱▱▱▱▱"
|
1413
|
+
]
|
822
1414
|
}
|
823
1415
|
}
|
@@ -171,5 +171,104 @@
|
|
171
171
|
"😿",
|
172
172
|
"🙀"
|
173
173
|
]
|
174
|
+
},
|
175
|
+
"card": {
|
176
|
+
"interval": 90,
|
177
|
+
"stop": "🂠",
|
178
|
+
"frames": [
|
179
|
+
"🃁", "🃂", "🃃", "🃄", "🃅", "🃆", "🃇", "🃈", "🃉", "🃊", "🃋", "🃌", "🃍", "🃎",
|
180
|
+
"🂱", "🂲", "🂳", "🂴", "🂵", "🂶", "🂷", "🂸", "🂹", "🂺", "🂻", "🂼", "🂽", "🂾",
|
181
|
+
"🂡", "🂢", "🂣", "🂤", "🂥", "🂦", "🂧", "🂨", "🂩", "🂪", "🂫", "🂬", "🂭", "🂮",
|
182
|
+
"🃑", "🃒", "🃓", "🃔", "🃕", "🃖", "🃗", "🃘", "🃙", "🃚", "🃛", "🃜", "🃝", "🃞"
|
183
|
+
]
|
184
|
+
},
|
185
|
+
"cloud": {
|
186
|
+
"interval": 140,
|
187
|
+
"frames": [
|
188
|
+
"🌥",
|
189
|
+
"🌦",
|
190
|
+
"🌧",
|
191
|
+
"🌨",
|
192
|
+
"🌩",
|
193
|
+
"🌪"
|
194
|
+
]
|
195
|
+
},
|
196
|
+
"photo": {
|
197
|
+
"interval": 200,
|
198
|
+
"frames": [
|
199
|
+
"📷",
|
200
|
+
"📸"
|
201
|
+
]
|
202
|
+
},
|
203
|
+
"banknote": {
|
204
|
+
"interval": 100,
|
205
|
+
"frames": [
|
206
|
+
"💴",
|
207
|
+
"💵",
|
208
|
+
"💶",
|
209
|
+
"💷"
|
210
|
+
]
|
211
|
+
},
|
212
|
+
"white_square": {
|
213
|
+
"interval": 100,
|
214
|
+
"mode": "swing",
|
215
|
+
"frames": [
|
216
|
+
"🞓",
|
217
|
+
"🞒",
|
218
|
+
"🞑",
|
219
|
+
"🞐",
|
220
|
+
"🞏",
|
221
|
+
"🞎",
|
222
|
+
"🞔"
|
223
|
+
]
|
224
|
+
},
|
225
|
+
"xberg": {
|
226
|
+
"interval": 150,
|
227
|
+
"mode": "random",
|
228
|
+
"frames": [
|
229
|
+
"⨯",
|
230
|
+
"⛰",
|
231
|
+
"⛰",
|
232
|
+
"⛰",
|
233
|
+
"⛰",
|
234
|
+
"⛰",
|
235
|
+
"⛰"
|
236
|
+
]
|
237
|
+
},
|
238
|
+
"circled_letter": {
|
239
|
+
"interval": 120,
|
240
|
+
"mode": "random",
|
241
|
+
"frames": [
|
242
|
+
"Ⓐ", "Ⓑ", "Ⓒ", "Ⓓ", "Ⓔ", "Ⓕ", "Ⓖ", "Ⓗ", "Ⓘ",
|
243
|
+
"Ⓙ", "Ⓚ", "Ⓛ", "Ⓜ", "Ⓝ", "Ⓞ", "Ⓟ", "Ⓠ", "Ⓡ",
|
244
|
+
"Ⓢ", "Ⓣ", "Ⓤ", "Ⓥ", "Ⓦ", "Ⓧ", "Ⓨ", "Ⓩ"
|
245
|
+
]
|
246
|
+
},
|
247
|
+
"circled_number": {
|
248
|
+
"interval": 120,
|
249
|
+
"mode": "random",
|
250
|
+
"frames": [
|
251
|
+
"①", "②", "③", "④", "⑤", "⑥", "⑦", "⑧", "⑨"
|
252
|
+
]
|
253
|
+
},
|
254
|
+
"letter_with_parens": {
|
255
|
+
"interval": 150,
|
256
|
+
"mode": "random",
|
257
|
+
"frames": [
|
258
|
+
"🄐", "🄑", "🄒", "🄓", "🄔", "🄕", "🄖", "🄗", "🄘",
|
259
|
+
"🄙", "🄚", "🄛", "🄜", "🄝", "🄞", "🄟", "🄠", "🄡",
|
260
|
+
"🄢", "🄣", "🄤", "🄥", "🄦", "🄧", "🄨", "🄩"
|
261
|
+
]
|
262
|
+
},
|
263
|
+
"starlike": {
|
264
|
+
"interval": 120,
|
265
|
+
"mode": "random",
|
266
|
+
"frames": [
|
267
|
+
"✩", "✪", "✫", "✬", "✭", "✮", "✯", "✰",
|
268
|
+
"✱", "✲", "✳", "✴", "✵", "✶", "✷", "✸",
|
269
|
+
"✹", "✺", "✻", "✼", "✽", "✾", "✿", "❀",
|
270
|
+
"❁", "❂", "❃", "❄", "❅", "❆", "❇", "❈",
|
271
|
+
"❉", "❊"
|
272
|
+
]
|
174
273
|
}
|
175
274
|
}
|
data/examples/euruko.rb
CHANGED
@@ -45,7 +45,7 @@ sleep 5
|
|
45
45
|
print "\033c"
|
46
46
|
puts Paint["Pong", :underline]
|
47
47
|
|
48
|
-
Whirly.start spinner: "pong",
|
48
|
+
Whirly.start spinner: "pong", color: false, status: "Two computers in a game of Pong" do
|
49
49
|
sleep 9
|
50
50
|
end
|
51
51
|
|
data/examples/single.rb
CHANGED
data/lib/whirly.rb
CHANGED
@@ -133,13 +133,6 @@ module Whirly
|
|
133
133
|
# optionally overwrite configuration on start
|
134
134
|
configure(**options)
|
135
135
|
|
136
|
-
# ensure cursor is visible after exit the program (only register for the very first time)
|
137
|
-
if (!defined?(@at_exit_handler_registered) || !@at_exit_handler_registered) && @options[:hide_cursor]
|
138
|
-
@at_exit_handler_registered = true
|
139
|
-
stream = @options[:stream]
|
140
|
-
at_exit{ stream.print CLI_COMMANDS[:show_cursor] }
|
141
|
-
end
|
142
|
-
|
143
136
|
# only enable once
|
144
137
|
return false if defined?(@enabled) && @enabled
|
145
138
|
|
@@ -149,6 +142,13 @@ module Whirly
|
|
149
142
|
# only do something if we are on a real terminal (or forced)
|
150
143
|
return false unless @options[:stream].tty? || @options[:non_tty]
|
151
144
|
|
145
|
+
# ensure cursor is visible after exit the program (only register for the very first time)
|
146
|
+
if (!defined?(@at_exit_handler_registered) || !@at_exit_handler_registered) && @options[:hide_cursor]
|
147
|
+
@at_exit_handler_registered = true
|
148
|
+
stream = @options[:stream]
|
149
|
+
at_exit{ stream.print CLI_COMMANDS[:show_cursor] }
|
150
|
+
end
|
151
|
+
|
152
152
|
# init color
|
153
153
|
initialize_color if @options[:color]
|
154
154
|
|
@@ -167,8 +167,11 @@ module Whirly
|
|
167
167
|
|
168
168
|
# idiomatic block syntax support
|
169
169
|
if block_given?
|
170
|
-
|
171
|
-
|
170
|
+
begin
|
171
|
+
yield
|
172
|
+
ensure
|
173
|
+
Whirly.stop
|
174
|
+
end
|
172
175
|
end
|
173
176
|
|
174
177
|
true
|
@@ -176,12 +179,14 @@ module Whirly
|
|
176
179
|
|
177
180
|
def self.stop(stop_frame = nil)
|
178
181
|
return false unless @enabled
|
182
|
+
@enabled = false
|
183
|
+
return false unless @options[:stream].tty? || @options[:non_tty]
|
184
|
+
|
179
185
|
@thread.terminate if @thread
|
180
186
|
render(stop_frame || @stop) if stop_frame || @stop
|
181
187
|
unrender if @options[:remove_after_stop]
|
182
188
|
@options[:stream].puts if @options[:append_newline]
|
183
189
|
@options[:stream].print CLI_COMMANDS[:show_cursor] if @options[:hide_cursor]
|
184
|
-
@enabled = false
|
185
190
|
|
186
191
|
true
|
187
192
|
end
|
@@ -4,13 +4,9 @@ module Whirly
|
|
4
4
|
module Spinners
|
5
5
|
WHIRLY = {
|
6
6
|
"random_dots" => { "proc" => ->(){ [ 0x2800 + rand(256)].pack("U") }, "interval" => 100 },
|
7
|
-
"circled_letter" => { "proc" => ->(){ [ 0x24B6 + rand(26) ].pack("U") }, "interval" => 120 },
|
8
|
-
"circled_number" => { "proc" => ->(){ [ 0x2460 + rand(9) ].pack("U") }, "interval" => 120 },
|
9
|
-
"starlike" => { "proc" => ->(){ [ 0x2729 + rand(34) ].pack("U") }, "interval" => 120 },
|
10
7
|
"mahjong" => { "proc" => ->(){ [0x1F000 + rand(44)].pack("U") }, "interval" => 200 },
|
11
8
|
"domino" => { "proc" => ->(){ [0x1F030 + rand(50)].pack("U") }, "interval" => 200 },
|
12
|
-
"vertical_domino" => { "proc" => ->(){ [0x1F062 + rand(50)].pack("U") }, "interval" => 200 }
|
13
|
-
"letters_with_parens" => { "proc" => ->(){ [0x1F110 + rand(26)].pack("U") }, "interval" => 150 },
|
9
|
+
"vertical_domino" => { "proc" => ->(){ [0x1F062 + rand(50)].pack("U") }, "interval" => 200 }
|
14
10
|
}
|
15
11
|
WHIRLY.merge! JSON.load(File.read(File.dirname(__FILE__) + "/../../../data/whirly-static-spinners.json"))
|
16
12
|
|
data/lib/whirly/version.rb
CHANGED
data/spec/whirly_spec.rb
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
require_relative "../lib/whirly"
|
2
2
|
require "minitest/autorun"
|
3
|
+
require "paint"
|
3
4
|
# require "irbtools/binding"
|
4
5
|
require "stringio"
|
5
6
|
|
6
7
|
def short_sleep
|
7
|
-
sleep 0.
|
8
|
+
sleep 0.4
|
8
9
|
end
|
9
10
|
|
10
11
|
def medium_sleep
|
11
|
-
sleep 0.
|
12
|
+
sleep 0.7
|
12
13
|
end
|
13
14
|
|
14
15
|
def long_sleep
|
@@ -169,10 +170,10 @@ describe Whirly do
|
|
169
170
|
spinner = { "frames" => "A".."H", "mode" => "random", "interval" => 10 }
|
170
171
|
|
171
172
|
Whirly.start(spinner: spinner)
|
172
|
-
|
173
|
+
short_sleep
|
173
174
|
Whirly.stop
|
174
175
|
|
175
|
-
refute
|
176
|
+
refute /\A.*?A.*?B.*?C.*?D.*?E.*?F.*?G.*?H/m =~ @capture.string
|
176
177
|
end
|
177
178
|
|
178
179
|
it "can be set to reverse" do
|
@@ -195,6 +196,91 @@ describe Whirly do
|
|
195
196
|
assert_match /A.*B.*C.*D.*E.*F.*G.*H.*G.*F.*E.*D.*C.*B.*A/m, @capture.string
|
196
197
|
end
|
197
198
|
end
|
199
|
+
|
200
|
+
describe "Interval" do
|
201
|
+
it "spins more often when interval is lower" do
|
202
|
+
capture1 = StringIO.new
|
203
|
+
Whirly.start(stream: capture1, interval: 100)
|
204
|
+
long_sleep
|
205
|
+
Whirly.stop
|
206
|
+
|
207
|
+
capture2 = StringIO.new
|
208
|
+
Whirly.start(stream: capture2, interval: 50)
|
209
|
+
long_sleep
|
210
|
+
Whirly.stop
|
211
|
+
|
212
|
+
assert capture1.string.size < capture2.string.size
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
describe "Colors" do
|
218
|
+
it "will use no color when :color option is falsey" do
|
219
|
+
Whirly.start(color: false)
|
220
|
+
short_sleep
|
221
|
+
Whirly.stop
|
222
|
+
|
223
|
+
refute /\[38;/ =~ @capture.string
|
224
|
+
end
|
225
|
+
|
226
|
+
it "will use color when :color option is truthy" do
|
227
|
+
Whirly.start(color: true)
|
228
|
+
short_sleep
|
229
|
+
Whirly.stop
|
230
|
+
|
231
|
+
assert /\[38;/ =~ @capture.string
|
232
|
+
end
|
233
|
+
|
234
|
+
it "defaults :color to true when the paint gem is available" do
|
235
|
+
Whirly.reset
|
236
|
+
Whirly.configure
|
237
|
+
assert Whirly.options[:color]
|
238
|
+
end
|
239
|
+
|
240
|
+
# it "defaults :color to true when the paint gem is not available" do
|
241
|
+
# remember_paint = Paint
|
242
|
+
# Object.send(:remove_const, :Paint)
|
243
|
+
# Whirly.reset
|
244
|
+
# Whirly.configure
|
245
|
+
# Object.send(:const_set, :Paint, remember_paint)
|
246
|
+
# refute Whirly.options[:color]
|
247
|
+
# end
|
248
|
+
|
249
|
+
it "changes the the color" do
|
250
|
+
Whirly.start
|
251
|
+
long_sleep
|
252
|
+
Whirly.stop
|
253
|
+
|
254
|
+
colors = @capture.string.scan(/\[38;.*?m/).flatten
|
255
|
+
assert colors.uniq.size > 1
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
describe "Cursor" do
|
260
|
+
it "hides (and later shows) cursor when :hide_cursor => true option is given (default)" do
|
261
|
+
Whirly.start(hide_cursor: true)
|
262
|
+
short_sleep
|
263
|
+
Whirly.stop
|
264
|
+
|
265
|
+
assert_match /\[?25l.*\[?25h/m, @capture.string
|
266
|
+
end
|
267
|
+
|
268
|
+
it "does not hide cursor when :hide_cursor => false option is given" do
|
269
|
+
Whirly.start(hide_cursor: false)
|
270
|
+
short_sleep
|
271
|
+
Whirly.stop
|
272
|
+
|
273
|
+
refute /\[?25l.*\[?25h/m =~ @capture.string
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
describe "Spinner Packs" do
|
278
|
+
it "can be passed an alternative set of :spinner_packs" do
|
279
|
+
assert_raises ArgumentError do
|
280
|
+
Whirly.start(spinner_packs: [:cli], spinner: "cat") # whirly is part of :whirly, but not of :cli
|
281
|
+
Whirly.stop
|
282
|
+
end
|
283
|
+
end
|
198
284
|
end
|
199
285
|
|
200
286
|
describe "Ansi Escape Mode" do
|
@@ -213,6 +299,34 @@ describe Whirly do
|
|
213
299
|
end
|
214
300
|
end
|
215
301
|
|
302
|
+
describe "Streams and TTYs" do
|
303
|
+
it "will not output anything on non-ttys" do
|
304
|
+
Whirly.reset
|
305
|
+
@capture = StringIO.new
|
306
|
+
Whirly.start(stream: @capture)
|
307
|
+
short_sleep
|
308
|
+
Whirly.stop
|
309
|
+
assert_equal "", @capture.string
|
310
|
+
end
|
311
|
+
|
312
|
+
it "will output something on non-ttys when :non_tty => true option is given" do
|
313
|
+
Whirly.reset
|
314
|
+
@capture = StringIO.new
|
315
|
+
Whirly.start(stream: @capture, non_tty: true)
|
316
|
+
short_sleep
|
317
|
+
Whirly.stop
|
318
|
+
refute_equal "", @capture.string
|
319
|
+
end
|
320
|
+
|
321
|
+
it "can be configured to which stream whirly's output goes" do
|
322
|
+
iolike = StringIO.new
|
323
|
+
Whirly.start(stream: iolike, non_tty: true)
|
324
|
+
short_sleep
|
325
|
+
Whirly.stop
|
326
|
+
refute_equal "", iolike.string
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
216
330
|
describe "Positioning" do
|
217
331
|
it "will render spinner 1 line further below (useful for spinning while git cloning)" do
|
218
332
|
Whirly.start(position: "below")
|
@@ -262,5 +376,18 @@ describe Whirly do
|
|
262
376
|
refute_predicate Whirly, :enabled?
|
263
377
|
end
|
264
378
|
end
|
265
|
-
end
|
266
379
|
|
380
|
+
describe "Error Handling" do
|
381
|
+
it "stops the spinner, when the main thread threw an exception [gh#3]" do
|
382
|
+
begin
|
383
|
+
Whirly.start status: "working" do
|
384
|
+
short_sleep
|
385
|
+
raise 'error!'
|
386
|
+
end
|
387
|
+
rescue
|
388
|
+
end
|
389
|
+
|
390
|
+
refute_predicate Whirly, :enabled?
|
391
|
+
end
|
392
|
+
end
|
393
|
+
end
|
data/whirly.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.summary = "Whirly: The friendly terminal spinner"
|
9
9
|
gem.description = "Simple terminal spinner with support for custom spinners. Includes spinners from npm's cli-spinners."
|
10
10
|
gem.authors = ["Jan Lelis"]
|
11
|
-
gem.email = ["
|
11
|
+
gem.email = ["hi@ruby.consulting"]
|
12
12
|
gem.homepage = "https://github.com/janlelis/whirly"
|
13
13
|
gem.license = "MIT"
|
14
14
|
|
@@ -20,7 +20,7 @@ Gem::Specification.new do |gem|
|
|
20
20
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
21
21
|
gem.require_paths = ["lib"]
|
22
22
|
|
23
|
-
gem.add_dependency "unicode-display_width", "
|
23
|
+
gem.add_dependency "unicode-display_width", ">= 1.1"
|
24
24
|
|
25
|
-
gem.required_ruby_version = "
|
25
|
+
gem.required_ruby_version = ">= 2.0", "< 4.0"
|
26
26
|
end
|
metadata
CHANGED
@@ -1,40 +1,39 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whirly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Lelis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unicode-display_width
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.1'
|
27
27
|
description: Simple terminal spinner with support for custom spinners. Includes spinners
|
28
28
|
from npm's cli-spinners.
|
29
29
|
email:
|
30
|
-
-
|
30
|
+
- hi@ruby.consulting
|
31
31
|
executables: []
|
32
32
|
extensions: []
|
33
33
|
extra_rdoc_files: []
|
34
34
|
files:
|
35
35
|
- ".gitignore"
|
36
36
|
- ".gitmodules"
|
37
|
-
- ".travis.yml"
|
38
37
|
- CHANGELOG.md
|
39
38
|
- CODE_OF_CONDUCT.md
|
40
39
|
- Gemfile
|
@@ -68,17 +67,19 @@ require_paths:
|
|
68
67
|
- lib
|
69
68
|
required_ruby_version: !ruby/object:Gem::Requirement
|
70
69
|
requirements:
|
71
|
-
- - "
|
70
|
+
- - ">="
|
72
71
|
- !ruby/object:Gem::Version
|
73
72
|
version: '2.0'
|
73
|
+
- - "<"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '4.0'
|
74
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
77
|
requirements:
|
76
78
|
- - ">="
|
77
79
|
- !ruby/object:Gem::Version
|
78
80
|
version: '0'
|
79
81
|
requirements: []
|
80
|
-
|
81
|
-
rubygems_version: 2.4.8
|
82
|
+
rubygems_version: 3.2.3
|
82
83
|
signing_key:
|
83
84
|
specification_version: 4
|
84
85
|
summary: 'Whirly: The friendly terminal spinner'
|
data/.travis.yml
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
sudo: false
|
2
|
-
language: ruby
|
3
|
-
|
4
|
-
script: bundle exec ruby spec/whirly_spec.rb
|
5
|
-
|
6
|
-
rvm:
|
7
|
-
- 2.3.0
|
8
|
-
- 2.2
|
9
|
-
- 2.1
|
10
|
-
- 2.0
|
11
|
-
- ruby-head
|
12
|
-
- rbx-2
|
13
|
-
- jruby-head
|
14
|
-
- jruby-9000
|
15
|
-
|
16
|
-
cache:
|
17
|
-
- bundler
|
18
|
-
|
19
|
-
# matrix:
|
20
|
-
# fast_finish: true
|
21
|
-
|
22
|
-
matrix:
|
23
|
-
allow_failures:
|
24
|
-
- rvm: jruby-head
|
25
|
-
- rvm: jruby-9000
|
26
|
-
- rvm: rbx-2
|