tty-spinner 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +34 -24
- data/lib/tty/spinner/version.rb +1 -1
- data/lib/tty/spinner.rb +12 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 806a1cadc39a03d6b98e3e365fd1c528cc250ae8
|
4
|
+
data.tar.gz: 05929fcc41b54e854a141ff8b52a599081acce85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f64c7e4b3d3acc4a9bc2bc688481d3146210498484931c22a0549494c3d494c198f17dd0457a567ede62fee8838431637e09395804e0735943edb87c32857ebc
|
7
|
+
data.tar.gz: 107b562da5049da6b968bd1ada2fc58521b949abcd225b4793d2f36a5d434ec4a9873895ebe6f937bdbdea2a5f25cfeb71c2c66c0f5221082479e9bac4056e35
|
data/README.md
CHANGED
@@ -39,14 +39,15 @@ Or install it yourself as:
|
|
39
39
|
* [1. Usage](#1-usage)
|
40
40
|
* [2. API](#2-api)
|
41
41
|
* [2.1 spin](#21-spin)
|
42
|
-
* [2.2
|
43
|
-
* [2.3
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
* [2.6
|
49
|
-
* [2.7
|
42
|
+
* [2.2 auto_spin](#22-auto_spin)
|
43
|
+
* [2.3 run](#23-run)
|
44
|
+
* [2.4 start](#24-start)
|
45
|
+
* [2.5 stop](#25-stop)
|
46
|
+
* [2.5.1 success](#251-success)
|
47
|
+
* [2.5.2 error](#252-error)
|
48
|
+
* [2.6 update](#26-update)
|
49
|
+
* [2.7 reset](#27-reset)
|
50
|
+
* [2.8 join](#28-join)
|
50
51
|
* [3. Configuration](#3-configuration)
|
51
52
|
* [3.1 :format](#31-format)
|
52
53
|
* [3.2 :frames](#32-frames)
|
@@ -108,17 +109,33 @@ loop do
|
|
108
109
|
end
|
109
110
|
```
|
110
111
|
|
111
|
-
### 2.2
|
112
|
+
### 2.2 auto_spin
|
112
113
|
|
113
|
-
To perform automatic spinning
|
114
|
+
To perform automatic spinning animation use `auto_spin` method like so:
|
114
115
|
|
115
116
|
```ruby
|
116
|
-
spinner.
|
117
|
+
spinner.auto_spin
|
117
118
|
```
|
118
119
|
|
119
120
|
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)).
|
120
121
|
|
121
|
-
### 2.3
|
122
|
+
### 2.3 run
|
123
|
+
|
124
|
+
Use `run` with a code block that will automatically display spinning animation while the block executes and finish animation when the block terminates. Optionally you can provide a stop message to display when animation is finished.
|
125
|
+
|
126
|
+
```ruby
|
127
|
+
spinner.run('Done!') { ... }
|
128
|
+
```
|
129
|
+
|
130
|
+
### 2.4 start
|
131
|
+
|
132
|
+
In order to set start time or reuse the same spinner after it has stopped, call `start` method:
|
133
|
+
|
134
|
+
```ruby
|
135
|
+
spinner.start
|
136
|
+
```
|
137
|
+
|
138
|
+
### 2.5 stop
|
122
139
|
|
123
140
|
In order to stop the spinner call `stop`. This will finish drawing the spinning animation and return to new line.
|
124
141
|
|
@@ -132,7 +149,7 @@ You can further pass a message to print when animation is finished.
|
|
132
149
|
spinner.stop('Done!')
|
133
150
|
```
|
134
151
|
|
135
|
-
#### 2.
|
152
|
+
#### 2.5.1 success
|
136
153
|
|
137
154
|
Use `success` call to stop the spinning animation and replace the spinning symbol with checkmark character to indicate successful completion.
|
138
155
|
|
@@ -147,7 +164,7 @@ This will produce:
|
|
147
164
|
[✔] Task name (successful)
|
148
165
|
```
|
149
166
|
|
150
|
-
#### 2.
|
167
|
+
#### 2.5.2 error
|
151
168
|
|
152
169
|
Use `error` call to stop the spining animation and replace the spinning symbol with cross character to indicate error completion.
|
153
170
|
|
@@ -162,15 +179,8 @@ This will produce:
|
|
162
179
|
[✖] Task name (error)
|
163
180
|
```
|
164
181
|
|
165
|
-
### 2.4 run
|
166
|
-
|
167
|
-
Use `run` with a code block that will automatically display spinning animation while the block executes and finish animation when the block terminates. Optionally you can provide a stop message to display when animation is finished.
|
168
|
-
|
169
|
-
```ruby
|
170
|
-
spinner.run('Done!') { ... }
|
171
|
-
```
|
172
182
|
|
173
|
-
### 2.
|
183
|
+
### 2.6 update
|
174
184
|
|
175
185
|
Use `update` call to dynamically change label name(s).
|
176
186
|
|
@@ -200,7 +210,7 @@ spinner.update(title: 'Downloading file2')
|
|
200
210
|
spinner.run { ... }
|
201
211
|
```
|
202
212
|
|
203
|
-
### 2.
|
213
|
+
### 2.7 reset
|
204
214
|
|
205
215
|
In order to reset the spinner to its initial frame do:
|
206
216
|
|
@@ -208,7 +218,7 @@ In order to reset the spinner to its initial frame do:
|
|
208
218
|
spinner.reset
|
209
219
|
```
|
210
220
|
|
211
|
-
### 2.
|
221
|
+
### 2.8 join
|
212
222
|
|
213
223
|
One way to wait while the spinning animates is to join the thread started with `start` method:
|
214
224
|
|
data/lib/tty/spinner/version.rb
CHANGED
data/lib/tty/spinner.rb
CHANGED
@@ -128,12 +128,20 @@ module TTY
|
|
128
128
|
self
|
129
129
|
end
|
130
130
|
|
131
|
-
# Start
|
131
|
+
# Start timer and unlock spinner
|
132
132
|
#
|
133
133
|
# @api public
|
134
134
|
def start
|
135
135
|
@started_at = Time.now
|
136
136
|
@done = false
|
137
|
+
reset
|
138
|
+
end
|
139
|
+
|
140
|
+
# Start automatic spinning animation
|
141
|
+
#
|
142
|
+
# @api public
|
143
|
+
def auto_spin
|
144
|
+
start
|
137
145
|
sleep_time = 1.0 / @interval
|
138
146
|
|
139
147
|
@thread = Thread.new do
|
@@ -155,8 +163,9 @@ module TTY
|
|
155
163
|
# spinner.run('Migrated DB') { ... }
|
156
164
|
#
|
157
165
|
# @api public
|
158
|
-
def run(stop_message =
|
159
|
-
|
166
|
+
def run(stop_message = '', &block)
|
167
|
+
auto_spin
|
168
|
+
|
160
169
|
@work = Thread.new(&block)
|
161
170
|
@work.join
|
162
171
|
ensure
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tty-spinner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Murach
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07
|
11
|
+
date: 2016-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|