highline 1.6.20 → 1.6.21

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
- !binary "U0hBMQ==":
3
- metadata.gz: a61adde22a7c1f3dee0c4bd0a140551c7c2d0d5c
4
- data.tar.gz: f0ff2a065f96473524fcd21b76dd63e6d7317e1a
5
- !binary "U0hBNTEy":
6
- metadata.gz: f7f546676de00891dece575d25b550459665f679161e2571d3218f355a16df9de929da9643b092948f17abd9764297846e2ac973d61b5d81d34933b9aef04ae4
7
- data.tar.gz: b8a676035168b49bdff06d2f272b37818289461a2d27b371ad32b2516f1c1c616cfe916ac09b833470c17652cb9e6d1701e60b6eb37dfdce97eaacfbb67a7808
2
+ SHA1:
3
+ metadata.gz: 654d8d8fa13e9d967eb78065d7d9c6be9f82fe44
4
+ data.tar.gz: d253b0c7ae6a1d36db8f0a07ce21c116e05e5c50
5
+ SHA512:
6
+ metadata.gz: ef2e620391d4ba1df254868824bda3f88705ba2724450b6155ff785e803da17e55a4e8dcb0026d150be49260cd2857c9fb1be3362590fb9e5d6ee2066af39393
7
+ data.tar.gz: e1c49b575b7d30f0c1b594c32770ff9895fc5a4fa85c0861e34c8d50ee812ac66a6dd11f5b8da7677298134fb88ce4d50356700744d6bf3fd3db2c7f437c7c56
data/CHANGELOG CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  Below is a complete listing of changes for each revision of HighLine.
4
4
 
5
+ == 1.6.21
6
+
7
+ * Improved Windows integration (by Ronie Henrich).
8
+ * Clarified menu choice error messages (by Keith Bennett).
9
+
5
10
  == 1.6.20
6
11
 
7
12
  * Fixed a bug with FFI::NCurses integration (by agentdave).
@@ -28,7 +28,7 @@ require "highline/style"
28
28
  #
29
29
  class HighLine
30
30
  # The version of the installed library.
31
- VERSION = "1.6.20".freeze
31
+ VERSION = "1.6.21".freeze
32
32
 
33
33
  # An internal HighLine error. User code does not need to trap this.
34
34
  class QuestionError < StandardError
@@ -368,31 +368,14 @@ class HighLine
368
368
 
369
369
  #
370
370
  # This method will update the intelligent responses to account for
371
- # Menu specific differences. This overrides the work done by
372
- # Question.build_responses().
371
+ # Menu specific differences. Calls the superclass' (Question's)
372
+ # build_responses method, overriding its default arguments to specify
373
+ # 'options' will be used to populate choice lists, and that
374
+ # the newly built hash will predominate over the preexisting hash
375
+ # for any keys that are the same.
373
376
  #
374
377
  def update_responses( )
375
- append_default unless default.nil?
376
- @responses = @responses.merge(
377
- :ambiguous_completion =>
378
- "Ambiguous choice. " +
379
- "Please choose one of #{options.inspect}.",
380
- :ask_on_error =>
381
- "? ",
382
- :invalid_type =>
383
- "You must enter a valid #{options}.",
384
- :no_completion =>
385
- "You must choose one of " +
386
- "#{options.inspect}.",
387
- :not_in_range =>
388
- "Your answer isn't within the expected range " +
389
- "(#{expected_range}).",
390
- :mismatch =>
391
- "Your entries didn't match.",
392
- :not_valid =>
393
- "Your answer isn't valid (must match " +
394
- "#{@validate.inspect})."
395
- )
378
+ build_responses(options, true)
396
379
  end
397
380
  end
398
381
  end
@@ -225,22 +225,29 @@ class HighLine
225
225
  #
226
226
  # Called late in the initialization process to build intelligent
227
227
  # responses based on the details of this Question object.
228
+ # Also used by Menu#update_responses.
228
229
  #
229
- def build_responses( )
230
- ### WARNING: This code is quasi-duplicated in ###
231
- ### Menu.update_responses(). Check there too when ###
232
- ### making changes! ###
230
+ def build_responses(message_source = answer_type, new_hash_wins = false)
231
+
233
232
  append_default unless default.nil?
234
- @responses = { :ambiguous_completion =>
235
- "Ambiguous choice. " +
236
- "Please choose one of #{@answer_type.inspect}.",
233
+
234
+ choice_error_str_func = lambda do
235
+ message_source.is_a?(Array) \
236
+ ? '[' + message_source.map { |s| "#{s}" }.join(', ') + ']' \
237
+ : message_source.inspect
238
+ end
239
+
240
+ old_hash = @responses
241
+
242
+ new_hash = { :ambiguous_completion =>
243
+ "Ambiguous choice. Please choose one of " +
244
+ choice_error_str_func.call + '.',
237
245
  :ask_on_error =>
238
246
  "? ",
239
247
  :invalid_type =>
240
- "You must enter a valid #{@answer_type}.",
248
+ "You must enter a valid #{message_source}.",
241
249
  :no_completion =>
242
- "You must choose one of " +
243
- "#{@answer_type.inspect}.",
250
+ "You must choose one of " + choice_error_str_func.call + '.',
244
251
  :not_in_range =>
245
252
  "Your answer isn't within the expected range " +
246
253
  "(#{expected_range}).",
@@ -248,10 +255,9 @@ class HighLine
248
255
  "Your entries didn't match.",
249
256
  :not_valid =>
250
257
  "Your answer isn't valid (must match " +
251
- "#{@validate.inspect})." }.merge(@responses)
252
- ### WARNING: This code is quasi-duplicated in ###
253
- ### Menu.update_responses(). Check there too when ###
254
- ### making changes! ###
258
+ "#{@validate.inspect})." }
259
+
260
+ @responses = new_hash_wins ? old_hash.merge(new_hash) : new_hash.merge(old_hash)
255
261
  end
256
262
 
257
263
  #
@@ -80,7 +80,13 @@ class HighLine
80
80
  require "dl/import"
81
81
 
82
82
  module WinAPI
83
- extend DL::Importer rescue DL::Importable
83
+ if defined?(DL::Importer)
84
+ # Ruby 1.9
85
+ extend DL::Importer
86
+ else
87
+ # Ruby 1.8
88
+ extend DL::Importable
89
+ end
84
90
  begin
85
91
  dlload "msvcrt", "kernel32"
86
92
  rescue DL::DLError
@@ -89,6 +95,16 @@ class HighLine
89
95
  extern "unsigned long _getch()"
90
96
  extern "unsigned long GetConsoleScreenBufferInfo(unsigned long, void*)"
91
97
  extern "unsigned long GetStdHandle(unsigned long)"
98
+
99
+ # Ruby 1.8 DL::Importable.import does mname[0,1].downcase so FooBar becomes fooBar
100
+ if defined?(getConsoleScreenBufferInfo)
101
+ alias_method :GetConsoleScreenBufferInfo, :getConsoleScreenBufferInfo
102
+ module_function :GetConsoleScreenBufferInfo
103
+ end
104
+ if defined?(getStdHandle)
105
+ alias_method :GetStdHandle, :getStdHandle
106
+ module_function :GetStdHandle
107
+ end
92
108
  end
93
109
  end
94
110
 
@@ -168,7 +168,7 @@ class TestHighLine < Test::Unit::TestCase
168
168
  end
169
169
  assert_equal(languages.last, answer)
170
170
  assert_equal( "What is your favorite programming language? " +
171
- "You must choose one of [:Perl, :Python, :Ruby].\n" +
171
+ "You must choose one of [Perl, Python, Ruby].\n" +
172
172
  "? ", @output.string )
173
173
  end
174
174
 
@@ -877,7 +877,7 @@ class TestHighLine < Test::Unit::TestCase
877
877
  assert_equal(:generate, answer)
878
878
  assert_equal( "Select a mode: " +
879
879
  "Ambiguous choice. " +
880
- "Please choose one of [:generate, :gentle].\n" +
880
+ "Please choose one of [generate, gentle].\n" +
881
881
  "? ", @output.string )
882
882
  end
883
883
 
metadata CHANGED
@@ -1,25 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: highline
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.20
4
+ version: 1.6.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Edward Gray II
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-16 00:00:00.000000000 Z
11
+ date: 2014-02-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: ! 'A high-level IO library that provides validation, type conversion,
14
- and more for
15
-
13
+ description: |
14
+ A high-level IO library that provides validation, type conversion, and more for
16
15
  command-line interfaces. HighLine also includes a complete menu system that can
17
-
18
16
  crank out anything from simple list selection to complete shells with just
19
-
20
17
  minutes of work.
21
-
22
- '
23
18
  email: james@graysoftinc.com
24
19
  executables: []
25
20
  extensions: []
@@ -30,7 +25,7 @@ extra_rdoc_files:
30
25
  - CHANGELOG
31
26
  - LICENSE
32
27
  files:
33
- - .gitignore
28
+ - ".gitignore"
34
29
  - AUTHORS
35
30
  - CHANGELOG
36
31
  - COPYING
@@ -84,25 +79,25 @@ licenses:
84
79
  metadata: {}
85
80
  post_install_message:
86
81
  rdoc_options:
87
- - --title
82
+ - "--title"
88
83
  - HighLine Documentation
89
- - --main
84
+ - "--main"
90
85
  - README
91
86
  require_paths:
92
87
  - lib
93
88
  required_ruby_version: !ruby/object:Gem::Requirement
94
89
  requirements:
95
- - - ! '>='
90
+ - - ">="
96
91
  - !ruby/object:Gem::Version
97
92
  version: '0'
98
93
  required_rubygems_version: !ruby/object:Gem::Requirement
99
94
  requirements:
100
- - - ! '>='
95
+ - - ">="
101
96
  - !ruby/object:Gem::Version
102
97
  version: '0'
103
98
  requirements: []
104
99
  rubyforge_project: highline
105
- rubygems_version: 2.0.3
100
+ rubygems_version: 2.2.2
106
101
  signing_key:
107
102
  specification_version: 4
108
103
  summary: HighLine is a high-level command-line IO library.