murano-cli-whirly 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.gitmodules +3 -0
- data/.travis.yml +21 -0
- data/CHANGELOG.md +60 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +8 -0
- data/MIT-LICENSE.txt +20 -0
- data/README.md +258 -0
- data/Rakefile +62 -0
- data/data/cli-spinners.json +874 -0
- data/data/whirly-static-spinners.json +274 -0
- data/examples/all_spinners.rb +21 -0
- data/examples/asciinema_bundled_spinners.rb +12 -0
- data/examples/euruko.rb +79 -0
- data/examples/multi_lines.rb +20 -0
- data/examples/single.rb +6 -0
- data/examples/status.rb +7 -0
- data/lib/murano-cli-whirly.rb +271 -0
- data/lib/murano-cli-whirly/spinners.rb +7 -0
- data/lib/murano-cli-whirly/spinners/cli.rb +7 -0
- data/lib/murano-cli-whirly/spinners/whirly.rb +15 -0
- data/lib/murano-cli-whirly/version.rb +3 -0
- data/murano-cli-whirly.gemspec +30 -0
- data/spec/whirly_spec.rb +393 -0
- data/whirly.gif +0 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 07d88778f616ee041cc0757cf75013b23faef12388e1e9ca2e66eddbd88c4089
|
4
|
+
data.tar.gz: ae04b1bf9d187ca170557819af050f2903d287891f2a811c3fa35011d764759a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 49301a9492b1dbab3eec77ff4d3936f48229e29400dd52de9f5c4e34eedb8cb44ffe41e34ffba1d289113201aa7be71b283e2078c04f2d48834ae23fb168c1dc
|
7
|
+
data.tar.gz: 87933d100c893b224bff26d3d16cdd385621b8d445afd6d799b00f597f4ec1d3ff8fee49f580c53d3cad538574043968c860b927e825cf28219282294bf44b0f
|
data/.gitignore
ADDED
data/.gitmodules
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
|
4
|
+
script: bundle exec ruby spec/whirly_spec.rb
|
5
|
+
|
6
|
+
rvm:
|
7
|
+
- 2.4.2
|
8
|
+
- 2.3.4
|
9
|
+
- 2.2
|
10
|
+
- 2.1
|
11
|
+
- 2.0
|
12
|
+
- ruby-head
|
13
|
+
- jruby-head
|
14
|
+
- jruby-9.1.13.0
|
15
|
+
|
16
|
+
cache:
|
17
|
+
- bundler
|
18
|
+
|
19
|
+
matrix:
|
20
|
+
allow_failures:
|
21
|
+
- rvm: jruby-head
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
## CHANGELOG
|
2
|
+
|
3
|
+
### 0.2.7
|
4
|
+
|
5
|
+
- Strip color codes before calculating frame length being cleared
|
6
|
+
|
7
|
+
### 0.2.6
|
8
|
+
|
9
|
+
- Update CLI spinners to 1.1.0 (adds "weather" and "christmas")
|
10
|
+
|
11
|
+
### 0.2.5
|
12
|
+
|
13
|
+
- Update CLI spinners to 1.0.1
|
14
|
+
|
15
|
+
### 0.2.4
|
16
|
+
|
17
|
+
- Fix bug that the Whirly thread will also stop when main thread throws error
|
18
|
+
(patch by @monkbroc)
|
19
|
+
- New spinner: xberg
|
20
|
+
|
21
|
+
### 0.2.3
|
22
|
+
|
23
|
+
- Fix bug that in some cases whirly output would be shown on non-ttys
|
24
|
+
- New spinners: card, cloud, photo, banknote, white_square
|
25
|
+
|
26
|
+
### 0.2.2
|
27
|
+
|
28
|
+
- More emotions for whirly (the spinner)
|
29
|
+
- Add cat spinner
|
30
|
+
|
31
|
+
### 0.2.1
|
32
|
+
|
33
|
+
- Use macOS terminal app compatible ANSI sequences
|
34
|
+
|
35
|
+
### 0.2.0
|
36
|
+
|
37
|
+
- Make paint dependency optional
|
38
|
+
- Remove pause feature
|
39
|
+
- Separate configuring into its own method, remember whirly's configuration, can be cleared with the new .reset method
|
40
|
+
- Introduce "stop" frames to display when spinner is over
|
41
|
+
- Different newline behaviour; append newline by default after spinner ran. Use position: "below" for old behaviour
|
42
|
+
- Support multiple frame modes: "linear", "random", "reverse", "swing"
|
43
|
+
- Proper unrendering (use unicode-display\_width)
|
44
|
+
- Introduce spinner packs (to deal with eventual name conflicts, currently: whirly + cli)
|
45
|
+
- Add more bundled spinners
|
46
|
+
- Update CLI spinners to v0.3.0 (two new spinners)
|
47
|
+
- Rename option :use\_color to just :color
|
48
|
+
- Option to set spinner can also take frames or proc directly
|
49
|
+
- Add ANSI escape mode option
|
50
|
+
- Add remove\_after\_stop option
|
51
|
+
|
52
|
+
### 0.1.1
|
53
|
+
|
54
|
+
- `non_tty` option to force TTY behaviour (whirly deactivates itself for non TTY by default)
|
55
|
+
- Allow passing in spinner hashes instead of only spinner names
|
56
|
+
|
57
|
+
### 0.1.0
|
58
|
+
|
59
|
+
- Initial release
|
60
|
+
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at opensource@janlelis.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/MIT-LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2016 Jan Lelis, mail@janlelis.de
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,258 @@
|
|
1
|
+
# Whirly 😀 [![[version]](https://badge.fury.io/rb/whirly.svg)](http://badge.fury.io/rb/whirly) [![[travis]](https://travis-ci.org/janlelis/whirly.svg)](https://travis-ci.org/janlelis/whirly)
|
2
|
+
|
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
|
+
|
5
|
+
## Demonstration
|
6
|
+
|
7
|
+
![](whirly.gif)
|
8
|
+
|
9
|
+
### Bundled Whirly Spinners
|
10
|
+
|
11
|
+
[Play on asciinema](https://asciinema.org/a/88198?size=big)
|
12
|
+
|
13
|
+
### Bundled Spinners from CLI Spinners
|
14
|
+
|
15
|
+
![](https://raw.githubusercontent.com/sindresorhus/cli-spinners/master/screenshot.gif)
|
16
|
+
|
17
|
+
[Play on asciinema](https://asciinema.org/a/9mlcoussb137m32swwuqtb2p1?size=big)
|
18
|
+
|
19
|
+
## Setup
|
20
|
+
|
21
|
+
Add to your `Gemfile`:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
gem 'whirly'
|
25
|
+
gem 'paint' # makes whirly colorful (recommended)
|
26
|
+
```
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
### Basic Usage
|
31
|
+
|
32
|
+
The spinner is shown while the block executes:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
Whirly.start do
|
36
|
+
# do the heavy work here
|
37
|
+
sleep 5
|
38
|
+
end
|
39
|
+
```
|
40
|
+
|
41
|
+
You can update the spinner text from inside the block:
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
Whirly.start do
|
45
|
+
Whirly.status = "Set some text to display alongside the spinner symbol"
|
46
|
+
sleep 3
|
47
|
+
Whirly.status = "Update it"
|
48
|
+
sleep 2
|
49
|
+
end
|
50
|
+
```
|
51
|
+
|
52
|
+
If you want to avoid the block syntax, you can also stop it manually:
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
Whirly.start
|
56
|
+
sleep 5
|
57
|
+
Whirly.stop
|
58
|
+
```
|
59
|
+
|
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
|
+
|
62
|
+
```ruby
|
63
|
+
Whirly.start spinner: "pong", color: false, status: "The Game of Pong" do
|
64
|
+
sleep 10
|
65
|
+
end
|
66
|
+
```
|
67
|
+
|
68
|
+
Also see the [examples directory](https://github.com/janlelis/whirly/tree/master/examples) for example scripts.
|
69
|
+
|
70
|
+
### Configuring Whirly
|
71
|
+
|
72
|
+
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`:
|
73
|
+
|
74
|
+
```ruby
|
75
|
+
Whirly.configure spinner: "dots"
|
76
|
+
|
77
|
+
Whirly.start do
|
78
|
+
sleep 3 # will use dots
|
79
|
+
end
|
80
|
+
|
81
|
+
Whirly.start do
|
82
|
+
sleep 3 # will use dots again
|
83
|
+
end
|
84
|
+
```
|
85
|
+
|
86
|
+
Call `.reset` to restore unconfigured behaviour:
|
87
|
+
|
88
|
+
```ruby
|
89
|
+
Whirly.configure spinner: "dots"
|
90
|
+
|
91
|
+
Whirly.reset
|
92
|
+
|
93
|
+
Whirly.start do
|
94
|
+
sleep 3 # will use default spinner
|
95
|
+
end
|
96
|
+
```
|
97
|
+
|
98
|
+
## Spinners
|
99
|
+
|
100
|
+
### Included Spinners
|
101
|
+
|
102
|
+
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.
|
103
|
+
|
104
|
+
## All `Whirly.start` / `Whirly.configure` Configuration Options
|
105
|
+
|
106
|
+
### Main Options
|
107
|
+
|
108
|
+
#### `spinner:`
|
109
|
+
|
110
|
+
*Default:* `"whirly"`
|
111
|
+
|
112
|
+
You have multiple ways of telling *Whirly* which spinner should be used. You can pass the following to the `spinner:` option:
|
113
|
+
|
114
|
+
- The name of a bundled spinner
|
115
|
+
- An array of spinner frames to use
|
116
|
+
- A proc which generates the frames dynamically
|
117
|
+
- A full spinner hash object ([explained below](https://github.com/janlelis/whirly#full-spinner-hash-format))
|
118
|
+
|
119
|
+
#### `status:`
|
120
|
+
|
121
|
+
*Default:* None
|
122
|
+
|
123
|
+
Allows you to directly set the first status text to display alongside the spinner icon.
|
124
|
+
|
125
|
+
#### `interval:`
|
126
|
+
|
127
|
+
*Default:* `100`
|
128
|
+
|
129
|
+
The number of milliseconds between changing to the next spinner icon frame.
|
130
|
+
|
131
|
+
### Advanced Options
|
132
|
+
|
133
|
+
#### `ambiguous_characters_width:`
|
134
|
+
|
135
|
+
*Default:* `1`
|
136
|
+
|
137
|
+
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.
|
138
|
+
|
139
|
+
#### `ansi_escape_mode:`
|
140
|
+
|
141
|
+
*Default:* `"restore"`
|
142
|
+
|
143
|
+
Can be set to `"line"` to use an different way of producing ANSI escape sequences necessary (experimental).
|
144
|
+
|
145
|
+
#### `append_newline:`
|
146
|
+
|
147
|
+
*Default:* `true`
|
148
|
+
|
149
|
+
When the Whirly block is over (or `.stop` was called), a `"\n"` will be outputted. Change to `false` to prevent this.
|
150
|
+
|
151
|
+
#### `color:`
|
152
|
+
|
153
|
+
*Default:* `!!defined?(Paint)`
|
154
|
+
|
155
|
+
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`.
|
156
|
+
|
157
|
+
#### `color_change_rate:`
|
158
|
+
|
159
|
+
*Default:* `30`
|
160
|
+
|
161
|
+
A value which describes how fast the color of the spinner icon changes.
|
162
|
+
|
163
|
+
#### `hide_cursor:`
|
164
|
+
|
165
|
+
*Default:* `true`
|
166
|
+
|
167
|
+
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`.
|
168
|
+
|
169
|
+
#### `mode:`
|
170
|
+
|
171
|
+
*Default:* `"linear"`
|
172
|
+
|
173
|
+
Instructs Whirly to play the frames in a different order. Possible values: `"linear"`, `"reverse"`, `"swing"`, and `"random"`. See [spinner format section](https://github.com/janlelis/whirly#mode-1) for more details.
|
174
|
+
|
175
|
+
#### `non_tty:`
|
176
|
+
|
177
|
+
*Default:* `false`
|
178
|
+
|
179
|
+
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`.
|
180
|
+
|
181
|
+
#### `position:`
|
182
|
+
|
183
|
+
*Default:* `"normal"`
|
184
|
+
|
185
|
+
You can set this to `"below"` to let Whirly appear one line below its normal position.
|
186
|
+
|
187
|
+
#### `remove_after_stop:`
|
188
|
+
|
189
|
+
*Default:* `false`
|
190
|
+
|
191
|
+
Causes the last frame to be removed after the spinner stopped.
|
192
|
+
|
193
|
+
#### `stop:`
|
194
|
+
|
195
|
+
*Default:* None
|
196
|
+
|
197
|
+
You can pass a custom frame to be used to end the animation, for example:
|
198
|
+
|
199
|
+
```ruby
|
200
|
+
Whirly.start spinner: "clock", interval: 1000, stop: "⏰" do
|
201
|
+
sleep 12
|
202
|
+
end
|
203
|
+
```
|
204
|
+
|
205
|
+
#### `spinner_packs:`
|
206
|
+
|
207
|
+
*Default:* `[:whirly, :cli]`
|
208
|
+
|
209
|
+
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.
|
210
|
+
|
211
|
+
#### `stream:`
|
212
|
+
|
213
|
+
*Default:* `$stdout`
|
214
|
+
|
215
|
+
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`.
|
216
|
+
|
217
|
+
## Full Spinner Hash Format
|
218
|
+
|
219
|
+
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.
|
220
|
+
|
221
|
+
### `"frames"`
|
222
|
+
|
223
|
+
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.
|
224
|
+
|
225
|
+
### `"proc"`
|
226
|
+
|
227
|
+
Instead of using `"frames"`: A proc which will generate the next frame with each call.
|
228
|
+
|
229
|
+
### `"interval"`
|
230
|
+
|
231
|
+
The number of milliseconds between changing to the next spinner icon frame.
|
232
|
+
|
233
|
+
### `"mode"`
|
234
|
+
|
235
|
+
The order in which frames should be played. It can be one of the following:
|
236
|
+
|
237
|
+
- `"linear"`: Cycle through all frames in normal order
|
238
|
+
- `"reverse"`: Cycle through all frames in reverse order
|
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
|
+
- `"random"`: Play random frames
|
241
|
+
|
242
|
+
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).
|
243
|
+
|
244
|
+
### `"stop"`
|
245
|
+
|
246
|
+
A frame to be used to end the spinner icon animation.
|
247
|
+
|
248
|
+
## Remarks, Troubleshooting, Caveats
|
249
|
+
|
250
|
+
- Interval is milliseconds, but don't rely on exact timing
|
251
|
+
- Will not do anything if stream is not a real console (or `non_tty: true` is passed)
|
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 substantly)
|
254
|
+
|
255
|
+
## MIT License
|
256
|
+
|
257
|
+
- Copyright (C) 2016 Jan Lelis <http://janlelis.com>. Released under the MIT license.
|
258
|
+
- Contains data from cli-spinners: MIT License, Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|