tty-reader 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/examples/multi_prompt.rb +9 -0
- data/lib/tty/reader/line.rb +4 -1
- data/lib/tty/reader/version.rb +1 -1
- data/spec/spec_helper.rb +4 -2
- data/spec/unit/history_spec.rb +1 -1
- data/spec/unit/read_line_spec.rb +23 -0
- data/tty-reader.gemspec +10 -1
- metadata +11 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5cafac5b8e629299d317c79b4bc5ff9b5f88873dbbcb966b152a773509c118a8
|
4
|
+
data.tar.gz: ebc42b1a9eb21652b74edf393f9555be025d9cfb3e84c9be14b667dc3012b59e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7d0b5652ed3e3b7f6080c7a31c066457d00d20aefe780f2f581e221f06760a19bfe654c5d5b7edaa6317d2fed9f934a3a58adc36296e73b5529d74cf1147c92
|
7
|
+
data.tar.gz: b713a61cf2c195d11ae63a4ccc4b0901347286913e41fa014d1bf641bc65e7ff958ba1e334354e7d8622848caf2229363a799402a240946042aec217e4ef1577
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
+
## [v0.7.0] - 2019-11-24
|
4
|
+
|
5
|
+
### Added
|
6
|
+
* Add support for a multi-line prompt by Katelyn Schiesser(@slowbro)
|
7
|
+
* Add metadata to gemspec
|
8
|
+
|
3
9
|
## [v0.6.0] - 2019-05-27
|
4
10
|
|
5
11
|
### Added
|
@@ -60,6 +66,7 @@
|
|
60
66
|
|
61
67
|
* Initial implementation and release
|
62
68
|
|
69
|
+
[v0.7.0]: https://github.com/piotrmurach/tty-reader/compare/v0.6.0...v0.7.0
|
63
70
|
[v0.6.0]: https://github.com/piotrmurach/tty-reader/compare/v0.5.0...v0.6.0
|
64
71
|
[v0.5.0]: https://github.com/piotrmurach/tty-reader/compare/v0.4.0...v0.5.0
|
65
72
|
[v0.4.0]: https://github.com/piotrmurach/tty-reader/compare/v0.3.0...v0.4.0
|
data/lib/tty/reader/line.rb
CHANGED
@@ -236,7 +236,10 @@ module TTY
|
|
236
236
|
#
|
237
237
|
# @api public
|
238
238
|
def prompt_size
|
239
|
-
self.class.sanitize(@prompt).
|
239
|
+
p = self.class.sanitize(@prompt).split(/\r?\n/)
|
240
|
+
# return the length of each line + screen width for every line past the first
|
241
|
+
# which accounts for multi-line prompts
|
242
|
+
p.join.length + ((p.length - 1) * TTY::Screen.width )
|
240
243
|
end
|
241
244
|
|
242
245
|
# Text size
|
data/lib/tty/reader/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
if ENV['COVERAGE'] || ENV['TRAVIS']
|
2
4
|
require 'simplecov'
|
3
5
|
require 'coveralls'
|
4
6
|
|
5
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
7
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
|
6
8
|
SimpleCov::Formatter::HTMLFormatter,
|
7
9
|
Coveralls::SimpleCov::Formatter
|
8
|
-
]
|
10
|
+
])
|
9
11
|
|
10
12
|
SimpleCov.start do
|
11
13
|
command_name 'spec'
|
data/spec/unit/history_spec.rb
CHANGED
@@ -13,7 +13,7 @@ RSpec.describe TTY::Reader::History do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it "allows to cycle through non-empty buffer" do
|
16
|
-
history = described_class.new(3,
|
16
|
+
history = described_class.new(3, cycle: true)
|
17
17
|
history << "line"
|
18
18
|
expect(history.next?).to eq(true)
|
19
19
|
expect(history.previous?).to eq(true)
|
data/spec/unit/read_line_spec.rb
CHANGED
@@ -93,4 +93,27 @@ RSpec.describe TTY::Reader, '#read_line' do
|
|
93
93
|
|
94
94
|
expect(answer).to eq("한글")
|
95
95
|
end
|
96
|
+
|
97
|
+
it "supports multiline prompts" do
|
98
|
+
allow(TTY::Screen).to receive(:width).and_return(50)
|
99
|
+
prompt = "one\ntwo\nthree"
|
100
|
+
input << "aa\n"
|
101
|
+
input.rewind
|
102
|
+
|
103
|
+
answer = reader.read_line(prompt)
|
104
|
+
|
105
|
+
expect(answer).to eq("aa\n")
|
106
|
+
expect(output.string).to eq([
|
107
|
+
prompt,
|
108
|
+
"\e[2K\e[1G\e[1A" * 2,
|
109
|
+
"\e[2K\e[1G",
|
110
|
+
prompt + "a",
|
111
|
+
"\e[2K\e[1G\e[1A" * 2,
|
112
|
+
"\e[2K\e[1G",
|
113
|
+
prompt + "aa",
|
114
|
+
"\e[2K\e[1G\e[1A" * 2,
|
115
|
+
"\e[2K\e[1G",
|
116
|
+
prompt + "aa\n"
|
117
|
+
].join)
|
118
|
+
end
|
96
119
|
end
|
data/tty-reader.gemspec
CHANGED
@@ -11,7 +11,16 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.description = %q{A set of methods for processing keyboard input in character, line and multiline modes. It maintains history of entered input with an ability to recall and re-edit those inputs. It lets you register to listen for keystroke events and trigger custom key events yourself.}
|
12
12
|
spec.homepage = "https://piotrmurach.github.io/tty"
|
13
13
|
spec.license = "MIT"
|
14
|
-
|
14
|
+
if spec.respond_to?(:metadata=)
|
15
|
+
spec.metadata = {
|
16
|
+
"allowed_push_host" => "https://rubygems.org",
|
17
|
+
"bug_tracker_uri" => "https://github.com/piotrmurach/tty-reader/issues",
|
18
|
+
"changelog_uri" => "https://github.com/piotrmurach/tty-reader/blob/master/CHANGELOG.md",
|
19
|
+
"documentation_uri" => "https://www.rubydoc.info/gems/tty-reader",
|
20
|
+
"homepage_uri" => spec.homepage,
|
21
|
+
"source_code_uri" => "https://github.com/piotrmurach/tty-reader"
|
22
|
+
}
|
23
|
+
end
|
15
24
|
spec.files = Dir['{lib,spec,examples,benchmarks}/**/*.rb']
|
16
25
|
spec.files += Dir['{bin,tasks}/*', 'tty-reader.gemspec']
|
17
26
|
spec.files += Dir['README.md', 'CHANGELOG.md', 'LICENSE.txt', 'Rakefile']
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tty-reader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Murach
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: wisper
|
@@ -115,6 +115,7 @@ files:
|
|
115
115
|
- examples/keypress.rb
|
116
116
|
- examples/keypress_nonblock.rb
|
117
117
|
- examples/line.rb
|
118
|
+
- examples/multi_prompt.rb
|
118
119
|
- examples/multiline.rb
|
119
120
|
- examples/noecho.rb
|
120
121
|
- examples/shell.rb
|
@@ -145,7 +146,13 @@ files:
|
|
145
146
|
homepage: https://piotrmurach.github.io/tty
|
146
147
|
licenses:
|
147
148
|
- MIT
|
148
|
-
metadata:
|
149
|
+
metadata:
|
150
|
+
allowed_push_host: https://rubygems.org
|
151
|
+
bug_tracker_uri: https://github.com/piotrmurach/tty-reader/issues
|
152
|
+
changelog_uri: https://github.com/piotrmurach/tty-reader/blob/master/CHANGELOG.md
|
153
|
+
documentation_uri: https://www.rubydoc.info/gems/tty-reader
|
154
|
+
homepage_uri: https://piotrmurach.github.io/tty
|
155
|
+
source_code_uri: https://github.com/piotrmurach/tty-reader
|
149
156
|
post_install_message:
|
150
157
|
rdoc_options: []
|
151
158
|
require_paths:
|
@@ -161,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
161
168
|
- !ruby/object:Gem::Version
|
162
169
|
version: '0'
|
163
170
|
requirements: []
|
164
|
-
rubygems_version: 3.0.
|
171
|
+
rubygems_version: 3.0.6
|
165
172
|
signing_key:
|
166
173
|
specification_version: 4
|
167
174
|
summary: A set of methods for processing keyboard input in character, line and multiline
|