tty-prompt 0.17.1 → 0.17.2

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: add9caacfddf9bf791d06ebc7a1c71bfe8b93bf9223a99ae7b44cd7e7db6bbc7
4
- data.tar.gz: f438dccea904d0bcb7e8eda4aa5c4c3c9e1002dc26ab2e1afd75a8a8c9cad315
3
+ metadata.gz: 5132a0018789c045981bf472bb2dfcf088701d50eb61ddec5e8945b3802786b4
4
+ data.tar.gz: a737e6b706f326ab39f58541adb05a2f85481374dfbb10b3f4e546f1f6c88e54
5
5
  SHA512:
6
- metadata.gz: 3f3a0b45e1c57b370de325375698920ee07ea1e57cbfe8ac830cd38da5d1b8755e5ba4c844cfdea5a9fafe7c6744c5aaa199c13ff32e1f59bef41135bf23f7cd
7
- data.tar.gz: 2fd7510bb85454bad9b089a6d2684418eb710ecbe49d3c423ffa118a8980e9fa9dd54e3f6ea5185334939d1fce3ff03abc489b3b1dad47d4304b3fcc4304cac3
6
+ metadata.gz: 0b23beb0dc70f5beda1b686c1650c7d078df0e8d9b040eaa8751c5da14f058e30f74d2f4b671d5ef8ce640f2cb30bc555a27ad58d75e28a0ffb0a8de2fd6a7c9
7
+ data.tar.gz: ebfd4d6309d87070e32932031f5250f60e39fd444ffbe3735e2445433825858c08c07894d660726dd83c31e572c030a93abbd515f4d634a3ba6fed363bfe0d54
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Change log
2
2
 
3
+ ## [v0.17.2] - 2018-11-01
4
+
5
+ ### Fixed
6
+ * Fix #yes? & #no? prompt suffix option to all non-standard characters by Rui(@rpbaltazar)
7
+
3
8
  ## [v0.17.1] - 2018-10-03
4
9
 
5
10
  ### Change
@@ -12,7 +17,7 @@
12
17
 
13
18
  ### Changed
14
19
  * Change to update tty-reader & tty-cursor dependencies
15
- * Change to directly requrie files in gemspec
20
+ * Change to directly require files in gemspec
16
21
 
17
22
  ## [v0.16.1] - 2018-04-29
18
23
 
@@ -27,7 +32,7 @@
27
32
  * Add #frozen_string_literal to all files
28
33
 
29
34
  ### Changed
30
- * Change Choice#from to allow parsing different data strucutures
35
+ * Change Choice#from to allow parsing different data structures
31
36
  * Change all classes to prevent strings mutations
32
37
  * Change Timeout to cleanly terminate keypress input without raising errors
33
38
 
@@ -280,6 +285,7 @@
280
285
 
281
286
  * Initial implementation and release
282
287
 
288
+ [v0.17.2]: https://github.com/piotrmurach/tty-prompt/compare/v0.17.1...v0.17.2
283
289
  [v0.17.1]: https://github.com/piotrmurach/tty-prompt/compare/v0.17.0...v0.17.1
284
290
  [v0.17.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.16.1...v0.17.0
285
291
  [v0.16.1]: https://github.com/piotrmurach/tty-prompt/compare/v0.16.0...v0.16.1
data/README.md CHANGED
@@ -102,7 +102,7 @@ Or install it yourself as:
102
102
  * [3.3 help_color](#33-help_color)
103
103
  * [3.4 interrupt](#34-interrupt)
104
104
  * [3.5 prefix](#35-prefix)
105
- * [3.6 trakc_history](#36-track_history)
105
+ * [3.6 track_history](#36-track_history)
106
106
 
107
107
  ## 1. Usage
108
108
 
@@ -286,7 +286,7 @@ prompt.ask('password:', echo: false)
286
286
 
287
287
  By default `tty-prompt` comes with predefined error messages for `required`, `in`, `validate` options.
288
288
 
289
- You can change these and configure to your liking either by inling them with the option:
289
+ You can change these and configure to your liking either by passing message as second argument with the option:
290
290
 
291
291
  ```ruby
292
292
  prompt.ask('What is your email?') do |q|
@@ -365,7 +365,7 @@ prompt.ask('What is your username?') do |q|
365
365
  end
366
366
  ```
367
367
 
368
- The **TTY::Prompt** comes with bult-in validations for `:email` and you can use them directly like so:
368
+ The **TTY::Prompt** comes with built-in validations for `:email` and you can use them directly like so:
369
369
 
370
370
  ```prompt
371
371
  prompt.ask('What is your email?') { |q| q.validate :email }
@@ -533,7 +533,7 @@ By default the choice name is also the value the prompt will return when selecte
533
533
  choices = {small: 1, medium: 2, large: 3}
534
534
  ```
535
535
 
536
- Finally, you can define an array of choices where each choice is a hash value with `:name` & `:value` keys which can include other options for customising indvidual choices:
536
+ Finally, you can define an array of choices where each choice is a hash value with `:name` & `:value` keys which can include other options for customising individual choices:
537
537
 
538
538
  ```ruby
539
539
  choices = [
@@ -723,7 +723,7 @@ warriors = [
723
723
  ]
724
724
  ```
725
725
 
726
- The disabled choice will be displaed with a cross `✘` character next to it and followed by an explanation:
726
+ The disabled choice will be displayed with a cross `✘` character next to it and followed by an explanation:
727
727
 
728
728
  ```ruby
729
729
  prompt.select('Choose your destiny?', warriors)
@@ -910,7 +910,7 @@ drinks = [
910
910
  ]
911
911
  ```
912
912
 
913
- The disabled choice will be displaed with a cross `✘` character next to it and followed by an explanation:
913
+ The disabled choice will be displayed with a cross `✘` character next to it and followed by an explanation:
914
914
 
915
915
  ```ruby
916
916
  prompt.multi_select('Choose your favourite drink?', drinks)
@@ -1211,6 +1211,15 @@ prompt.slider('Volume', max: 100, step: 5, default: 75, format: "|:slider| %d%")
1211
1211
  # (Use arrow keys, press Enter to select)
1212
1212
  ```
1213
1213
 
1214
+ You can also specify slider range with decimal numbers. For example, to have a step of `0.5` and display each value with a single decimal place use `%f` as format:
1215
+
1216
+ ```ruby
1217
+ prompt.slider("Volume", max: 10, step: 0.5, default: 5, format: "|:slider| %.1f")
1218
+ # =>
1219
+ # Volume |───────────────O─────| 7.5
1220
+ # (Use arrow keys, press Enter to select)
1221
+ ```
1222
+
1214
1223
  Slider can be configured through DSL as well:
1215
1224
 
1216
1225
  ```ruby
@@ -1235,7 +1244,7 @@ prompt.say(...)
1235
1244
 
1236
1245
  The `say` method also accepts option `:color` which supports all the colors provided by [pastel](https://github.com/piotrmurach/pastel#3-supported-colors)
1237
1246
 
1238
- **TTY::Prompt** provides more specific versions of `say` method to better express intenation behind the message such as `ok`, `warn` and `error`.
1247
+ **TTY::Prompt** provides more specific versions of `say` method to better express intention behind the message such as `ok`, `warn` and `error`.
1239
1248
 
1240
1249
  #### 2.11.1 ok
1241
1250
 
@@ -1317,7 +1326,7 @@ The available events are:
1317
1326
 
1318
1327
  ### 3.1 active_color
1319
1328
 
1320
- All prompt types support `:active_color` option. In case of `select`, `multi_select`, `enum_select` or `expand` this color is used to highlight the currently selected choice. All the resulted inputs provided by user that are read in by the prompt as answer are highlighted with this color. This option can be applied either globablly for all prompts or individually.
1329
+ All prompt types support `:active_color` option. In case of `select`, `multi_select`, `enum_select` or `expand` this color is used to highlight the currently selected choice. All the resulted inputs provided by user that are read in by the prompt as answer are highlighted with this color. This option can be applied either globally for all prompts or individually.
1321
1330
 
1322
1331
  ```ruby
1323
1332
  prompt = TTY::Prompt.new(active_color: :cyan)
@@ -1341,7 +1350,7 @@ prompt = TTY::Prompt.new(enable_color: true)
1341
1350
 
1342
1351
  ### 3.3 help_color
1343
1352
 
1344
- Prompts such as `select`, `multi_select`, `expand` support `:help_color` which is used to customize the help text. This option can be applied either globablly for all prompts or individually.
1353
+ Prompts such as `select`, `multi_select`, `expand` support `:help_color` which is used to customize the help text. This option can be applied either globally for all prompts or individually.
1345
1354
 
1346
1355
  ```ruby
1347
1356
  prompt = TTY::Prompt.new(help_color: :cyan)
@@ -1378,7 +1387,7 @@ prompt = TTY::Prompt.new(prefix: '[?] ')
1378
1387
 
1379
1388
  ### 3.6 track_history
1380
1389
 
1381
- The prompts that accept line input such as `multiline` or `ask` provide history buffer that tracks all the lines entered during `TTY::Prompt.new` interactions. The history buffer provides previoius or next lines when user presses up/down arrows respectively. However, if you wish to disable this behaviour use `:track_history` option like so:
1390
+ The prompts that accept line input such as `multiline` or `ask` provide history buffer that tracks all the lines entered during `TTY::Prompt.new` interactions. The history buffer provides previous or next lines when user presses up/down arrows respectively. However, if you wish to disable this behaviour use `:track_history` option like so:
1382
1391
 
1383
1392
  ```ruby
1384
1393
  prompt = TTY::Prompt.new(track_history: false)
@@ -121,7 +121,12 @@ module TTY
121
121
  #
122
122
  # @api private
123
123
  def conversion
124
- proc { |input| !input.match(/^#{positive}|#{positive[0]}$/i).nil? }
124
+ proc { |input|
125
+ positive_word = Regexp.escape(positive)
126
+ positive_letter = Regexp.escape(positive[0])
127
+ pattern = Regexp.new("^#{positive_word}|#{positive_letter}$", true)
128
+ !input.match(pattern).nil?
129
+ }
125
130
  end
126
131
  end # ConfirmQuestion
127
132
  end # Prompt
@@ -2,6 +2,6 @@
2
2
 
3
3
  module TTY
4
4
  class Prompt
5
- VERSION = '0.17.1'
5
+ VERSION = '0.17.2'
6
6
  end # Prompt
7
7
  end # TTY
@@ -95,6 +95,22 @@ RSpec.describe TTY::Prompt, 'confirmation' do
95
95
  ].join)
96
96
  end
97
97
 
98
+ it "accepts regex conflicting characters as suffix" do
99
+ prompt.input << "]\n"
100
+ prompt.input.rewind
101
+ result = prompt.yes?("Are you a human? [ as yes and ] as no") do |q|
102
+ q.suffix "[/]"
103
+ end
104
+ expect(result).to eq(false)
105
+ expect(prompt.output.string).to eq([
106
+ "Are you a human? [ as yes and ] as no \e[90m([/])\e[0m ",
107
+ "\e[2K\e[1GAre you a human? [ as yes and ] as no \e[90m([/])\e[0m ]",
108
+ "\e[2K\e[1GAre you a human? [ as yes and ] as no \e[90m([/])\e[0m ]\n",
109
+ "\e[1A\e[2K\e[1G",
110
+ "Are you a human? [ as yes and ] as no \e[32m]\e[0m\n"
111
+ ].join)
112
+ end
113
+
98
114
  it "customizes question through options" do
99
115
  prompt.input << "\r"
100
116
  prompt.input.rewind
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.17.1
4
+ version: 0.17.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Murach
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-03 00:00:00.000000000 Z
11
+ date: 2018-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: necromancer