tty-prompt 0.10.1 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -1
- data/CHANGELOG.md +30 -0
- data/README.md +39 -9
- data/examples/echo.rb +5 -1
- data/examples/inputs.rb +10 -0
- data/examples/mask.rb +6 -2
- data/examples/multi_select.rb +1 -1
- data/examples/multi_select_paged.rb +9 -0
- data/examples/select.rb +5 -5
- data/examples/slider.rb +1 -1
- data/lib/tty-prompt.rb +2 -36
- data/lib/tty/prompt.rb +49 -8
- data/lib/tty/prompt/choices.rb +2 -0
- data/lib/tty/prompt/confirm_question.rb +6 -1
- data/lib/tty/prompt/converter_dsl.rb +9 -6
- data/lib/tty/prompt/converter_registry.rb +27 -19
- data/lib/tty/prompt/converters.rb +16 -22
- data/lib/tty/prompt/enum_list.rb +8 -4
- data/lib/tty/prompt/enum_paginator.rb +2 -0
- data/lib/tty/prompt/evaluator.rb +1 -1
- data/lib/tty/prompt/expander.rb +1 -1
- data/lib/tty/prompt/list.rb +21 -11
- data/lib/tty/prompt/mask_question.rb +15 -6
- data/lib/tty/prompt/multi_list.rb +12 -10
- data/lib/tty/prompt/question.rb +38 -36
- data/lib/tty/prompt/question/modifier.rb +2 -0
- data/lib/tty/prompt/question/validation.rb +5 -4
- data/lib/tty/prompt/reader.rb +104 -58
- data/lib/tty/prompt/reader/codes.rb +103 -63
- data/lib/tty/prompt/reader/console.rb +57 -0
- data/lib/tty/prompt/reader/key_event.rb +51 -88
- data/lib/tty/prompt/reader/mode.rb +5 -5
- data/lib/tty/prompt/reader/win_api.rb +29 -0
- data/lib/tty/prompt/reader/win_console.rb +49 -0
- data/lib/tty/prompt/slider.rb +10 -6
- data/lib/tty/prompt/suggestion.rb +1 -1
- data/lib/tty/prompt/symbols.rb +52 -10
- data/lib/tty/prompt/version.rb +1 -1
- data/lib/tty/{prompt/test.rb → test_prompt.rb} +2 -1
- data/spec/unit/ask_spec.rb +8 -16
- data/spec/unit/converters/convert_bool_spec.rb +1 -2
- data/spec/unit/converters/on_error_spec.rb +9 -0
- data/spec/unit/enum_paginator_spec.rb +16 -0
- data/spec/unit/enum_select_spec.rb +69 -25
- data/spec/unit/expand_spec.rb +14 -14
- data/spec/unit/mask_spec.rb +66 -29
- data/spec/unit/multi_select_spec.rb +120 -74
- data/spec/unit/new_spec.rb +5 -3
- data/spec/unit/paginator_spec.rb +16 -0
- data/spec/unit/question/default_spec.rb +2 -4
- data/spec/unit/question/echo_spec.rb +2 -3
- data/spec/unit/question/in_spec.rb +9 -14
- data/spec/unit/question/modifier/letter_case_spec.rb +32 -11
- data/spec/unit/question/modifier/whitespace_spec.rb +41 -15
- data/spec/unit/question/required_spec.rb +9 -13
- data/spec/unit/question/validate_spec.rb +7 -10
- data/spec/unit/reader/key_event_spec.rb +36 -50
- data/spec/unit/reader/publish_keypress_event_spec.rb +5 -3
- data/spec/unit/reader/read_keypress_spec.rb +8 -7
- data/spec/unit/reader/read_line_spec.rb +9 -9
- data/spec/unit/reader/read_multiline_spec.rb +8 -7
- data/spec/unit/select_spec.rb +85 -25
- data/spec/unit/slider_spec.rb +43 -16
- data/spec/unit/yes_no_spec.rb +14 -28
- data/tasks/console.rake +1 -0
- data/tty-prompt.gemspec +2 -2
- metadata +14 -7
data/spec/unit/yes_no_spec.rb
CHANGED
@@ -11,8 +11,7 @@ RSpec.describe TTY::Prompt, 'confirmation' do
|
|
11
11
|
expect(prompt.yes?("Are you a human?")).to eq(true)
|
12
12
|
expect(prompt.output.string).to eq([
|
13
13
|
"Are you a human? \e[90m(Y/n)\e[0m ",
|
14
|
-
"\e[
|
15
|
-
"\e[1000D\e[K",
|
14
|
+
"\e[1A\e[2K\e[1G",
|
16
15
|
"Are you a human? \e[32mYes\e[0m\n"
|
17
16
|
].join)
|
18
17
|
end
|
@@ -23,8 +22,7 @@ RSpec.describe TTY::Prompt, 'confirmation' do
|
|
23
22
|
expect(prompt.yes?("Are you a human?")).to eq(false)
|
24
23
|
expect(prompt.output.string).to eq([
|
25
24
|
"Are you a human? \e[90m(Y/n)\e[0m ",
|
26
|
-
"\e[
|
27
|
-
"\e[1000D\e[K",
|
25
|
+
"\e[1A\e[2K\e[1G",
|
28
26
|
"Are you a human? \e[32mno\e[0m\n"
|
29
27
|
].join)
|
30
28
|
end
|
@@ -35,8 +33,7 @@ RSpec.describe TTY::Prompt, 'confirmation' do
|
|
35
33
|
expect(prompt.yes?("Are you a human?")).to eq(true)
|
36
34
|
expect(prompt.output.string).to eq([
|
37
35
|
"Are you a human? \e[90m(Y/n)\e[0m ",
|
38
|
-
"\e[
|
39
|
-
"\e[1000D\e[K",
|
36
|
+
"\e[1A\e[2K\e[1G",
|
40
37
|
"Are you a human? \e[32mYes\e[0m\n"
|
41
38
|
].join)
|
42
39
|
end
|
@@ -47,8 +44,7 @@ RSpec.describe TTY::Prompt, 'confirmation' do
|
|
47
44
|
expect(prompt.yes?("Are you a human?", default: false)).to eq(false)
|
48
45
|
expect(prompt.output.string).to eq([
|
49
46
|
"Are you a human? \e[90m(Y/n)\e[0m ",
|
50
|
-
"\e[
|
51
|
-
"\e[1000D\e[K",
|
47
|
+
"\e[1A\e[2K\e[1G",
|
52
48
|
"Are you a human? \e[32mno\e[0m\n"
|
53
49
|
].join)
|
54
50
|
end
|
@@ -63,8 +59,7 @@ RSpec.describe TTY::Prompt, 'confirmation' do
|
|
63
59
|
expect(result).to eq(false)
|
64
60
|
expect(prompt.output.string).to eq([
|
65
61
|
"Are you a human? \e[90m(Yup/nope)\e[0m ",
|
66
|
-
"\e[
|
67
|
-
"\e[1000D\e[K",
|
62
|
+
"\e[1A\e[2K\e[1G",
|
68
63
|
"Are you a human? \e[32mnope\e[0m\n"
|
69
64
|
].join)
|
70
65
|
end
|
@@ -78,8 +73,7 @@ RSpec.describe TTY::Prompt, 'confirmation' do
|
|
78
73
|
expect(result).to eq(false)
|
79
74
|
expect(prompt.output.string).to eq([
|
80
75
|
"Are you a human? \e[90m(Yup/nope)\e[0m ",
|
81
|
-
"\e[
|
82
|
-
"\e[1000D\e[K",
|
76
|
+
"\e[1A\e[2K\e[1G",
|
83
77
|
"Are you a human? \e[32mnope\e[0m\n"
|
84
78
|
].join)
|
85
79
|
end
|
@@ -92,8 +86,7 @@ RSpec.describe TTY::Prompt, 'confirmation' do
|
|
92
86
|
expect(result).to eq(true)
|
93
87
|
expect(prompt.output.string).to eq([
|
94
88
|
"Are you a human? \e[90m(Agree/Disagree)\e[0m ",
|
95
|
-
"\e[
|
96
|
-
"\e[1000D\e[K",
|
89
|
+
"\e[1A\e[2K\e[1G",
|
97
90
|
"Are you a human? \e[32mAgree\e[0m\n"
|
98
91
|
].join)
|
99
92
|
end
|
@@ -111,8 +104,7 @@ RSpec.describe TTY::Prompt, 'confirmation' do
|
|
111
104
|
expect(result).to eq(false)
|
112
105
|
expect(prompt.output.string).to eq([
|
113
106
|
"Are you a human? \e[90m(Agree/Disagree)\e[0m ",
|
114
|
-
"\e[
|
115
|
-
"\e[1000D\e[K",
|
107
|
+
"\e[1A\e[2K\e[1G",
|
116
108
|
"Are you a human? \e[32mDisagree\e[0m\n"
|
117
109
|
].join)
|
118
110
|
end
|
@@ -125,8 +117,7 @@ RSpec.describe TTY::Prompt, 'confirmation' do
|
|
125
117
|
expect(prompt.no?("Are you a human?")).to eq(true)
|
126
118
|
expect(prompt.output.string).to eq([
|
127
119
|
"Are you a human? \e[90m(y/N)\e[0m ",
|
128
|
-
"\e[
|
129
|
-
"\e[1000D\e[K",
|
120
|
+
"\e[1A\e[2K\e[1G",
|
130
121
|
"Are you a human? \e[32mNo\e[0m\n"
|
131
122
|
].join)
|
132
123
|
end
|
@@ -137,8 +128,7 @@ RSpec.describe TTY::Prompt, 'confirmation' do
|
|
137
128
|
expect(prompt.no?("Are you a human?")).to eq(false)
|
138
129
|
expect(prompt.output.string).to eq([
|
139
130
|
"Are you a human? \e[90m(y/N)\e[0m ",
|
140
|
-
"\e[
|
141
|
-
"\e[1000D\e[K",
|
131
|
+
"\e[1A\e[2K\e[1G",
|
142
132
|
"Are you a human? \e[32mYes\e[0m\n"
|
143
133
|
].join)
|
144
134
|
end
|
@@ -149,8 +139,7 @@ RSpec.describe TTY::Prompt, 'confirmation' do
|
|
149
139
|
expect(prompt.no?("Are you a human?")).to eq(true)
|
150
140
|
expect(prompt.output.string).to eq([
|
151
141
|
"Are you a human? \e[90m(y/N)\e[0m ",
|
152
|
-
"\e[
|
153
|
-
"\e[1000D\e[K",
|
142
|
+
"\e[1A\e[2K\e[1G",
|
154
143
|
"Are you a human? \e[32mNo\e[0m\n"
|
155
144
|
].join)
|
156
145
|
end
|
@@ -161,8 +150,7 @@ RSpec.describe TTY::Prompt, 'confirmation' do
|
|
161
150
|
expect(prompt.no?("Are you a human?", default: true)).to eq(false)
|
162
151
|
expect(prompt.output.string).to eq([
|
163
152
|
"Are you a human? \e[90m(y/N)\e[0m ",
|
164
|
-
"\e[
|
165
|
-
"\e[1000D\e[K",
|
153
|
+
"\e[1A\e[2K\e[1G",
|
166
154
|
"Are you a human? \e[32mYes\e[0m\n"
|
167
155
|
].join)
|
168
156
|
end
|
@@ -177,8 +165,7 @@ RSpec.describe TTY::Prompt, 'confirmation' do
|
|
177
165
|
expect(result).to eq(false)
|
178
166
|
expect(prompt.output.string).to eq([
|
179
167
|
"Are you a human? \e[90m(yup/Nope)\e[0m ",
|
180
|
-
"\e[
|
181
|
-
"\e[1000D\e[K",
|
168
|
+
"\e[1A\e[2K\e[1G",
|
182
169
|
"Are you a human? \e[32myup\e[0m\n"
|
183
170
|
].join)
|
184
171
|
end
|
@@ -196,8 +183,7 @@ RSpec.describe TTY::Prompt, 'confirmation' do
|
|
196
183
|
expect(result).to eq(false)
|
197
184
|
expect(prompt.output.string).to eq([
|
198
185
|
"Are you a human? \e[90m(Agree/Disagree)\e[0m ",
|
199
|
-
"\e[
|
200
|
-
"\e[1000D\e[K",
|
186
|
+
"\e[1A\e[2K\e[1G",
|
201
187
|
"Are you a human? \e[32mAgree\e[0m\n"
|
202
188
|
].join)
|
203
189
|
end
|
data/tasks/console.rake
CHANGED
data/tty-prompt.gemspec
CHANGED
@@ -18,9 +18,9 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency 'necromancer', '~> 0.
|
21
|
+
spec.add_dependency 'necromancer', '~> 0.4.0'
|
22
22
|
spec.add_dependency 'pastel', '~> 0.7.0'
|
23
|
-
spec.add_dependency 'tty-cursor', '~> 0.
|
23
|
+
spec.add_dependency 'tty-cursor', '~> 0.4.0'
|
24
24
|
spec.add_dependency 'wisper', '~> 1.6.1'
|
25
25
|
|
26
26
|
spec.add_development_dependency 'bundler', '>= 1.5.0', '< 2.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tty-prompt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.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: 2017-02-
|
11
|
+
date: 2017-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: necromancer
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.4.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.4.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: pastel
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: 0.4.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: 0.4.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: wisper
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -141,9 +141,11 @@ files:
|
|
141
141
|
- examples/enum_select.rb
|
142
142
|
- examples/expand.rb
|
143
143
|
- examples/in.rb
|
144
|
+
- examples/inputs.rb
|
144
145
|
- examples/keypress.rb
|
145
146
|
- examples/mask.rb
|
146
147
|
- examples/multi_select.rb
|
148
|
+
- examples/multi_select_paged.rb
|
147
149
|
- examples/select.rb
|
148
150
|
- examples/select_paginated.rb
|
149
151
|
- examples/slider.rb
|
@@ -174,16 +176,19 @@ files:
|
|
174
176
|
- lib/tty/prompt/question/validation.rb
|
175
177
|
- lib/tty/prompt/reader.rb
|
176
178
|
- lib/tty/prompt/reader/codes.rb
|
179
|
+
- lib/tty/prompt/reader/console.rb
|
177
180
|
- lib/tty/prompt/reader/key_event.rb
|
178
181
|
- lib/tty/prompt/reader/mode.rb
|
182
|
+
- lib/tty/prompt/reader/win_api.rb
|
183
|
+
- lib/tty/prompt/reader/win_console.rb
|
179
184
|
- lib/tty/prompt/result.rb
|
180
185
|
- lib/tty/prompt/slider.rb
|
181
186
|
- lib/tty/prompt/statement.rb
|
182
187
|
- lib/tty/prompt/suggestion.rb
|
183
188
|
- lib/tty/prompt/symbols.rb
|
184
|
-
- lib/tty/prompt/test.rb
|
185
189
|
- lib/tty/prompt/utils.rb
|
186
190
|
- lib/tty/prompt/version.rb
|
191
|
+
- lib/tty/test_prompt.rb
|
187
192
|
- spec/spec_helper.rb
|
188
193
|
- spec/unit/ask_spec.rb
|
189
194
|
- spec/unit/choice/eql_spec.rb
|
@@ -204,6 +209,7 @@ files:
|
|
204
209
|
- spec/unit/converters/convert_range_spec.rb
|
205
210
|
- spec/unit/converters/convert_regex_spec.rb
|
206
211
|
- spec/unit/converters/convert_string_spec.rb
|
212
|
+
- spec/unit/converters/on_error_spec.rb
|
207
213
|
- spec/unit/distance/distance_spec.rb
|
208
214
|
- spec/unit/enum_paginator_spec.rb
|
209
215
|
- spec/unit/enum_select_spec.rb
|
@@ -292,6 +298,7 @@ test_files:
|
|
292
298
|
- spec/unit/converters/convert_range_spec.rb
|
293
299
|
- spec/unit/converters/convert_regex_spec.rb
|
294
300
|
- spec/unit/converters/convert_string_spec.rb
|
301
|
+
- spec/unit/converters/on_error_spec.rb
|
295
302
|
- spec/unit/distance/distance_spec.rb
|
296
303
|
- spec/unit/enum_paginator_spec.rb
|
297
304
|
- spec/unit/enum_select_spec.rb
|