summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbinoam P. Marques Jr <abinoam@gmail.com>2017-09-24 22:23:10 -0300
committerAbinoam P. Marques Jr <abinoam@gmail.com>2017-09-25 06:50:59 -0300
commite5d8c9a7301a0e5c219feb8218e3fff35475a732 (patch)
tree678009a68309cf8364abce448727d521ceb230a0
parent7e5df1b2848f8c2b4058f67398962ab123c97e95 (diff)
downloadhighline-e5d8c9a7301a0e5c219feb8218e3fff35475a732.tar.gz
Revert %i use for 1.9 compatibility
-rw-r--r--examples/color_scheme.rb4
-rw-r--r--lib/highline/color_scheme.rb12
-rwxr-xr-xlib/highline/question.rb8
-rw-r--r--test/test_color_scheme.rb10
-rwxr-xr-xtest/test_highline.rb6
-rwxr-xr-xtest/test_style.rb8
6 files changed, 24 insertions, 24 deletions
diff --git a/examples/color_scheme.rb b/examples/color_scheme.rb
index cde2575..215a595 100644
--- a/examples/color_scheme.rb
+++ b/examples/color_scheme.rb
@@ -11,8 +11,8 @@ require "highline/import"
# Create a color scheme, naming color patterns with symbol names.
ft = HighLine::ColorScheme.new do |cs|
- cs[:headline] = %i[bold yellow on_black]
- cs[:horizontal_line] = %i[bold white on_blue]
+ cs[:headline] = [:bold, :yellow, :on_black]
+ cs[:horizontal_line] = [:bold, :white, :on_blue]
cs[:even_row] = [:green]
cs[:odd_row] = [:magenta]
end
diff --git a/lib/highline/color_scheme.rb b/lib/highline/color_scheme.rb
index 414ebb1..e1bec88 100644
--- a/lib/highline/color_scheme.rb
+++ b/lib/highline/color_scheme.rb
@@ -130,12 +130,12 @@ class HighLine
# A sample ColorScheme.
class SampleColorScheme < ColorScheme
SAMPLE_SCHEME = {
- critical: %i[yellow on_red],
- error: %i[bold red],
- warning: %i[bold yellow],
- notice: %i[bold magenta],
- info: %i[bold cyan],
- debug: %i[bold green],
+ critical: [:yellow, :on_red],
+ error: [:bold, :red],
+ warning: [:bold, :yellow],
+ notice: [:bold, :magenta],
+ info: [:bold, :cyan],
+ debug: [:bold, :green],
row_even: [:cyan],
row_odd: [:magenta]
}.freeze
diff --git a/lib/highline/question.rb b/lib/highline/question.rb
index d94df9a..f93d4d1 100755
--- a/lib/highline/question.rb
+++ b/lib/highline/question.rb
@@ -307,9 +307,9 @@ class HighLine
# @return [String] upcased, downcased, capitalized
# or unchanged answer String.
def change_case(answer_string)
- if %i[up upcase].include?(@case)
+ if [:up, :upcase].include?(@case)
answer_string.upcase
- elsif %i[down downcase].include?(@case)
+ elsif [:down, :downcase].include?(@case)
answer_string.downcase
elsif @case == :capitalize
answer_string.capitalize
@@ -432,11 +432,11 @@ class HighLine
def remove_whitespace(answer_string)
if !whitespace
answer_string
- elsif %i[strip chomp].include?(whitespace)
+ elsif [:strip, :chomp].include?(whitespace)
answer_string.send(whitespace)
elsif whitespace == :collapse
answer_string.gsub(/\s+/, " ")
- elsif %i[strip_and_collapse chomp_and_collapse].include?(whitespace)
+ elsif [:strip_and_collapse, :chomp_and_collapse].include?(whitespace)
result = answer_string.send(whitespace.to_s[/^[a-z]+/])
result.gsub(/\s+/, " ")
elsif whitespace == :remove
diff --git a/test/test_color_scheme.rb b/test/test_color_scheme.rb
index 0040790..0716327 100644
--- a/test/test_color_scheme.rb
+++ b/test/test_color_scheme.rb
@@ -77,10 +77,10 @@ class TestColorScheme < Minitest::Test
assert_instance_of Array, defn2
assert_instance_of Array, defn3
assert_instance_of Array, defn4
- assert_equal %i[bold yellow], defn1
- assert_equal %i[bold yellow], defn2
- assert_equal %i[bold yellow], defn3
- assert_equal %i[bold yellow], defn4
+ assert_equal [:bold, :yellow], defn1
+ assert_equal [:bold, :yellow], defn2
+ assert_equal [:bold, :yellow], defn3
+ assert_equal [:bold, :yellow], defn4
assert_nil HighLine.color_scheme.definition(:nonexistent)
color_scheme_hash = HighLine.color_scheme.to_hash
@@ -89,7 +89,7 @@ class TestColorScheme < Minitest::Test
info debug row_even row_odd].sort,
color_scheme_hash.keys.sort
assert_instance_of Array, HighLine.color_scheme.definition(:warning)
- assert_equal %i[bold yellow], HighLine.color_scheme.definition(:warning)
+ assert_equal [:bold, :yellow], HighLine.color_scheme.definition(:warning)
# turn it back off, should raise an exception
HighLine.color_scheme = nil
diff --git a/test/test_highline.rb b/test/test_highline.rb
index e215986..eca4670 100755
--- a/test/test_highline.rb
+++ b/test/test_highline.rb
@@ -212,7 +212,7 @@ class TestHighLine < Minitest::Test
@input << "ruby\nRuby\n"
@input.rewind
- languages = %i[Perl Python Ruby]
+ languages = [:Perl, :Python, :Ruby]
answer = @terminal.ask("What is your favorite programming language? ",
languages)
assert_equal(languages.last, answer)
@@ -1388,7 +1388,7 @@ class TestHighLine < Minitest::Test
@input.rewind
@output.truncate(@output.rewind)
- answer = @terminal.ask("Select a mode: ", %i[generate gentle])
+ answer = @terminal.ask("Select a mode: ", [:generate, :gentle])
assert_instance_of(Symbol, answer)
assert_equal(:generate, answer)
assert_equal("Select a mode: " \
@@ -1539,7 +1539,7 @@ class TestHighLine < Minitest::Test
@input << "gen\n"
@input.rewind
- answer = @terminal.ask("Select a mode: ", %i[generate run])
+ answer = @terminal.ask("Select a mode: ", [:generate, :run])
assert_instance_of(Symbol, answer)
assert_equal(:generate, answer)
end
diff --git a/test/test_style.rb b/test/test_style.rb
index f8babbd..3f3e288 100755
--- a/test/test_style.rb
+++ b/test/test_style.rb
@@ -20,7 +20,7 @@ class TestStyle < Minitest::Test
@terminal = HighLine.new(@input, @output)
@style1 = HighLine::Style.new(name: :foo, code: "\e[99m", rgb: [1, 2, 3])
@style2 = HighLine::Style.new(name: :lando, code: "\e[98m")
- @style3 = HighLine::Style.new(name: %i[foo lando], list: %i[foo lando])
+ @style3 = HighLine::Style.new(name: [:foo, :lando], list: [:foo, :lando])
@style4 = HighLine::Style(:rgb_654321)
@added_styles_on_setup = 4 # update here if added more styles
@added_codes_to_index = 3 # :foo, :lando and :rgb_654321
@@ -127,7 +127,7 @@ class TestStyle < Minitest::Test
# Create a style list
s1 = HighLine.Style(:bold, :red)
assert_instance_of HighLine::Style, s1
- assert_equal %i[bold red], s1.list
+ assert_equal [:bold, :red], s1.list
# Find an existing style list
s2 = HighLine.Style(:bold, :red)
@@ -137,7 +137,7 @@ class TestStyle < Minitest::Test
# Create a style list with nils
s1 = HighLine.Style(:underline, nil, :blue)
assert_instance_of HighLine::Style, s1
- assert_equal %i[underline blue], s1.list
+ assert_equal [:underline, :blue], s1.list
# Raise an error for an undefined style
assert_raises(::NameError) { HighLine.Style(:fubar) }
@@ -153,7 +153,7 @@ class TestStyle < Minitest::Test
s = HighLine.Style(:critical)
assert_instance_of HighLine::Style, s
assert_equal :critical, s.name
- assert_equal %i[yellow on_red], s.list
+ assert_equal [:yellow, :on_red], s.list
end
def test_builtin_foreground_colors_defined