whirly 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f12112b921f3f00166d7acf85d4d86cac8836005
4
- data.tar.gz: ec7da03c93842811b381ca1fdfbe0df418ff05e1
3
+ metadata.gz: 49d0b7549d709f596eb1371e60ca6955f27f40ae
4
+ data.tar.gz: cedb70f10956ebb3197642ba3470435c4e9f7cf1
5
5
  SHA512:
6
- metadata.gz: eccb4074399d77acf9e4454fddc27b894d08506095285f4004271d116fa03e6450d2fe2cdd3a1ff6ca8a445b634a6e6ab32a379d8cb2c4b9edc0756cb2ae2a10
7
- data.tar.gz: 5a1e9ae823be1884e8e1f0e6783a63b2b540dbfe17d8e74c8cd6634949b69fa6df41d4cb0724fb47760b2fd45984d44c5729b5b8ef70174e264652d0cfce1d00
6
+ metadata.gz: 17b9d7c49c44f18471b72d4af58a5eea30da8a7b3a7a03b9ea38abed6324a09d8ec5a2238e9a9908f43c08c799fa93cc2f596f5762b11709d5f15f54f4ae8f3f
7
+ data.tar.gz: 7afee607c939d42eff7aa0f3d9bf68780c395896e46fb8bc830a2e195c4ce9babccbf41ff9ff5b108757d86b773256c3cf5fb9ec7496a92b587ed4836a286a92
data/.travis.yml CHANGED
@@ -18,3 +18,8 @@ cache:
18
18
 
19
19
  # matrix:
20
20
  # fast_finish: true
21
+
22
+ matrix:
23
+ allow_failures:
24
+ - rvm: jruby-head
25
+ - rvm: rbx-2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  ## CHANGELOG
2
2
 
3
+ ### 0.2.0
4
+
5
+ - Make paint dependency optional
6
+ - Remove pause feature
7
+ - Separate configuring into its own method, remember whirly's configuration, can be cleared with the new .reset method
8
+ - Introduce "stop" frames to display when spinner is over
9
+ - Different newline behaviour; append newline by default after spinner ran. Use position: "below" for old behaviour
10
+ - Support multiple frame modes: "linear", "random", "reverse", "swing"
11
+ - Proper unrendering (use unicode-display\_width)
12
+ - Introduce spinner packs (to deal with eventual name conflicts, currently: whirly + cli)
13
+ - Add more bundled spinners
14
+ - Update CLI spinners to v0.3.0 (two new spinners)
15
+ - Rename option :use\_color to just :color
16
+ - Option to set spinner can also take frames or proc directly
17
+ - Add ANSI escape mode option
18
+ - Add remove\_after\_stop option
19
+
3
20
  ### 0.1.1
4
21
 
5
22
  - `non_tty` option to force TTY behaviour (whirly deactivates itself for non TTY by default)
@@ -7,5 +24,5 @@
7
24
 
8
25
  ### 0.1.0
9
26
 
10
- - Inital release
27
+ - Initial release
11
28
 
data/Gemfile CHANGED
@@ -3,3 +3,4 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  gem 'minitest'
6
+ # gem 'irbtools-more', require: 'irbtools/binding'
data/README.md CHANGED
@@ -1,8 +1,17 @@
1
1
  # Whirly [![[version]](https://badge.fury.io/rb/whirly.svg)](http://badge.fury.io/rb/whirly) [![[travis]](https://travis-ci.org/janlelis/whirly.png)](https://travis-ci.org/janlelis/whirly)
2
2
 
3
- Whirly terminal spinner for Ruby, influenced by [ora](https://github.com/sindresorhus/ora), includes [cli-spinners](https://github.com/sindresorhus/cli-spinners).
3
+ A simple, colorful and customizable terminal spinner library for Ruby. It comes with 17 custom spinners and also includes those from the [cli-spinners](https://github.com/sindresorhus/cli-spinners) project.
4
4
 
5
- ALPHA RELEASE FOR EURUKO
5
+ ## Demonstration
6
+ ### Bundled Whirly Spinners
7
+
8
+ [Play on asciinema](https://asciinema.org/a/88198?size=big)
9
+
10
+ ### Bundled Spinners from CLI Spinners
11
+
12
+ ![](https://raw.githubusercontent.com/sindresorhus/cli-spinners/master/screenshot.gif)
13
+
14
+ [Play on asciinema](https://asciinema.org/a/9mlcoussb137m32swwuqtb2p1?size=big)
6
15
 
7
16
  ## Setup
8
17
 
@@ -17,26 +26,35 @@ gem 'paint' # makes whirly colorful (recommended)
17
26
 
18
27
  ### Basic Usage
19
28
 
29
+ The spinner is shown while the block executes:
30
+
20
31
  ```ruby
21
32
  Whirly.start do
22
- Whirly.status = "Working on it…"
33
+ # do the heavy work here
34
+ sleep 5
35
+ end
36
+ ```
37
+
38
+ You can update the spinner text from inside the block:
39
+
40
+ ```ruby
41
+ Whirly.start do
42
+ Whirly.status = "Set some text to display alongside the spinner symbol"
23
43
  sleep 3
24
- Whirly.status = "Almoste done…"
44
+ Whirly.status = "Update it"
25
45
  sleep 2
26
46
  end
27
47
  ```
28
48
 
29
- ### Non-Block Syntax, World Spinner
49
+ If you want to avoid the block syntax, you can also stop it manually:
30
50
 
31
51
  ```ruby
32
- Whirly.start spinner: "world"
33
- Whirly.status = "Working on it…"
34
- sleep 3
35
- Whirly.status = "Almoste done…"
52
+ Whirly.start
53
+ sleep 5
36
54
  Whirly.stop
37
55
  ```
38
56
 
39
- ### No Colors, Pong Spinner, Initial Status
57
+ 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.
40
58
 
41
59
  ```ruby
42
60
  Whirly.start spinner: "pong", use_color: false, status: "The Game of Pong" do
@@ -44,25 +62,189 @@ Whirly.start spinner: "pong", use_color: false, status: "The Game of Pong" do
44
62
  end
45
63
  ```
46
64
 
47
- ### Slower Interval, Don't Hide Cursor
65
+ ### Configuring Whirly
66
+
67
+ You can pass the same options you would pass to `.start` to `.configure` instead to create a persistent configuration that will be used by `.start`:
48
68
 
49
69
  ```ruby
50
- Whirly.start spinner: "clock", interval: 1000, hide_cursor: false do
51
- sleep 5
70
+ Whirly.configure spinner: "dots"
71
+
72
+ Whirly.start do
73
+ sleep 3 # will use dots
74
+ end
75
+
76
+ Whirly.start do
77
+ sleep 3 # will use dots again
78
+ end
79
+ ```
80
+
81
+ Call `.reset` to restore unconfigured behaviour:
82
+
83
+ ```ruby
84
+ Whirly.configure spinner: "dots"
85
+
86
+ Whirly.reset
87
+
88
+ Whirly.start do
89
+ sleep 3 # will use default spinner
90
+ end
91
+ ```
92
+
93
+ ## Spinners
94
+
95
+ ### Included Spinners
96
+
97
+ See [`data/whirly-static-spinnes.json`](https://github.com/janlelis/whirly/blob/master/data/whirly-static-spinners.json), [`lib/whirly/spinners/whirly.rb`](https://github.com/janlelis/whirly/blob/master/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/master/examples/all_spinners.rb) script.
98
+
99
+ ## All `Whirly.start` / `Whirly.configure` Configuration Options
100
+
101
+ ### Main Options
102
+
103
+ #### `spinner:`
104
+
105
+ You have multiple ways of telling *Whirly* which spinner should be used. You can pass the following to the `spinner:` option:
106
+
107
+ *Default:* `"whirly"`
108
+
109
+ - The name of a bundled spinner
110
+ - An array of spinner frames to use
111
+ - A proc which generates the frames dynamically
112
+ - A full spinner hash object ([explained below](https://github.com/janlelis/whirly#full-spinner-hash-format))
113
+
114
+ #### `status:`
115
+
116
+ *Default:* None
117
+
118
+ Allows you to directly set the first status text to display alongside the spinner icon.
119
+
120
+ #### `interval:`
121
+
122
+ *Default:* `100`
123
+
124
+ The number of milliseconds between changing to the next spinner icon frame.
125
+
126
+ ### Advanced Options
127
+
128
+ #### `ambiguous_characters_width:`
129
+
130
+ *Default:* `1`
131
+
132
+ If set to `2`, ambiguous Unicode charatcers will be treated as 2 colums wide. See [unicode-display_width](https://github.com/janlelis/unicode-display_width) for more details.
133
+
134
+ #### `ansi_escape_mode:`
135
+
136
+ *Default:* `"restore"`
137
+
138
+ Can be set to `"line"` to use an different way of producing ANSI escape sequences (experimental)
139
+
140
+ #### `append_newline:`
141
+
142
+ *Default:* `true`
143
+
144
+ When the Whirly block is over (or `.stop` was called), a `"\n"` will be outputted. Change to `false` to prevent this.
145
+
146
+ #### `color:`
147
+
148
+ *Default:* `!!defined?(Paint)`
149
+
150
+ This option is responsible for displaying the spinner icon in random colors. Set to `false` if you do not want this. Related option `:color_change_rate`.
151
+
152
+ #### `color_change_rate:`
153
+
154
+ *Default:* `30`
155
+
156
+ A value which describes how fast the color of the spinner icon changes.
157
+
158
+ #### `hide_cursor:`
159
+
160
+ *Default:* `true`
161
+
162
+ By default, the terminal cursor gets hidden while displaying the spinner. This also registers an `at_exit` callback, which always restores the cursor when exitting the program. If you do not want to hide the cursor, change this option to `false`.
163
+
164
+ #### `mode:`
165
+
166
+ *Default:* `"linear"`
167
+
168
+ Instructs Whirly to play the frames in a different order. Possible values: `"linear"`, `"reverse"`, `"swing"`, and `"random"`. See spinner format section for more details.
169
+
170
+ #### `non_tty:`
171
+
172
+ *Default:* `false`
173
+
174
+ Whirly only gets activated if the current process appears to be a real terminal. If you want to activate it for non-terimnals, set this option to `true`.
175
+
176
+ #### `position:`
177
+
178
+ *Default:* `"normal"`
179
+
180
+ You can set this to `"below"` to let Whirly appear one line below its normal position.
181
+
182
+ #### `remove_after_stop:`
183
+
184
+ *Default:* `"false"`
185
+
186
+ Causes the last frame to be removed after the spinner stopped.
187
+
188
+ #### `stop:`
189
+
190
+ *Default:* None
191
+
192
+ You can pass a custom frame to be used to end the animation, for example:
193
+
194
+ ```ruby
195
+ Whirly.start spinner: "clock", interval: 1000, stop: "⏰" do
196
+ sleep 12
52
197
  end
53
198
  ```
54
199
 
55
- ## Included Spinners & Custom Spinners
200
+ #### `spinner_packs:`
201
+
202
+ *Default:* `[:whirly, :cli]`
203
+
204
+ Whirly comes with spinners from different sources. This options defines which sources to consider (the value refers to an uppercased child constant of `Whirly::Spinners`) and in which order.
205
+
206
+ #### `stream:`
207
+
208
+ *Default:* `$stdout`
209
+
210
+ You can pass in an [IO](https://ruby-doc.org/core-2.3.1/IO.html)-like object, if you want to display *Whirly* on an other stream than `$stdout`.
211
+
212
+ ## Full Spinner Hash Format
213
+
214
+ A full spinner is defined by a hash which can have the following key-value pairs. Please note that in order to keep the format more portable, all keys are strings and not Ruby symbols. Except for `"frames"` and `"proc"`, all options are overwritable when starting/configuring Whirly. See the included spinners for example definitions of spinners.
215
+
216
+ ### `"frames"`
217
+
218
+ An [Array](https://ruby-doc.org/core-2.3.1/Array.html) or [Enumerable](https://ruby-doc.org/core-2.3.1/Enumerable.html) of strings that will be used as the spinner icon.
219
+
220
+ ### `"proc"`
221
+
222
+ Instead of using `"frames"`: A proc which will generate the next frame with each call.
223
+
224
+ ### `"interval"`
225
+
226
+ The number of milliseconds between changing to the next spinner icon frame.
227
+
228
+ ### `"mode"`
229
+
230
+ The order in which frames should be played. It can be one of the following:
231
+
232
+ - `"linear"`: Cycle through all frames in normal order
233
+ - `"reverse"`: Cycle through all frames in reverse order
234
+ - `"swing"`: Cycle through all frames in normal order, and then in reverse order, but only play first and last frame once each round
235
+ - `"random"`: Play random frames
236
+
237
+ Please note: While `"linear"` also works with frames that are just an [Enumerable](https://ruby-doc.org/core-2.3.1/Enumerable.html), all other frame modes require the object to be representable as an [Array](https://ruby-doc.org/core-2.3.1/Array.html).
238
+
239
+ ### `"stop"`
56
240
 
57
- - See `data/cursors.json`
58
- - Spinners are either an Array of frames or an enumerator [...]
59
- - Extra fun spinners :random_character, :random_emoticon (SOON)
241
+ A frame to be used to end the spinner icon animation.
60
242
 
61
243
  ## Remarks, Troubleshooting, Caveats
62
244
 
63
245
  - Interval is milliseconds, but don't rely on exact timing
64
- - Will not do anything if stream is not a real console
65
- - Colors not working? Be sure to include the [paint](https://github.com/janlelis/paint/) gem
246
+ - Will not do anything if stream is not a real console (or `non_tty: true` is passed)
247
+ - Colors not working? Be sure to include the [paint](https://github.com/janlelis/paint/) gem in your Gemfile
66
248
  - Don't set very short intervals (or it might affect performance substantly)
67
249
 
68
250
  ## MIT License
data/Rakefile CHANGED
@@ -30,10 +30,31 @@ task :irb do
30
30
  end
31
31
 
32
32
 
33
+ # # #
34
+ # Run Specs
35
+
36
+ desc "#{gemspec.name} | Spec"
37
+ task :spec do
38
+ sh "for file in spec/*.rb; do ruby $file; done"
39
+ end
40
+ task default: :spec
41
+
42
+
33
43
  # # #
34
44
  # Update spinners
45
+
35
46
  desc "Update spinners"
36
47
  task :update_spinners do
37
- sh "git submodule update"
38
- cp "data/external/cli-spinners/spinners.json", "data/spinners.json"
48
+ sh "git submodule update --recursive --remote"
49
+ cp "data/external/cli-spinners/spinners.json", "data/cli-spinners.json"
39
50
  end
51
+
52
+
53
+ # # #
54
+ # Record ASCIICAST
55
+
56
+ desc "Record an asciicast via asciinema"
57
+ task :record_acsiicast do
58
+ sh "cd && asciinema rec whirly-bundled-spinners-v0.2.0.json --title='Whirly v0.2.0 Bundled Spinners' --command='ruby #{File.dirname(__FILE__)}/examples/asciinema_bundled_spinners.rb'"
59
+ end
60
+
@@ -213,6 +213,67 @@
213
213
  "⠈"
214
214
  ]
215
215
  },
216
+ "dots12": {
217
+ "interval": 80,
218
+ "frames": [
219
+ "⢀⠀",
220
+ "⡀⠀",
221
+ "⠄⠀",
222
+ "⢂⠀",
223
+ "⡂⠀",
224
+ "⠅⠀",
225
+ "⢃⠀",
226
+ "⡃⠀",
227
+ "⠍⠀",
228
+ "⢋⠀",
229
+ "⡋⠀",
230
+ "⠍⠁",
231
+ "⢋⠁",
232
+ "⡋⠁",
233
+ "⠍⠉",
234
+ "⠋⠉",
235
+ "⠋⠉",
236
+ "⠉⠙",
237
+ "⠉⠙",
238
+ "⠉⠩",
239
+ "⠈⢙",
240
+ "⠈⡙",
241
+ "⢈⠩",
242
+ "⡀⢙",
243
+ "⠄⡙",
244
+ "⢂⠩",
245
+ "⡂⢘",
246
+ "⠅⡘",
247
+ "⢃⠨",
248
+ "⡃⢐",
249
+ "⠍⡐",
250
+ "⢋⠠",
251
+ "⡋⢀",
252
+ "⠍⡁",
253
+ "⢋⠁",
254
+ "⡋⠁",
255
+ "⠍⠉",
256
+ "⠋⠉",
257
+ "⠋⠉",
258
+ "⠉⠙",
259
+ "⠉⠙",
260
+ "⠉⠩",
261
+ "⠈⢙",
262
+ "⠈⡙",
263
+ "⠈⠩",
264
+ "⠀⢙",
265
+ "⠀⡙",
266
+ "⠀⠩",
267
+ "⠀⢘",
268
+ "⠀⡘",
269
+ "⠀⠨",
270
+ "⠀⢐",
271
+ "⠀⡐",
272
+ "⠀⠠",
273
+ "⠀⢀",
274
+ "⠀⡀"
275
+ ]
276
+ },
216
277
  "line": {
217
278
  "interval": 130,
218
279
  "frames": [
@@ -727,5 +788,36 @@
727
788
  "▐ ⡀ ▌",
728
789
  "▐⠠ ▌"
729
790
  ]
791
+ },
792
+ "shark": {
793
+ "interval": 120,
794
+ "frames": [
795
+ "▐|\\____________▌",
796
+ "▐_|\\___________▌",
797
+ "▐__|\\__________▌",
798
+ "▐___|\\_________▌",
799
+ "▐____|\\________▌",
800
+ "▐_____|\\_______▌",
801
+ "▐______|\\______▌",
802
+ "▐_______|\\_____▌",
803
+ "▐________|\\____▌",
804
+ "▐_________|\\___▌",
805
+ "▐__________|\\__▌",
806
+ "▐___________|\\_▌",
807
+ "▐____________|\\▌",
808
+ "▐____________/|▌",
809
+ "▐___________/|_▌",
810
+ "▐__________/|__▌",
811
+ "▐_________/|___▌",
812
+ "▐________/|____▌",
813
+ "▐_______/|_____▌",
814
+ "▐______/|______▌",
815
+ "▐_____/|_______▌",
816
+ "▐____/|________▌",
817
+ "▐___/|_________▌",
818
+ "▐__/|__________▌",
819
+ "▐_/|___________▌",
820
+ "▐/|____________▌"
821
+ ]
730
822
  }
731
823
  }