tty-prompt 0.16.0 → 0.16.1

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: 6dde0a99b670047f5cd262c047451d003dfc47ed8179bcd8b4f5e826612baeb8
4
- data.tar.gz: 2b9dca2f4d4790a157f30457dd1e5d4c1696aaaf29327624ee886342e67acec5
3
+ metadata.gz: aec759d54706c89726d2a7a9b5ec7d7dd14c773c0cb1240e1ecf51c2a0b734c6
4
+ data.tar.gz: af25b5b8fe122644232e5e02fd2aea203bad75901d7dfa1d2c0605c4181035ab
5
5
  SHA512:
6
- metadata.gz: d7504991bca7514addf3b72afdd2fcbf3e811528d06e9dede50edc7c80398a1cc486e6662162094afe5eb06657df14fa06082d59b4e587ed2afeac66af7f1e6b
7
- data.tar.gz: d6ab20ddeae00214b47428e6c5f9a65aa756d08466e5bf68e84acf6f58cba975d81ad4f99ffa687190694e7bd158e5a82c9af9c6bb74c802344aeb6f2badf628
6
+ metadata.gz: a44c4754daf0cabddbcce1a3863988603150df18364075ad0b9d2bef8193d16b3e0d67804f7553ace2f68c907cbcf9ad708f28442b5bd66c088400732bfa8101
7
+ data.tar.gz: 4253e5b3e30113775138f233c28a020291d3d20a70ed8f7e37c68407c62ebda1f09788909274c66c8e8e88cb4c855dd0085a13a89a9e42b7fc5174dabc05051c
@@ -1,5 +1,10 @@
1
1
  # Change log
2
2
 
3
+ ## [v0.16.1] - 2018-04-29
4
+
5
+ ### Fixed
6
+ * Fix key events subscription to only listen for the current prompt events
7
+
3
8
  ## [v0.16.0] - 2018-03-11
4
9
 
5
10
  ### Added
@@ -261,6 +266,7 @@
261
266
 
262
267
  * Initial implementation and release
263
268
 
269
+ [v0.16.1]: https://github.com/piotrmurach/tty-prompt/compare/v0.16.0...v0.16.1
264
270
  [v0.16.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.15.0...v0.16.0
265
271
  [v0.15.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.14.0...v0.15.0
266
272
  [v0.14.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.13.2...v0.14.0
data/Gemfile CHANGED
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- # gem 'tty-reader', path: '../tty-reader'
5
+ #gem 'tty-reader', path: '../tty-reader'
6
6
  # gem 'tty-reader', git: 'https://github.com/piotrmurach/tty-reader'
7
7
 
8
8
  group :test do
data/README.md CHANGED
@@ -79,8 +79,9 @@ Or install it yourself as:
79
79
  * [2.6.2.1 :disabled](#2621-disabled)
80
80
  * [2.6.2.2 :filter](#2622-filter)
81
81
  * [2.6.3 multi_select](#263-multi_select)
82
- * [2.6.3.1 :echo](#2631-echo)
83
- * [2.6.3.2 :filter](#2632-filter)
82
+ * [2.6.3.1 :disabled](#2631-disabled)
83
+ * [2.6.3.2 :echo](#2632-echo)
84
+ * [2.6.3.3 :filter](#2633-filter)
84
85
  * [2.6.4 enum_select](#264-enum_select)
85
86
  * [2.7 expand](#27-expand)
86
87
  * [2.8 collect](#28-collect)
@@ -890,7 +891,36 @@ prompt.multi_select("Choose your letter?", letters, per_page: 4)
890
891
  # (Move up or down to reveal more choices)
891
892
  ```
892
893
 
893
- ### 2.6.3.1 `:echo`
894
+ #### 2.6.3.1 `:disabled`
895
+
896
+ To disable menu choice, use the `:disabled` key with a value that explains the reason for the choice being unavailable. For example, out of all drinks, the sake and beer are currently out of stock:
897
+
898
+ ```ruby
899
+ drinks = [
900
+ 'bourbon',
901
+ {name: 'sake', disabled: '(out of stock)'},
902
+ 'vodka',
903
+ {name: 'beer', disabled: '(out of stock)'},
904
+ 'wine',
905
+ 'whisky'
906
+ ]
907
+ ```
908
+
909
+ The disabled choice will be displaed with a cross `✘` character next to it and followed by an explanation:
910
+
911
+ ```ruby
912
+ prompt.multi_select('Choose your favourite drink?', drinks)
913
+ # =>
914
+ # Choose your favourite drink? (Use arrow keys, press Space to select and Enter to finish)
915
+ # ‣ ⬡ bourbon
916
+ # ✘ sake (out of stock)
917
+ # ⬡ vodka
918
+ # ✘ beer (out of stock)
919
+ # ⬡ wine
920
+ # ⬡ whisky
921
+ ```
922
+
923
+ #### 2.6.3.2 `:echo`
894
924
 
895
925
  To control whether the selected items are shown on the question
896
926
  header use the :echo option:
@@ -907,7 +937,7 @@ prompt.multi_select("Select drinks?", choices, echo: false)
907
937
  # ‣ ⬢ 5) bourbon
908
938
  ```
909
939
 
910
- ### 2.6.3.2 `:filter`
940
+ #### 2.6.3.3 `:filter`
911
941
 
912
942
  To activate dynamic list filtering on letter/number typing, use the :filter option:
913
943
 
@@ -5,13 +5,13 @@ require_relative "../lib/tty-prompt"
5
5
  prompt = TTY::Prompt.new
6
6
 
7
7
  drinks = [
8
+ 'bourbon',
8
9
  {name: 'sake', disabled: '(out of stock)'},
9
10
  'vodka',
10
11
  {name: 'beer', disabled: '(out of stock)'},
11
12
  'wine',
12
- 'whisky',
13
- 'bourbon'
13
+ 'whisky'
14
14
  ]
15
- answer = prompt.multi_select('Choose your favourite drink?', drinks, default: 2)
15
+ answer = prompt.multi_select('Choose your favourite drink?', drinks)
16
16
 
17
17
  puts answer.inspect
@@ -76,7 +76,7 @@ module TTY
76
76
  :show, :hide
77
77
 
78
78
  def_delegators :@reader, :read_char, :read_line, :read_keypress,
79
- :read_multiline, :on, :subscribe, :trigger,
79
+ :read_multiline, :on, :subscribe, :unsubscribe, :trigger,
80
80
  :count_screen_lines
81
81
 
82
82
  def_delegators :@output, :print, :puts, :flush
@@ -41,8 +41,6 @@ module TTY
41
41
  @page_help = options[:page_help] || PAGE_HELP
42
42
  @paginator = EnumPaginator.new
43
43
  @page_active = @default
44
-
45
- @prompt.subscribe(self)
46
44
  end
47
45
 
48
46
  # Set default option selected
@@ -122,7 +120,9 @@ module TTY
122
120
  @question = question
123
121
  block[self] if block
124
122
  setup_defaults
125
- render
123
+ @prompt.subscribe(self) do
124
+ render
125
+ end
126
126
  end
127
127
 
128
128
  def keypress(event)
@@ -31,8 +31,6 @@ module TTY
31
31
  @status = :collapsed
32
32
  @hint = nil
33
33
  @default_key = false
34
-
35
- @prompt.subscribe(self)
36
34
  end
37
35
 
38
36
  def expanded?
@@ -133,7 +131,9 @@ module TTY
133
131
  block.call(self) if block
134
132
  setup_defaults
135
133
  choice(HELP_CHOICE)
136
- render
134
+ @prompt.subscribe(self) do
135
+ render
136
+ end
137
137
  end
138
138
 
139
139
  private
@@ -57,8 +57,6 @@ module TTY
57
57
  @per_page = options[:per_page]
58
58
  @page_help = options[:page_help] || PAGE_HELP
59
59
  @paginator = Paginator.new
60
-
61
- @prompt.subscribe(self)
62
60
  end
63
61
 
64
62
  # Set marker
@@ -183,7 +181,9 @@ module TTY
183
181
  @question = question
184
182
  block.call(self) if block
185
183
  setup_defaults
186
- render
184
+ @prompt.subscribe(self) do
185
+ render
186
+ end
187
187
  end
188
188
 
189
189
  # Check if list is enumerated
@@ -18,7 +18,6 @@ module TTY
18
18
  @mask = options.fetch(:mask) { Symbols.symbols[:dot] }
19
19
  @done_masked = false
20
20
  @failure = false
21
- @prompt.subscribe(self)
22
21
  end
23
22
 
24
23
  # Set character for masking the STDIN input
@@ -17,8 +17,6 @@ module TTY
17
17
  @help = options[:help] || self.class::HELP
18
18
  @first_render = true
19
19
  @lines_count = 0
20
-
21
- @prompt.subscribe(self)
22
20
  end
23
21
 
24
22
  # Provide help information
@@ -99,7 +99,9 @@ module TTY
99
99
  return if Utils.blank?(message)
100
100
  @message = message
101
101
  block.call(self) if block
102
- render
102
+ @prompt.subscribe(self) do
103
+ render
104
+ end
103
105
  end
104
106
 
105
107
  # Read answer and convert to type
@@ -40,8 +40,6 @@ module TTY
40
40
  @format = options.fetch(:format) { FORMAT }
41
41
  @first_render = true
42
42
  @done = false
43
-
44
- @prompt.subscribe(self)
45
43
  end
46
44
 
47
45
  # Setup initial active position
@@ -100,7 +98,9 @@ module TTY
100
98
  @question = question
101
99
  block.call(self) if block
102
100
  @active = initial
103
- render
101
+ @prompt.subscribe(self) do
102
+ render
103
+ end
104
104
  end
105
105
 
106
106
  def keyleft(*)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module TTY
4
4
  class Prompt
5
- VERSION = '0.16.0'.freeze
5
+ VERSION = '0.16.1'.freeze
6
6
  end # Prompt
7
7
  end # TTY
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.add_dependency 'pastel', '~> 0.7.0'
27
27
  spec.add_dependency 'timers', '~> 4.0'
28
28
  spec.add_dependency 'tty-cursor', '~> 0.5.0'
29
- spec.add_dependency 'tty-reader', '~> 0.2.0'
29
+ spec.add_dependency 'tty-reader', '~> 0.3.0'
30
30
 
31
31
  spec.add_development_dependency 'bundler', '>= 1.5.0', '< 2.0'
32
32
  spec.add_development_dependency 'rake'
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.16.0
4
+ version: 0.16.1
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-03-11 00:00:00.000000000 Z
11
+ date: 2018-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: necromancer
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.2.0
75
+ version: 0.3.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.2.0
82
+ version: 0.3.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: bundler
85
85
  requirement: !ruby/object:Gem::Requirement