tty 0.4.0 → 0.5.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/CHANGELOG.md +10 -0
- data/README.md +38 -38
- data/lib/tty/version.rb +1 -1
- data/tty.gemspec +6 -5
- metadata +25 -12
- data/benchmarks/shell.rb +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e76e7f5fabce92373a5d30470030bb32c3e385a2
|
4
|
+
data.tar.gz: e22d3ee873af12433ad048780519cdc7a25eccd6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92d6818d1d61b3e1dc4c66b6e62f39e85e43c2c295a312487ac77b468723ede92a917a5fb421bb67975b04d2e416dbf19f913668854da736add9ad966796014f
|
7
|
+
data.tar.gz: cfed541bea516a36e8568b9bce380dd3667bc107ea56f37553f9cd0bad27094a4569f3a358b4b34242919b224e63c92c3bf7d09a8326d9f893cf9fead22fa0f4
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
+
## [v0.5.0] - 2016-05-30
|
4
|
+
|
5
|
+
### Added
|
6
|
+
* Add tty-command dependency
|
7
|
+
|
8
|
+
### Changed
|
9
|
+
* Update tty-progressbar dependency
|
10
|
+
* Update tty-prompt dependency
|
11
|
+
* Update tty-spinner dependency
|
12
|
+
|
3
13
|
## [v0.4.0] - 2016-02-13
|
4
14
|
|
5
15
|
### Added
|
data/README.md
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
<div align="center">
|
2
|
-
<a href="http://
|
2
|
+
<a href="http://piotrmurach.github.io/tty"><img width="130" src="https://cdn.rawgit.com/piotrmurach/tty/master/images/tty.png" alt="tty logo" /></a>
|
3
3
|
</div>
|
4
4
|
<br/>
|
5
5
|
[][gem]
|
6
|
-
[][travis]
|
7
|
+
[][codeclimate]
|
8
|
+
[][coveralls]
|
9
|
+
[][inchpages]
|
10
|
+
[][gitter]
|
11
11
|
|
12
12
|
[gem]: http://badge.fury.io/rb/tty
|
13
|
-
[travis]: http://travis-ci.org/
|
14
|
-
[codeclimate]: https://codeclimate.com/github/
|
15
|
-
[coveralls]: https://coveralls.io/r/
|
16
|
-
[inchpages]: http://inch-ci.org/github/
|
17
|
-
[gitter]: https://gitter.im/
|
13
|
+
[travis]: http://travis-ci.org/piotrmurach/tty
|
14
|
+
[codeclimate]: https://codeclimate.com/github/piotrmurach/tty
|
15
|
+
[coveralls]: https://coveralls.io/r/piotrmurach/tty
|
16
|
+
[inchpages]: http://inch-ci.org/github/piotrmurach/tty
|
17
|
+
[gitter]: https://gitter.im/piotrmurach/tty
|
18
18
|
|
19
19
|
> TTY is a toolbox for developing beautiful command line clients in Ruby. It provides a fluid interface for gathering input from the user, querying system and terminal and displaying information back. It is not another command line options parser, rather a plumbing library that helps in common tasks.
|
20
20
|
|
@@ -156,18 +156,18 @@ print cursor.up(5) + cursor.forward(2)
|
|
156
156
|
|
157
157
|
## 2. Prompting for input
|
158
158
|
|
159
|
-
**TTY** relies on [tty-prompt](https://github.com/
|
159
|
+
**TTY** relies on [tty-prompt](https://github.com/piotrmurach/tty-prompt#ttyprompt) component for processing user input.
|
160
160
|
|
161
161
|
```ruby
|
162
162
|
prompt.ask('What is your name?', default: ENV['USER'])
|
163
163
|
# => What is your name? (piotr)
|
164
164
|
```
|
165
165
|
|
166
|
-
Please refer to [documentation](https://github.com/
|
166
|
+
Please refer to [documentation](https://github.com/piotrmurach/tty-prompt#contents) for complete API.
|
167
167
|
|
168
|
-
##
|
168
|
+
## 3. Drawing tables
|
169
169
|
|
170
|
-
**TTY** uses the [tty-table](https://github.com/
|
170
|
+
**TTY** uses the [tty-table](https://github.com/piotrmurach/tty-table) component in order to convert data into table and render as string output in tabular form. For example, to render data with ASCII border:
|
171
171
|
|
172
172
|
```ruby
|
173
173
|
table = TTY::Table.new ['header1','header2'], [['a1','a2'], ['b1','b2']]
|
@@ -181,11 +181,11 @@ table.render(:ascii)
|
|
181
181
|
+-------+-------+
|
182
182
|
```
|
183
183
|
|
184
|
-
Please refer to [documentation](https://github.com/
|
184
|
+
Please refer to [documentation](https://github.com/piotrmurach/tty-table) for complete API.
|
185
185
|
|
186
|
-
##
|
186
|
+
## 4. Drawing progress bars
|
187
187
|
|
188
|
-
In order to draw progress bars in terminal, **TTY** uses the [tty-progressbar](https://github.com/
|
188
|
+
In order to draw progress bars in terminal, **TTY** uses the [tty-progressbar](https://github.com/piotrmurach/tty-progressbar) component.
|
189
189
|
|
190
190
|
For example, to render basic download bar do:
|
191
191
|
|
@@ -194,34 +194,34 @@ bar = TTY::ProgressBar.new("downloading [:bar]", total: 30)
|
|
194
194
|
30.times { bar.advance }
|
195
195
|
```
|
196
196
|
|
197
|
-
Please refer to [documentation](https://github.com/
|
197
|
+
Please refer to [documentation](https://github.com/piotrmurach/tty-progressbar) for complete API.
|
198
198
|
|
199
|
-
##
|
199
|
+
## 5. Drawing spinners
|
200
200
|
|
201
|
-
**TTY** uses the [tty-spinner](https://github.com/
|
201
|
+
**TTY** uses the [tty-spinner](https://github.com/piotrmurach/tty-spinner) component to handle terminal spinning animation. For instance, to create a simple spinner do:
|
202
202
|
|
203
203
|
```ruby
|
204
|
-
spinner = TTY::Spinner.new(
|
204
|
+
spinner = TTY::Spinner.new("[:spinner] Loading ...", format: :pulse_2)
|
205
205
|
30.times { spinner.spin }
|
206
|
+
spinner.stop('Done!')
|
206
207
|
```
|
207
208
|
|
208
|
-
Please refer to [documentation](https://github.com/
|
209
|
-
|
209
|
+
Please refer to [documentation](https://github.com/piotrmurach/tty-spinner) for complete API.
|
210
210
|
|
211
211
|
## 6. Output coloring
|
212
212
|
|
213
|
-
In order to colorize strings, **TTY** uses the [pastel](https://github.com/
|
213
|
+
In order to colorize strings, **TTY** uses the [pastel](https://github.com/piotrmurach/pastel) component:
|
214
214
|
|
215
215
|
```ruby
|
216
216
|
pastel = Pastel.new
|
217
217
|
pastel.red.on_green.bold 'text...' # => red bold text on green background
|
218
218
|
```
|
219
219
|
|
220
|
-
Please refer to [documentation](https://github.com/
|
220
|
+
Please refer to [documentation](https://github.com/piotrmurach/pastel#contents) for complete API.
|
221
221
|
|
222
222
|
## 7. Output paging
|
223
223
|
|
224
|
-
To page terminal output **TTY** relies on [tty-pager](https://github.com/
|
224
|
+
To page terminal output **TTY** relies on [tty-pager](https://github.com/piotrmurach/tty-pager) component.
|
225
225
|
|
226
226
|
For example to page terminal output do (on non unix systems falls back to ruby implementation):
|
227
227
|
|
@@ -230,11 +230,11 @@ pager = TTY::Pager.new
|
|
230
230
|
pager.page('Very long text...')
|
231
231
|
```
|
232
232
|
|
233
|
-
Please refer to [documentation](https://github.com/
|
233
|
+
Please refer to [documentation](https://github.com/piotrmurach/tty-pager) for complete API.
|
234
234
|
|
235
235
|
## 8. Detecting screen properties
|
236
236
|
|
237
|
-
**TTY** uses the [tty-screen](https://github.com/
|
237
|
+
**TTY** uses the [tty-screen](https://github.com/piotrmurach/tty-screen) component to measure the screen properties.
|
238
238
|
|
239
239
|
For example to get screen size do:
|
240
240
|
|
@@ -245,11 +245,11 @@ screen.width # => 280
|
|
245
245
|
screen.height # => 51
|
246
246
|
```
|
247
247
|
|
248
|
-
Please refer to [documentation](https://github.com/
|
248
|
+
Please refer to [documentation](https://github.com/piotrmurach/tty-screen) for complete API.
|
249
249
|
|
250
250
|
## 9. Detecting platform
|
251
251
|
|
252
|
-
To check for platform properties **TTY** uses [tty-platform](https://github.com/
|
252
|
+
To check for platform properties **TTY** uses [tty-platform](https://github.com/piotrmurach/tty-platform) component.
|
253
253
|
|
254
254
|
```ruby
|
255
255
|
platform = TTY::Platform.new
|
@@ -265,22 +265,22 @@ TTY::Platform.unix? # => true
|
|
265
265
|
TTY::Platform.windows? # => false
|
266
266
|
```
|
267
267
|
|
268
|
-
Please refer to [documentation](https://github.com/
|
268
|
+
Please refer to [documentation](https://github.com/piotrmurach/tty-platform) for complete API.
|
269
269
|
|
270
270
|
## 10. Detecting color capabilities
|
271
271
|
|
272
|
-
[tty-color](https://github.com/
|
272
|
+
[tty-color](https://github.com/piotrmurach/tty-color) component allows **TTY** detect color support and mode in terminal emulator:
|
273
273
|
|
274
274
|
```ruby
|
275
275
|
TTY::Color.supports? # => true
|
276
276
|
TTY::Color.mode # => 64
|
277
277
|
```
|
278
278
|
|
279
|
-
Please refer to [documentation](https://github.com/
|
279
|
+
Please refer to [documentation](https://github.com/piotrmurach/tty-color) for complete API.
|
280
280
|
|
281
281
|
## 11. Searching executables
|
282
282
|
|
283
|
-
To find executable path **TTY** uses [tty-which](https://github.com/
|
283
|
+
To find executable path **TTY** uses [tty-which](https://github.com/piotrmurach/tty-which#ttywhich) component.
|
284
284
|
|
285
285
|
For instance, to find out if `less` utility is actually supported by the system do:
|
286
286
|
|
@@ -288,11 +288,11 @@ For instance, to find out if `less` utility is actually supported by the system
|
|
288
288
|
TTY::Which.which('less') # => '/usr/bin/less'
|
289
289
|
```
|
290
290
|
|
291
|
-
Please refer to [documentation](https://github.com/
|
291
|
+
Please refer to [documentation](https://github.com/piotrmurach/tty-which#ttywhich) for complete API.
|
292
292
|
|
293
293
|
## 12. Moving cursor
|
294
294
|
|
295
|
-
To perform terminal cursor movements use [tty-cursor](https://github.com/
|
295
|
+
To perform terminal cursor movements use [tty-cursor](https://github.com/piotrmurach/tty-cursor#ttycursor) component.
|
296
296
|
|
297
297
|
For example, to move cursor up by 5 rows and forward by 2 columns:
|
298
298
|
|
@@ -301,7 +301,7 @@ cursor = TTY::Cursor
|
|
301
301
|
print cursor.up(5) + cursor.forward(2)
|
302
302
|
```
|
303
303
|
|
304
|
-
Please refer to [documentation](https://github.com/
|
304
|
+
Please refer to [documentation](https://github.com/piotrmurach/tty-cursor#contents) for complete API.
|
305
305
|
|
306
306
|
## 13. Setting editor
|
307
307
|
|
data/lib/tty/version.rb
CHANGED
data/tty.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = [""]
|
11
11
|
spec.description = %q{A toolbox for developing beautiful command line clients.}
|
12
12
|
spec.summary = %q{A toolbox for developing beautiful command line clients. It provides a fluid interface for gathering input from the user, querying system and terminal and displaying information back.}
|
13
|
-
spec.homepage = '
|
13
|
+
spec.homepage = 'https://piotrmurach.github.io/tty/'
|
14
14
|
|
15
15
|
spec.files = `git ls-files`.split($/)
|
16
16
|
spec.executables = spec.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
@@ -18,13 +18,14 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
20
|
spec.add_dependency 'tty-color', '~> 0.3.0'
|
21
|
-
spec.add_dependency 'tty-cursor', '~> 0.
|
21
|
+
spec.add_dependency 'tty-cursor', '~> 0.3.0'
|
22
|
+
spec.add_dependency 'tty-command', '~> 0.1.0'
|
22
23
|
spec.add_dependency 'tty-pager', '~> 0.4.0'
|
23
24
|
spec.add_dependency 'tty-platform', '~> 0.1.0'
|
24
|
-
spec.add_dependency 'tty-progressbar', '~> 0.
|
25
|
-
spec.add_dependency 'tty-prompt', '~> 0.
|
25
|
+
spec.add_dependency 'tty-progressbar', '~> 0.9.0'
|
26
|
+
spec.add_dependency 'tty-prompt', '~> 0.6.0'
|
26
27
|
spec.add_dependency 'tty-screen', '~> 0.5.0'
|
27
|
-
spec.add_dependency 'tty-spinner', '~> 0.
|
28
|
+
spec.add_dependency 'tty-spinner', '~> 0.2.0'
|
28
29
|
spec.add_dependency 'tty-table', '~> 0.5.0'
|
29
30
|
spec.add_dependency 'tty-which', '~> 0.1.0'
|
30
31
|
spec.add_dependency 'equatable', '~> 0.5.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.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-
|
11
|
+
date: 2016-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tty-color
|
@@ -30,14 +30,28 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.3.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.3.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: tty-command
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.1.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.1.0
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: tty-pager
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,28 +86,28 @@ dependencies:
|
|
72
86
|
requirements:
|
73
87
|
- - ~>
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.
|
89
|
+
version: 0.9.0
|
76
90
|
type: :runtime
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
94
|
- - ~>
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.
|
96
|
+
version: 0.9.0
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: tty-prompt
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
101
|
- - ~>
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.
|
103
|
+
version: 0.6.0
|
90
104
|
type: :runtime
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
108
|
- - ~>
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.
|
110
|
+
version: 0.6.0
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: tty-screen
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,14 +128,14 @@ dependencies:
|
|
114
128
|
requirements:
|
115
129
|
- - ~>
|
116
130
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0.
|
131
|
+
version: 0.2.0
|
118
132
|
type: :runtime
|
119
133
|
prerelease: false
|
120
134
|
version_requirements: !ruby/object:Gem::Requirement
|
121
135
|
requirements:
|
122
136
|
- - ~>
|
123
137
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0.
|
138
|
+
version: 0.2.0
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: tty-table
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -228,7 +242,6 @@ files:
|
|
228
242
|
- LICENSE.txt
|
229
243
|
- README.md
|
230
244
|
- Rakefile
|
231
|
-
- benchmarks/shell.rb
|
232
245
|
- images/tty.png
|
233
246
|
- lib/tty.rb
|
234
247
|
- lib/tty/logger.rb
|
@@ -271,7 +284,7 @@ files:
|
|
271
284
|
- tasks/metrics/reek.rake
|
272
285
|
- tasks/spec.rake
|
273
286
|
- tty.gemspec
|
274
|
-
homepage:
|
287
|
+
homepage: https://piotrmurach.github.io/tty/
|
275
288
|
licenses: []
|
276
289
|
metadata: {}
|
277
290
|
post_install_message:
|
data/benchmarks/shell.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
# Benchmark speed of shell operations
|
4
|
-
|
5
|
-
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
6
|
-
|
7
|
-
require 'tty'
|
8
|
-
require 'benchmark'
|
9
|
-
require 'benchmark/ips'
|
10
|
-
require 'stringio'
|
11
|
-
|
12
|
-
input = ::StringIO.new
|
13
|
-
output = ::StringIO.new
|
14
|
-
shell = TTY::Shell.new(input, output)
|
15
|
-
|
16
|
-
Benchmark.ips do |r|
|
17
|
-
|
18
|
-
r.report("Ruby #puts") do
|
19
|
-
output.puts "What is your name?"
|
20
|
-
end
|
21
|
-
|
22
|
-
r.report("TTY #ask") do
|
23
|
-
shell.ask("What is your name?")
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|