malysz87-highline 1.5.9 → 1.5.10
Sign up to get free protection for your applications and to get access to all the features.
- data/examples/ansi_colors.rb +38 -0
- data/examples/asking_for_arrays.rb +18 -0
- data/examples/basic_usage.rb +75 -0
- data/examples/color_scheme.rb +32 -0
- data/examples/menus.rb +65 -0
- data/examples/overwrite.rb +19 -0
- data/examples/page_and_wrap.rb +322 -0
- data/examples/password.rb +7 -0
- data/examples/trapping_eof.rb +22 -0
- data/examples/using_readline.rb +17 -0
- data/lib/highline/color_scheme.rb +120 -0
- data/lib/highline/import.rb +43 -0
- data/lib/highline/menu.rb +395 -0
- data/lib/highline/question.rb +514 -0
- data/lib/highline/system_extensions.rb +130 -0
- data/lib/highline.rb +762 -0
- data/test/tc_color_scheme.rb +56 -0
- data/test/tc_highline.rb +839 -0
- data/test/tc_import.rb +54 -0
- data/test/tc_menu.rb +429 -0
- metadata +26 -4
@@ -0,0 +1,56 @@
|
|
1
|
+
#!/usr/local/bin/ruby -w
|
2
|
+
|
3
|
+
# tc_color_scheme.rb
|
4
|
+
#
|
5
|
+
# Created by Jeremy Hinegardner on 2007-01-24.
|
6
|
+
# Copyright 2007 Jeremy Hinegardner. All rights reserved.
|
7
|
+
#
|
8
|
+
# This is Free Software. See LICENSE and COPYING for details.
|
9
|
+
|
10
|
+
require "test/unit"
|
11
|
+
|
12
|
+
require "highline"
|
13
|
+
require "stringio"
|
14
|
+
|
15
|
+
class TestColorScheme < Test::Unit::TestCase
|
16
|
+
def setup
|
17
|
+
@input = StringIO.new
|
18
|
+
@output = StringIO.new
|
19
|
+
@terminal = HighLine.new(@input, @output)
|
20
|
+
|
21
|
+
@old_color_scheme = HighLine.color_scheme
|
22
|
+
end
|
23
|
+
|
24
|
+
def teardown
|
25
|
+
HighLine.color_scheme = @old_color_scheme
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_using_color_scheme
|
29
|
+
assert_equal(false,HighLine.using_color_scheme?)
|
30
|
+
|
31
|
+
HighLine.color_scheme = HighLine::ColorScheme.new
|
32
|
+
assert_equal(true,HighLine.using_color_scheme?)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_scheme
|
36
|
+
HighLine.color_scheme = HighLine::SampleColorScheme.new
|
37
|
+
|
38
|
+
@terminal.say("This should be <%= color('warning yellow', :warning) %>.")
|
39
|
+
assert_equal("This should be \e[1m\e[33mwarning yellow\e[0m.\n",@output.string)
|
40
|
+
@output.rewind
|
41
|
+
|
42
|
+
@terminal.say("This should be <%= color('warning yellow', 'warning') %>.")
|
43
|
+
assert_equal("This should be \e[1m\e[33mwarning yellow\e[0m.\n",@output.string)
|
44
|
+
@output.rewind
|
45
|
+
|
46
|
+
@terminal.say("This should be <%= color('warning yellow', 'WarNing') %>.")
|
47
|
+
assert_equal("This should be \e[1m\e[33mwarning yellow\e[0m.\n",@output.string)
|
48
|
+
@output.rewind
|
49
|
+
|
50
|
+
# turn it back off, should raise an exception
|
51
|
+
HighLine.color_scheme = @old_color_scheme
|
52
|
+
assert_raises(NameError) {
|
53
|
+
@terminal.say("This should be <%= color('nothing at all', :error) %>.")
|
54
|
+
}
|
55
|
+
end
|
56
|
+
end
|