highline 1.6.15 → 1.6.16
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 +11 -3
- data/INSTALL +1 -1
- data/README.rdoc +2 -2
- data/Rakefile +2 -2
- data/examples/basic_usage.rb +2 -2
- data/examples/color_scheme.rb +2 -2
- data/examples/get_character.rb +12 -0
- data/examples/limit.rb +1 -1
- data/examples/menus.rb +2 -2
- data/examples/overwrite.rb +2 -2
- data/examples/page_and_wrap.rb +11 -11
- data/highline.gemspec +1 -0
- data/lib/highline.rb +156 -112
- data/lib/highline/color_scheme.rb +13 -13
- data/lib/highline/import.rb +4 -4
- data/lib/highline/menu.rb +64 -64
- data/lib/highline/question.rb +61 -58
- data/lib/highline/simulate.rb +1 -1
- data/lib/highline/string_extensions.rb +11 -11
- data/lib/highline/style.rb +21 -21
- data/lib/highline/system_extensions.rb +11 -9
- data/setup.rb +6 -6
- data/site/index.html +1 -1
- data/test/tc_highline.rb +91 -3
- data/test/tc_style.rb +3 -3
- metadata +5 -3
@@ -11,13 +11,13 @@ class HighLine
|
|
11
11
|
module SystemExtensions
|
12
12
|
JRUBY = defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
if JRUBY
|
15
|
+
def initialize_system_extensions
|
16
16
|
require 'java'
|
17
17
|
if JRUBY_VERSION =~ /^1.7/
|
18
18
|
java_import 'jline.console.ConsoleReader'
|
19
19
|
|
20
|
-
@java_console = ConsoleReader.new(
|
20
|
+
@java_console = ConsoleReader.new(@input.to_inputstream, @output.to_outputstream)
|
21
21
|
@java_console.set_history_enabled(false)
|
22
22
|
@java_console.set_bell_enabled(true)
|
23
23
|
@java_console.set_pagination_enabled(false)
|
@@ -28,8 +28,8 @@ class HighLine
|
|
28
28
|
java_import 'jline.ConsoleReader'
|
29
29
|
java_import 'jline.Terminal'
|
30
30
|
|
31
|
-
@java_input = Channels.newInputStream(
|
32
|
-
@java_output = OutputStreamWriter.new(Channels.newOutputStream(
|
31
|
+
@java_input = Channels.newInputStream(@input.to_channel)
|
32
|
+
@java_output = OutputStreamWriter.new(Channels.newOutputStream(@output.to_channel))
|
33
33
|
@java_terminal = Terminal.getTerminal
|
34
34
|
@java_console = ConsoleReader.new(@java_input, @java_output)
|
35
35
|
@java_console.setUseHistory(false)
|
@@ -41,10 +41,6 @@ class HighLine
|
|
41
41
|
|
42
42
|
module_function
|
43
43
|
|
44
|
-
def get_character( input = STDIN )
|
45
|
-
input.getbyte
|
46
|
-
end
|
47
|
-
|
48
44
|
#
|
49
45
|
# This section builds character reading and terminal size functions
|
50
46
|
# to suit the proper platform we're running on. Be warned: Here be
|
@@ -186,5 +182,11 @@ class HighLine
|
|
186
182
|
end
|
187
183
|
end
|
188
184
|
end
|
185
|
+
|
186
|
+
if not defined?(get_character)
|
187
|
+
def get_character( input = STDIN )
|
188
|
+
input.getbyte
|
189
|
+
end
|
190
|
+
end
|
189
191
|
end
|
190
192
|
end
|
data/setup.rb
CHANGED
@@ -538,7 +538,7 @@ module FileOperations
|
|
538
538
|
def ruby(str)
|
539
539
|
command config('rubyprog') + ' ' + str
|
540
540
|
end
|
541
|
-
|
541
|
+
|
542
542
|
def make(task = '')
|
543
543
|
command config('makeprog') + ' ' + task
|
544
544
|
end
|
@@ -629,7 +629,7 @@ module HookScriptAPI
|
|
629
629
|
def srcdirectory?(path)
|
630
630
|
File.dir?(srcfile(path))
|
631
631
|
end
|
632
|
-
|
632
|
+
|
633
633
|
def srcfile?(path)
|
634
634
|
File.file? srcfile(path)
|
635
635
|
end
|
@@ -710,7 +710,7 @@ class ToplevelInstaller
|
|
710
710
|
__send__ "exec_#{task}"
|
711
711
|
end
|
712
712
|
end
|
713
|
-
|
713
|
+
|
714
714
|
def run_metaconfigs
|
715
715
|
eval_file_ifexist "#{@ardir}/metaconfig"
|
716
716
|
end
|
@@ -775,7 +775,7 @@ class ToplevelInstaller
|
|
775
775
|
when '-v', '--version'
|
776
776
|
puts "#{File.basename($0)} version #{Version}"
|
777
777
|
exit 0
|
778
|
-
|
778
|
+
|
779
779
|
when '--copyright'
|
780
780
|
puts Copyright
|
781
781
|
exit 0
|
@@ -1197,9 +1197,9 @@ class Installer
|
|
1197
1197
|
def ruby_scripts
|
1198
1198
|
collect_filenames_auto().select {|n| /\.rb\z/ =~ n }
|
1199
1199
|
end
|
1200
|
-
|
1200
|
+
|
1201
1201
|
# picked up many entries from cvs-1.11.1/src/ignore.c
|
1202
|
-
reject_patterns = %w(
|
1202
|
+
reject_patterns = %w(
|
1203
1203
|
core RCSLOG tags TAGS .make.state
|
1204
1204
|
.nse_depinfo #* .#* cvslog.* ,* .del-* *.olb
|
1205
1205
|
*~ *.old *.bak *.BAK *.orig *.rej _$* *$
|
data/site/index.html
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
|
16
16
|
<p>Command line interfaces are meant to be easy. So why shouldn’t building
|
17
17
|
them be easy, too? HighLine provides a solid toolset to help you get
|
18
|
-
the job done cleanly so you can focus on the real task at hand,
|
18
|
+
the job done cleanly so you can focus on the real task at hand,
|
19
19
|
<em>your task.</em></p>
|
20
20
|
|
21
21
|
|
data/test/tc_highline.rb
CHANGED
@@ -69,7 +69,73 @@ class TestHighLine < Test::Unit::TestCase
|
|
69
69
|
|
70
70
|
assert_raise(EOFError) { @terminal.ask("Any input left? ", String) }
|
71
71
|
end
|
72
|
+
|
73
|
+
def test_indent
|
74
|
+
text = "Testing...\n"
|
75
|
+
@terminal.indent_level=1
|
76
|
+
@terminal.say(text)
|
77
|
+
assert_equal(' '*3+text, @output.string)
|
78
|
+
|
79
|
+
@output.truncate(@output.rewind)
|
80
|
+
@terminal.indent_level=3
|
81
|
+
@terminal.say(text)
|
82
|
+
assert_equal(' '*9+text, @output.string)
|
83
|
+
|
84
|
+
@output.truncate(@output.rewind)
|
85
|
+
@terminal.indent_level=0
|
86
|
+
@terminal.indent_size=5
|
87
|
+
@terminal.indent(2, text)
|
88
|
+
assert_equal(' '*10+text, @output.string)
|
89
|
+
|
90
|
+
@output.truncate(@output.rewind)
|
91
|
+
@terminal.indent_size=4
|
92
|
+
@terminal.indent {
|
93
|
+
@terminal.say(text)
|
94
|
+
}
|
95
|
+
assert_equal(' '*4+text, @output.string)
|
96
|
+
|
97
|
+
@output.truncate(@output.rewind)
|
98
|
+
@terminal.indent_size=2
|
99
|
+
@terminal.indent(3) { |t|
|
100
|
+
t.say(text)
|
101
|
+
}
|
102
|
+
assert_equal(' '*6+text, @output.string)
|
103
|
+
|
104
|
+
@output.truncate(@output.rewind)
|
105
|
+
@terminal.indent { |t|
|
106
|
+
t.indent {
|
107
|
+
t.indent {
|
108
|
+
t.indent { |tt|
|
109
|
+
tt.say(text)
|
110
|
+
}
|
111
|
+
}
|
112
|
+
}
|
113
|
+
}
|
114
|
+
assert_equal(' '*8+text, @output.string)
|
115
|
+
|
116
|
+
text = "Multi\nLine\nIndentation\n"
|
117
|
+
indent = ' '*4
|
118
|
+
@terminal.indent_level=2
|
119
|
+
@output.truncate(@output.rewind)
|
120
|
+
@terminal.say(text)
|
121
|
+
assert_equal("#{indent}Multi\n#{indent}Line\n#{indent}Indentation\n", @output.string)
|
122
|
+
|
123
|
+
@output.truncate(@output.rewind)
|
124
|
+
@terminal.multi_indent = false
|
125
|
+
@terminal.say(text)
|
126
|
+
assert_equal("#{indent}Multi\nLine\nIndentation\n", @output.string)
|
127
|
+
|
128
|
+
@output.truncate(@output.rewind)
|
129
|
+
@terminal.indent(0, text, true)
|
130
|
+
assert_equal("#{indent}Multi\n#{indent}Line\n#{indent}Indentation\n", @output.string)
|
131
|
+
end
|
72
132
|
|
133
|
+
def test_newline
|
134
|
+
@terminal.newline
|
135
|
+
@terminal.newline
|
136
|
+
assert_equal("\n\n", @output.string)
|
137
|
+
end
|
138
|
+
|
73
139
|
def test_bug_fixes
|
74
140
|
# auto-complete bug
|
75
141
|
@input << "ruby\nRuby\n"
|
@@ -153,10 +219,10 @@ class TestHighLine < Test::Unit::TestCase
|
|
153
219
|
@input << "\b\b"
|
154
220
|
@input.rewind
|
155
221
|
answer = @terminal.ask("Please enter your password: ") do |q|
|
156
|
-
|
222
|
+
q.echo = "*"
|
157
223
|
end
|
158
224
|
assert_equal("", answer)
|
159
|
-
assert_equal("Please enter your password: \n"
|
225
|
+
assert_equal("Please enter your password: \n", @output.string)
|
160
226
|
end
|
161
227
|
|
162
228
|
def test_readline_on_non_echo_question_has_prompt
|
@@ -167,7 +233,7 @@ class TestHighLine < Test::Unit::TestCase
|
|
167
233
|
q.echo = "*"
|
168
234
|
end
|
169
235
|
assert_equal("you can't see me", answer)
|
170
|
-
assert_equal("Please enter some hidden text: ****************\n"
|
236
|
+
assert_equal("Please enter some hidden text: ****************\n", @output.string)
|
171
237
|
end
|
172
238
|
|
173
239
|
def test_character_reading
|
@@ -839,6 +905,28 @@ class TestHighLine < Test::Unit::TestCase
|
|
839
905
|
|
840
906
|
@terminal.say("This will not have a newline. ")
|
841
907
|
assert_equal("This will not have a newline. ", @output.string)
|
908
|
+
|
909
|
+
@output.truncate(@output.rewind)
|
910
|
+
|
911
|
+
@terminal.say("This will not\n end with a newline. ")
|
912
|
+
assert_equal("This will not\n end with a newline. ", @output.string)
|
913
|
+
|
914
|
+
@output.truncate(@output.rewind)
|
915
|
+
|
916
|
+
@terminal.say("This will \nend with a newline.")
|
917
|
+
assert_equal("This will \nend with a newline.\n", @output.string)
|
918
|
+
|
919
|
+
@output.truncate(@output.rewind)
|
920
|
+
|
921
|
+
colorized = @terminal.color("This will not have a newline. ", :green)
|
922
|
+
@terminal.say(colorized)
|
923
|
+
assert_equal("\e[32mThis will not have a newline. \e[0m", @output.string)
|
924
|
+
|
925
|
+
@output.truncate(@output.rewind)
|
926
|
+
|
927
|
+
colorized = @terminal.color("This will have a newline.", :green)
|
928
|
+
@terminal.say(colorized)
|
929
|
+
assert_equal("\e[32mThis will have a newline.\e[0m\n", @output.string)
|
842
930
|
end
|
843
931
|
|
844
932
|
def test_type_conversion
|
data/test/tc_style.rb
CHANGED
@@ -379,7 +379,7 @@ class TestStyle < Test::Unit::TestCase
|
|
379
379
|
|
380
380
|
# Add a Style with a new name and code
|
381
381
|
assert_nil HighLine::Style.code_index['chewie']
|
382
|
-
|
382
|
+
HighLine::Style.new(:name=>:s8, :code=>'chewie')
|
383
383
|
assert_equal list_size+1, HighLine::Style.code_index.size
|
384
384
|
assert_instance_of Array, HighLine::Style.code_index['chewie']
|
385
385
|
assert_equal 1, HighLine::Style.code_index['chewie'].size
|
@@ -388,7 +388,7 @@ class TestStyle < Test::Unit::TestCase
|
|
388
388
|
|
389
389
|
# Add another Style with a new name and code
|
390
390
|
assert_nil HighLine::Style.code_index['c3po']
|
391
|
-
|
391
|
+
HighLine::Style.new(:name=>:s9, :code=>'c3po')
|
392
392
|
assert_equal list_size+2, HighLine::Style.code_index.size
|
393
393
|
assert_instance_of Array, HighLine::Style.code_index['c3po']
|
394
394
|
assert_equal 1, HighLine::Style.code_index['c3po'].size
|
@@ -397,7 +397,7 @@ class TestStyle < Test::Unit::TestCase
|
|
397
397
|
|
398
398
|
# Add a Style with an existing code
|
399
399
|
assert_equal 1, HighLine::Style.code_index['c3po'].size
|
400
|
-
|
400
|
+
HighLine::Style.new(:name=>:s10, :code=>'c3po')
|
401
401
|
assert_equal list_size+2, HighLine::Style.code_index.size
|
402
402
|
assert_equal 2, HighLine::Style.code_index['c3po'].size
|
403
403
|
assert_equal :s10, HighLine::Style.code_index['c3po'].last.name
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: highline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.16
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-03-15 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: ! 'A high-level IO library that provides validation, type conversion,
|
15
15
|
and more for
|
@@ -45,6 +45,7 @@ files:
|
|
45
45
|
- examples/asking_for_arrays.rb
|
46
46
|
- examples/basic_usage.rb
|
47
47
|
- examples/color_scheme.rb
|
48
|
+
- examples/get_character.rb
|
48
49
|
- examples/limit.rb
|
49
50
|
- examples/menus.rb
|
50
51
|
- examples/overwrite.rb
|
@@ -79,7 +80,8 @@ files:
|
|
79
80
|
- test/tc_style.rb
|
80
81
|
- test/ts_all.rb
|
81
82
|
homepage: http://highline.rubyforge.org
|
82
|
-
licenses:
|
83
|
+
licenses:
|
84
|
+
- Ruby
|
83
85
|
post_install_message:
|
84
86
|
rdoc_options:
|
85
87
|
- --title
|