colorize 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 457c8133e78895d4a846061c3bb7791fb05b275c
4
- data.tar.gz: 1da070e618c773e16194c9f5b977640ff444ed5b
3
+ metadata.gz: e5c5eebff741d463a64631a114639080a071daa5
4
+ data.tar.gz: bcf92072d401eff652efd8b2535383b394e972f1
5
5
  SHA512:
6
- metadata.gz: 0bc400c6dfbe1886c313017ac912143ec34bac1f7a54d849a82dd8e62a148150e84b009f414db7ea5a706083d94e027e187e84987af7b826933e577f9993cc7e
7
- data.tar.gz: 6f56cd3b23d1338523579f2165a09645dfc691cc29a09594b1bb5b640c5284f40453143e44e48a0340918dae17872c78d7e8a9e487ba4171e8b416389ae8b7d9
6
+ metadata.gz: 7d2a1a40d37e2c928c38f0209beed07cd22f2f009aebf6c4da8d5d18b4d2e8a92e7d41ffbbcde018b78416a796dddfe0404aee38e7b892f1affafc4cb1ed9611
7
+ data.tar.gz: eddf5713fb76550945849f69fa9eefe3a4e50b82d97885838cb26e578098cab12852dc034e6ecb091cab27235c3772df182f552ae4123165d1510c6649952f16
data/colorize.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'colorize'
3
- s.version = '0.7.0'
3
+ s.version = '0.7.1'
4
4
 
5
5
  s.authors = ['fazibear']
6
6
  s.email = 'fazibear@gmail.com'
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"
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: colorize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - fazibear