colorize 0.7.0 → 0.7.1
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.
- checksums.yaml +4 -4
- data/colorize.gemspec +1 -1
- data/lib/colorize.rb +5 -5
- data/test/test_colorize.rb +10 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5c5eebff741d463a64631a114639080a071daa5
|
4
|
+
data.tar.gz: bcf92072d401eff652efd8b2535383b394e972f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d2a1a40d37e2c928c38f0209beed07cd22f2f009aebf6c4da8d5d18b4d2e8a92e7d41ffbbcde018b78416a796dddfe0404aee38e7b892f1affafc4cb1ed9611
|
7
|
+
data.tar.gz: eddf5713fb76550945849f69fa9eefe3a4e50b82d97885838cb26e578098cab12852dc034e6ecb091cab27235c3772df182f552ae4123165d1510c6649952f16
|
data/colorize.gemspec
CHANGED
data/lib/colorize.rb
CHANGED
@@ -75,11 +75,11 @@ class String
|
|
75
75
|
match[3] ||= match[4]
|
76
76
|
|
77
77
|
if (params.instance_of?(Hash))
|
78
|
-
match[0] = MODES[params[:mode]] if params[:mode]
|
79
|
-
match[1] = COLORS[params[:color]] + COLOR_OFFSET if params[:color]
|
80
|
-
match[2] = COLORS[params[:background]] + BACKGROUND_OFFSET if params[:background]
|
81
|
-
elsif (params.instance_of?(Symbol))
|
82
|
-
match[1] = COLORS[params] +COLOR_OFFSET if params
|
78
|
+
match[0] = MODES[params[:mode]] if params[:mode] && MODES[params[:mode]]
|
79
|
+
match[1] = COLORS[params[:color]] + COLOR_OFFSET if params[:color] && COLORS[params[:color]]
|
80
|
+
match[2] = COLORS[params[:background]] + BACKGROUND_OFFSET if params[:background] && COLORS[params[:background]]
|
81
|
+
elsif (params.instance_of?(Symbol)) && params
|
82
|
+
match[1] = COLORS[params] + COLOR_OFFSET if params && COLORS[params]
|
83
83
|
end
|
84
84
|
|
85
85
|
str << "\033[#{match[0]};#{match[1]};#{match[2]}m#{match[3]}\033[0m"
|
data/test/test_colorize.rb
CHANGED
@@ -5,6 +5,16 @@ class TestColorize < Test::Unit::TestCase
|
|
5
5
|
assert 'This is blue'.colorize(:blue) == "\e[0;34;49mThis is blue\e[0m"
|
6
6
|
end
|
7
7
|
|
8
|
+
def test_incorrect_symbol
|
9
|
+
assert 'This is incorrect color'.colorize(:bold) == "\e[0;39;49mThis is incorrect color\e[0m"
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_incorrect_hash
|
13
|
+
assert 'This is incorrect color'.colorize(:color => :bold) == "\e[0;39;49mThis is incorrect color\e[0m"
|
14
|
+
assert 'This is incorrect color'.colorize(:mode => :green) == "\e[0;39;49mThis is incorrect color\e[0m"
|
15
|
+
assert 'This is incorrect color'.colorize(:background => :bold) == "\e[0;39;49mThis is incorrect color\e[0m"
|
16
|
+
end
|
17
|
+
|
8
18
|
def test_blue_hash
|
9
19
|
assert 'This is also blue'.colorize(:color => :blue) == "\e[0;34;49mThis is also blue\e[0m"
|
10
20
|
end
|