highline 1.0.2 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -2,12 +2,20 @@
2
2
 
3
3
  Below is a complete listing of changes for each revision of HighLine.
4
4
 
5
+ == 1.0.4
6
+
7
+ * Moved the HighLine project to Subversion.
8
+ * HighLine's color escapes can now be disabled.
9
+ * Fixed EOF bug introduced in the last release.
10
+ * Updated HighLine web page.
11
+ * Moved to a forked development/stable version numbering.
12
+
5
13
  == 1.0.2
6
14
 
7
15
  * Removed old and broken help tests.
8
16
  * Fixed test case typo found by David A. Black.
9
17
  * Added ERb escapes processing to lists, for coloring list items. Color escapes
10
- Do nod add to list element size.
18
+ do not add to list element size.
11
19
  * HighLine now throws EOFError when input is exhausted.
12
20
 
13
21
  == 1.0.1
data/README CHANGED
@@ -27,5 +27,5 @@ See the INSTALL file for instructions.
27
27
 
28
28
  == Questions and/or Comments
29
29
 
30
- Feel free to email {James Edward Gray II}[mailto:james@grayproductions.net] with
31
- any questions.
30
+ Feel free to email {James Edward Gray II}[mailto:james@grayproductions.net] or
31
+ {Grregory Brown}[mailto:gregory.t.brown@gmail.com] with any questions.
data/Rakefile CHANGED
@@ -24,15 +24,15 @@ end
24
24
 
25
25
  desc "Upload current documentation to Rubyforge"
26
26
  task :upload_docs => [:rdoc] do
27
- sh "scp -r site/* " +
28
- "bbazzarrakk@rubyforge.org:/var/www/gforge-projects/highline/"
29
27
  sh "scp -r doc/html/* " +
30
28
  "bbazzarrakk@rubyforge.org:/var/www/gforge-projects/highline/doc/"
29
+ sh "scp -r site/* " +
30
+ "bbazzarrakk@rubyforge.org:/var/www/gforge-projects/highline/"
31
31
  end
32
32
 
33
33
  spec = Gem::Specification.new do |spec|
34
34
  spec.name = "highline"
35
- spec.version = "1.0.2"
35
+ spec.version = "1.0.4"
36
36
  spec.platform = Gem::Platform::RUBY
37
37
  spec.summary = "HighLine is a high-level line oriented console interface."
38
38
  spec.files = Dir.glob("{examples,lib,test}/**/*.rb").
data/lib/highline.rb CHANGED
@@ -6,6 +6,8 @@
6
6
  # Copyright 2005 Gray Productions. All rights reserved.
7
7
  #
8
8
  # See HighLine for documentation.
9
+ #
10
+ # This is Free Software. See LICENSE and COPYING for details
9
11
 
10
12
  require "highline/question"
11
13
  require "highline/menu"
@@ -28,6 +30,19 @@ class HighLine
28
30
  class QuestionError < StandardError
29
31
  # do nothing, just creating a unique error type
30
32
  end
33
+
34
+ # The setting used to disable color output.
35
+ @@use_color = true
36
+
37
+ # Pass +false+ to _setting_ to turn off HighLine's color escapes.
38
+ def self.use_color=( setting )
39
+ @@use_color = setting
40
+ end
41
+
42
+ # Returns true if HighLine is currently using color escapes.
43
+ def self.use_color?
44
+ @@use_color
45
+ end
31
46
 
32
47
  #
33
48
  # Embed in a String to clear all previous ANSI sequences. This *MUST* be
@@ -168,8 +183,7 @@ class HighLine
168
183
  if @question.confirm
169
184
  # need to add a layer of scope to ask a question inside a
170
185
  # question, without destroying instance data
171
- context_change = self.class.new( @input, @output,
172
- @wrap_at, @page_at )
186
+ context_change = self.class.new(@input, @output, @wrap_at, @page_at)
173
187
  if @question.confirm == true
174
188
  confirm_question = "Are you sure? "
175
189
  else
@@ -264,8 +278,13 @@ class HighLine
264
278
  # affected by. The _colors_ can be HighLine class constants, or symbols
265
279
  # (:blue for BLUE, for example). A CLEAR will automatically be embedded to
266
280
  # the end of the returned String.
281
+ #
282
+ # This method returns the original _string_ unchanged if HighLine::use_color?
283
+ # is +false+.
267
284
  #
268
285
  def color( string, *colors )
286
+ return string unless self.class.use_color?
287
+
269
288
  colors.map! do |c|
270
289
  if c.is_a?(Symbol)
271
290
  self.class.const_get(c.to_s.upcase)
@@ -523,6 +542,8 @@ class HighLine
523
542
  #
524
543
  # If Question's _readline_ property is set, that library will be used to
525
544
  # fetch input. *WARNING*: This ignores the currently set input stream.
545
+ #
546
+ # Raises EOFError if input is exhausted.
526
547
  #
527
548
  def get_line( )
528
549
  if @question.readline
@@ -549,6 +570,8 @@ class HighLine
549
570
 
550
571
  answer
551
572
  else
573
+ raise EOFError, "The input stream is exhausted." if @input.eof?
574
+
552
575
  @question.change_case(@question.remove_whitespace(@input.gets))
553
576
  end
554
577
  end
@@ -561,8 +584,6 @@ class HighLine
561
584
  # Raises EOFError if input is exhausted.
562
585
  #
563
586
  def get_response( )
564
- raise EOFError, "The input stream is exhausted." if @input.eof?
565
-
566
587
  if @question.character.nil?
567
588
  if @question.echo == true and @question.limit.nil?
568
589
  get_line
@@ -4,6 +4,8 @@
4
4
  #
5
5
  # Created by James Edward Gray II on 2005-04-26.
6
6
  # Copyright 2005 Gray Productions. All rights reserved.
7
+ #
8
+ # This is Free Software. See LICENSE and COPYING for details
7
9
 
8
10
  require "highline"
9
11
  require "forwardable"
data/lib/highline/menu.rb CHANGED
@@ -4,6 +4,8 @@
4
4
  #
5
5
  # Created by Gregory Thomas Brown on 2005-05-10.
6
6
  # Copyright 2005. All rights reserved.
7
+ #
8
+ # This is Free Software. See LICENSE and COPYING for details
7
9
 
8
10
  require "highline/question"
9
11
 
@@ -4,7 +4,9 @@
4
4
  #
5
5
  # Created by James Edward Gray II on 2005-04-26.
6
6
  # Copyright 2005 Gray Productions. All rights reserved.
7
-
7
+ #
8
+ # This is Free Software. See LICENSE and COPYING for details
9
+
8
10
  require "optparse"
9
11
  require "date"
10
12
  require "pathname"
data/test/tc_highline.rb CHANGED
@@ -4,6 +4,8 @@
4
4
  #
5
5
  # Created by James Edward Gray II on 2005-04-26.
6
6
  # Copyright 2005 Gray Productions. All rights reserved.
7
+ #
8
+ # This is Free Software. See LICENSE and COPYING for details.
7
9
 
8
10
  require "test/unit"
9
11
 
@@ -155,6 +157,15 @@ class TestHighLine < Test::Unit::TestCase
155
157
  "<%= color('blinking on red', :blink, :on_red) %>!" )
156
158
  assert_equal( "This should be \e[5m\e[41mblinking on red\e[0m!\n",
157
159
  @output.string )
160
+
161
+ @output.truncate(@output.rewind)
162
+
163
+ # turn off color
164
+ old_setting = HighLine.use_color?
165
+ assert_nothing_raised(Exception) { HighLine.use_color = false }
166
+ @terminal.say("This should be <%= color('cyan', CYAN) %>!")
167
+ assert_equal("This should be cyan!\n", @output.string)
168
+ HighLine.use_color = old_setting
158
169
  end
159
170
 
160
171
  def test_confirm
data/test/tc_import.rb CHANGED
@@ -4,6 +4,8 @@
4
4
  #
5
5
  # Created by James Edward Gray II on 2005-04-26.
6
6
  # Copyright 2005 Gray Productions. All rights reserved.
7
+ #
8
+ # This is Free Software. See LICENSE and COPYING for details.
7
9
 
8
10
  require "test/unit"
9
11
 
data/test/tc_menu.rb CHANGED
@@ -4,6 +4,8 @@
4
4
  #
5
5
  # Created by Gregory Thomas Brown on 2005-05-10.
6
6
  # Copyright 2005. All rights reserved.
7
+ #
8
+ # This is Free Software. See LICENSE and COPYING for details.
7
9
 
8
10
  require "test/unit"
9
11
 
data/test/ts_all.rb CHANGED
@@ -4,7 +4,8 @@
4
4
  #
5
5
  # Created by James Edward Gray II on 2005-04-26.
6
6
  # Copyright 2005 Gray Productions. All rights reserved.
7
-
7
+ #
8
+ # This is Free Software. See LICENSE and COPYING for details.
8
9
  require "test/unit"
9
10
 
10
11
  require "tc_highline"
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: highline
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.2
7
- date: 2006-02-20 00:00:00 -06:00
6
+ version: 1.0.4
7
+ date: 2006-02-26 00:00:00 -06:00
8
8
  summary: HighLine is a high-level line oriented console interface.
9
9
  require_paths:
10
10
  - lib