highline 1.4.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  Below is a complete listing of changes for each revision of HighLine.
4
4
 
5
+ == 1.5.0
6
+
7
+ * Fixed a bug that would prevent Readline from showing all completions.
8
+ (reported by Yaohan Chen)
9
+ * Added the ability to pass a block to HighLine#agree().
10
+ (patch by Yaohan Chen)
11
+
5
12
  == 1.4.0
6
13
 
7
14
  * Made the code grabbing terminal size a little more cross-platform by
@@ -9,7 +9,7 @@ require "rubygems"
9
9
  require "highline/import"
10
10
 
11
11
  loop do
12
- cmd = ask("Enter command: ", %w{save load reset quit}) do |q|
12
+ cmd = ask("Enter command: ", %w{save sample load reset quit}) do |q|
13
13
  q.readline = true
14
14
  end
15
15
  say("Executing \"#{cmd}\"...")
@@ -29,7 +29,7 @@ require "abbrev"
29
29
  #
30
30
  class HighLine
31
31
  # The version of the installed library.
32
- VERSION = "1.4.0".freeze
32
+ VERSION = "1.5.0".freeze
33
33
 
34
34
  # An internal HighLine error. User code does not need to trap this.
35
35
  class QuestionError < StandardError
@@ -173,7 +173,8 @@ class HighLine
173
173
  # A shortcut to HighLine.ask() a question that only accepts "yes" or "no"
174
174
  # answers ("y" and "n" are allowed) and returns +true+ or +false+
175
175
  # (+true+ for "yes"). If provided a +true+ value, _character_ will cause
176
- # HighLine to fetch a single character response.
176
+ # HighLine to fetch a single character response. A block can be provided
177
+ # to further configure the question as in HighLine.ask()
177
178
  #
178
179
  # Raises EOFError if input is exhausted.
179
180
  #
@@ -183,6 +184,8 @@ class HighLine
183
184
  q.responses[:not_valid] = 'Please enter "yes" or "no".'
184
185
  q.responses[:ask_on_error] = :question
185
186
  q.character = character
187
+
188
+ yield q if block_given?
186
189
  end
187
190
  end
188
191
 
@@ -577,8 +580,9 @@ class HighLine
577
580
  @output = old_output
578
581
 
579
582
  # prep auto-completion
580
- completions = @question.selection.abbrev
581
- Readline.completion_proc = lambda { |string| completions[string] }
583
+ Readline.completion_proc = lambda do |string|
584
+ @question.selection.grep(/\A#{Regexp.escape(string)}/)
585
+ end
582
586
 
583
587
  # work-around ugly readline() warnings
584
588
  old_verbose = $VERBOSE
@@ -44,6 +44,14 @@ class TestHighLine < Test::Unit::TestCase
44
44
  assert_equal(true, @terminal.agree("Yes or no? ", :getc))
45
45
  end
46
46
 
47
+ def test_agree_with_block
48
+ @input << "\n\n"
49
+ @input.rewind
50
+
51
+ assert_equal(true, @terminal.agree("Yes or no? ") { |q| q.default = "y" })
52
+ assert_equal(false, @terminal.agree("Yes or no? ") { |q| q.default = "n" })
53
+ end
54
+
47
55
  def test_ask
48
56
  name = "James Edward Gray II"
49
57
  @input << name << "\n"
metadata CHANGED
@@ -1,33 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.4
3
- specification_version: 1
4
2
  name: highline
5
3
  version: !ruby/object:Gem::Version
6
- version: 1.4.0
7
- date: 2007-08-07 00:00:00 -05:00
8
- summary: HighLine is a high-level command-line IO library.
9
- require_paths:
10
- - lib
11
- email: james@grayproductions.net
12
- homepage: http://highline.rubyforge.org
13
- rubyforge_project: highline
14
- description: A high-level IO library that provides validation, type conversion, and more for command-line interfaces. HighLine also includes a complete menu system that can crank out anything from simple list selection to complete shells with just minutes of work.
15
- autorequire:
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
4
+ version: 1.5.0
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
6
  authors:
30
7
  - James Edward Gray II
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-11-05 00:00:00 -06:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: A high-level IO library that provides validation, type conversion, and more for command-line interfaces. HighLine also includes a complete menu system that can crank out anything from simple list selection to complete shells with just minutes of work.
17
+ email: james@grayproductions.net
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README
24
+ - INSTALL
25
+ - TODO
26
+ - CHANGELOG
27
+ - LICENSE
31
28
  files:
32
29
  - examples/ansi_colors.rb
33
30
  - examples/asking_for_arrays.rb
@@ -57,24 +54,34 @@ files:
57
54
  - TODO
58
55
  - CHANGELOG
59
56
  - LICENSE
60
- test_files:
61
- - test/ts_all.rb
57
+ has_rdoc: true
58
+ homepage: http://highline.rubyforge.org
59
+ post_install_message:
62
60
  rdoc_options:
63
61
  - --title
64
62
  - HighLine Documentation
65
63
  - --main
66
64
  - README
67
- extra_rdoc_files:
68
- - README
69
- - INSTALL
70
- - TODO
71
- - CHANGELOG
72
- - LICENSE
73
- executables: []
74
-
75
- extensions: []
76
-
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: "0"
72
+ version:
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: "0"
78
+ version:
77
79
  requirements: []
78
80
 
79
- dependencies: []
80
-
81
+ rubyforge_project: highline
82
+ rubygems_version: 1.3.1
83
+ signing_key:
84
+ specification_version: 2
85
+ summary: HighLine is a high-level command-line IO library.
86
+ test_files:
87
+ - test/ts_all.rb