highline_wrapper 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f360fc32885250acb479282caea2a5594cd40ad0f7ed101bf87bf4c229212d2f
4
- data.tar.gz: 71dcb19db17ce249d0fb08307b88dcd4fa22686d951065e5d0cc5e479866a53a
3
+ metadata.gz: 911a5de9b3a7c5315a0dd7983a3a3da86fc7ac39309718a93601400cdfd3e5d1
4
+ data.tar.gz: 00c7153fd5d0f2d9bbc354aaa4c04113abfd507d7a42560865c472c218e4197e
5
5
  SHA512:
6
- metadata.gz: 2a3e21cc1744f27746016e1744f16640504cdaad8f1b80e1bdf3a9f4b16ac3afa5aed6787f1128e2b02867ba9edd02d83d17fa25f834d27c6334c93063daac9f
7
- data.tar.gz: 2560f9a19bcd5fdb633084109aac6a82769d49f54b065ca780c1f0e32503aa9ee66952a731753e0bc5d18a83585e5fb74c57a06f124ca0739f7d201cd8dbf571
6
+ metadata.gz: 8ec66bb92ec4b4e24d68b772774b04f9c5aff7efba95feea1f8d315098f88a0a7836a3ca37609fb638f43b1fadf6fe0b9fb1fa935c8a4accc279f6b8c94810fd
7
+ data.tar.gz: b4582ee3283bd032c9a611bed8850e92922877fde6b378594a31bfc7088fb19a74e642d99787d0a451f08066a1e31591fec643d5ab6197e38f20fecb7690c954
data/Gemfile.lock CHANGED
@@ -1,24 +1,21 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- highline_wrapper (1.1.0)
4
+ highline_wrapper (1.2.0)
5
5
  highline (~> 2.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  ast (2.4.2)
11
- binding_of_caller (1.0.0)
12
- debug_inspector (>= 0.0.1)
13
11
  coderay (1.1.3)
14
12
  concurrent-ruby (1.1.8)
15
- debug_inspector (1.0.0)
16
13
  diff-lcs (1.4.4)
17
- faker (2.16.0)
14
+ faker (2.18.0)
18
15
  i18n (>= 1.6, < 2)
19
- ffi (1.15.0)
16
+ ffi (1.15.1)
20
17
  formatador (0.2.5)
21
- guard (2.16.2)
18
+ guard (2.17.0)
22
19
  formatador (>= 0.2.4)
23
20
  listen (>= 2.7, < 4.0)
24
21
  lumberjack (>= 1.0.12, < 2.0)
@@ -33,10 +30,9 @@ GEM
33
30
  guard-compat (~> 1.1)
34
31
  rspec (>= 2.99.0, < 4.0)
35
32
  highline (2.0.3)
36
- i18n (1.8.9)
33
+ i18n (1.8.10)
37
34
  concurrent-ruby (~> 1.0)
38
- interception (0.5)
39
- listen (3.4.1)
35
+ listen (3.5.1)
40
36
  rb-fsevent (~> 0.10, >= 0.10.3)
41
37
  rb-inotify (~> 0.9, >= 0.9.10)
42
38
  lumberjack (1.2.8)
@@ -46,27 +42,18 @@ GEM
46
42
  nenv (~> 0.1)
47
43
  shellany (~> 0.0)
48
44
  parallel (1.20.1)
49
- parser (3.0.0.0)
45
+ parser (3.0.1.1)
50
46
  ast (~> 2.4.1)
51
- pry (0.14.0)
47
+ pry (0.14.1)
52
48
  coderay (~> 1.1)
53
49
  method_source (~> 1.0)
54
- pry-doc (1.1.0)
55
- pry (~> 0.11)
56
- yard (~> 0.9.11)
57
- pry-rescue (1.5.2)
58
- interception (>= 0.5)
59
- pry (>= 0.12.0)
60
- pry-stack_explorer (0.6.1)
61
- binding_of_caller (~> 1.0)
62
- pry (~> 0.13)
63
50
  rainbow (3.0.0)
64
51
  rake (13.0.3)
65
- rb-fsevent (0.10.4)
52
+ rb-fsevent (0.11.0)
66
53
  rb-inotify (0.10.1)
67
54
  ffi (~> 1.0)
68
55
  regexp_parser (2.1.1)
69
- rexml (3.2.4)
56
+ rexml (3.2.5)
70
57
  rspec (3.10.0)
71
58
  rspec-core (~> 3.10.0)
72
59
  rspec-expectations (~> 3.10.0)
@@ -80,22 +67,21 @@ GEM
80
67
  diff-lcs (>= 1.2.0, < 2.0)
81
68
  rspec-support (~> 3.10.0)
82
69
  rspec-support (3.10.2)
83
- rubocop (1.11.0)
70
+ rubocop (1.16.0)
84
71
  parallel (~> 1.10)
85
72
  parser (>= 3.0.0.0)
86
73
  rainbow (>= 2.2.2, < 4.0)
87
74
  regexp_parser (>= 1.8, < 3.0)
88
75
  rexml
89
- rubocop-ast (>= 1.2.0, < 2.0)
76
+ rubocop-ast (>= 1.7.0, < 2.0)
90
77
  ruby-progressbar (~> 1.7)
91
78
  unicode-display_width (>= 1.4.0, < 3.0)
92
- rubocop-ast (1.4.1)
93
- parser (>= 2.7.1.5)
79
+ rubocop-ast (1.7.0)
80
+ parser (>= 3.0.1.1)
94
81
  ruby-progressbar (1.11.0)
95
82
  shellany (0.0.1)
96
83
  thor (1.1.0)
97
84
  unicode-display_width (2.0.0)
98
- yard (0.9.26)
99
85
 
100
86
  PLATFORMS
101
87
  x86_64-darwin-20
@@ -106,12 +92,9 @@ DEPENDENCIES
106
92
  guard-rspec (~> 4.3)
107
93
  highline_wrapper!
108
94
  pry (~> 0.13)
109
- pry-doc
110
- pry-rescue
111
- pry-stack_explorer
112
95
  rake (~> 13.0)
113
96
  rspec (~> 3.9)
114
97
  rubocop (~> 1.10)
115
98
 
116
99
  BUNDLED WITH
117
- 2.2.14
100
+ 2.2.19
data/README.md CHANGED
@@ -143,6 +143,7 @@ Notes:
143
143
  * If `required` is `true`, the question will repeat until the user answers the question
144
144
  * If `required` is `true`, then the `default` value will be ignored (defaults to `true`, but could be set to whatever and the code won't care... the question is required)
145
145
  * If `default` is `true` and `required` is `false`, and the user skips the question, the answer will be `true`
146
+ * The response to the question MUST be given either as `y`/`n`/`yes`/`no` or with any capitalization... anything else given as a response will be unparseable
146
147
 
147
148
  <details><summary>Examples</summary>
148
149
 
@@ -174,7 +175,7 @@ Do you like Ruby?
174
175
  Do you like Ruby?
175
176
  --- This question is required ---
176
177
  Do you like Ruby?
177
- no
178
+ N
178
179
  => false
179
180
 
180
181
  > HighlineWrapper.new.ask_yes_no('Do you like Ruby?')
@@ -182,7 +183,15 @@ Do you like Ruby?
182
183
  uh-huh
183
184
  --- This question is required ---
184
185
  Do you like Ruby?
186
+ YES
187
+ => true
188
+
189
+ > HighlineWrapper.new.ask_yes_no('Do you like Ruby?')
190
+ Do you like Ruby?
185
191
  yep
192
+ --- This question is required ---
193
+ Do you like Ruby?
194
+ yes
186
195
  => true
187
196
  ```
188
197
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class HighlineWrapper
4
- VERSION = '1.1.0'
4
+ VERSION = '1.2.0'
5
5
  end
@@ -16,10 +16,14 @@ class HighlineWrapper
16
16
  end
17
17
 
18
18
  private def parse(answer, prompt, options)
19
- return true if answer.include?('y')
20
- return false if answer.include?('n')
21
-
22
- recurse(prompt, nil, options)
19
+ case answer
20
+ when 'yes', 'y'
21
+ true
22
+ when 'no', 'n'
23
+ false
24
+ else
25
+ recurse(prompt, nil, options)
26
+ end
23
27
  end
24
28
 
25
29
  private def print_default_message(options)
@@ -28,7 +28,7 @@ describe HighlineWrapper::YesNoQuestion do
28
28
  end
29
29
 
30
30
  it 'should ask the highline client ask' do
31
- expect(highline).to receive(:ask)
31
+ expect(highline).to receive(:ask).and_return('Y')
32
32
  subject.ask(Faker::Lorem.sentence, options)
33
33
  end
34
34
 
@@ -49,6 +49,12 @@ describe HighlineWrapper::YesNoQuestion do
49
49
  expect(subject).to receive(:print_default_message)
50
50
  subject.ask(Faker::Lorem.sentence, options)
51
51
  end
52
+
53
+ it 'should recurse if the answer given is unparseable' do
54
+ allow(highline).to receive(:ask).and_return('yep', 'yessss', 'yes')
55
+ expect(subject).to receive(:recurse).exactly(2).times.and_call_original
56
+ subject.ask(Faker::Lorem.sentence, options)
57
+ end
52
58
  end
53
59
 
54
60
  context 'with required set to true' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: highline_wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emma Sax
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-09 00:00:00.000000000 Z
11
+ date: 2021-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline
@@ -167,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
167
  - !ruby/object:Gem::Version
168
168
  version: '0'
169
169
  requirements: []
170
- rubygems_version: 3.2.3
170
+ rubygems_version: 3.2.15
171
171
  signing_key:
172
172
  specification_version: 4
173
173
  summary: A little wrapper for HighLine