highline 1.2.8 → 1.2.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/CHANGELOG +5 -0
  2. data/lib/highline.rb +7 -5
  3. data/test/tc_highline.rb +11 -0
  4. metadata +2 -2
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.2.9
6
+
7
+ * Additional work on the backspacing issue. (patch by Jeremy Hinegardner)
8
+ * Fixed Readline prompt bug. (patch by Jeremy Hinegardner)
9
+
5
10
  == 1.2.8
6
11
 
7
12
  * Fixed backspacing past the prompt and interrupting a prompt bugs.
@@ -29,7 +29,7 @@ require "abbrev"
29
29
  #
30
30
  class HighLine
31
31
  # The version of the installed library.
32
- VERSION = "1.2.8".freeze
32
+ VERSION = "1.2.9".freeze
33
33
 
34
34
  # An internal HighLine error. User code does not need to trap this.
35
35
  class QuestionError < StandardError
@@ -204,9 +204,11 @@ class HighLine
204
204
  @question ||= Question.new(question, answer_type, &details)
205
205
 
206
206
  return gather if @question.gather
207
-
208
- # readline() needs to handle it's own output
209
- say(@question) unless @question.readline
207
+
208
+ # readline() needs to handle it's own output, but readline only supports
209
+ # full line reading. Therefore if @question.echo is anything but true,
210
+ # the prompt will not be issued. And we have to account for that now.
211
+ say(@question) unless (@question.readline and @question.echo == true)
210
212
  begin
211
213
  @answer = @question.answer_or_default(get_response)
212
214
  unless @question.valid_answer?(@answer)
@@ -624,7 +626,7 @@ class HighLine
624
626
  backspace_limit -= 1
625
627
  else
626
628
  line << character.chr
627
- backspace_limit += 1
629
+ backspace_limit = line.size
628
630
  end
629
631
  # looking for carriage return (decimal 13) or
630
632
  # newline (decimal 10) in raw input
@@ -143,6 +143,17 @@ class TestHighLine < Test::Unit::TestCase
143
143
  assert_equal("Please enter your password: \n",@output.string)
144
144
  end
145
145
 
146
+ def test_readline_on_non_echo_question_has_prompt
147
+ @input << "you can't see me"
148
+ @input.rewind
149
+ answer = @terminal.ask("Please enter some hidden text: ") do |q|
150
+ q.readline = true
151
+ q.echo = "*"
152
+ end
153
+ assert_equal("you can't see me", answer)
154
+ assert_equal("Please enter some hidden text: ****************\n",@output.string)
155
+ end
156
+
146
157
  def test_character_reading
147
158
  # WARNING: This method does NOT cover Unix and Windows savvy testing!
148
159
  @input << "12345"
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: highline
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.2.8
7
- date: 2007-06-20 00:00:00 -05:00
6
+ version: 1.2.9
7
+ date: 2007-06-21 00:00:00 -05:00
8
8
  summary: HighLine is a high-level command-line IO library.
9
9
  require_paths:
10
10
  - lib