colorize 0.7.1 → 0.7.2
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/CHANGELOG +7 -0
- data/colorize.gemspec +2 -4
- data/lib/colorize.rb +1 -1
- data/test/test_colorize.rb +41 -23
- metadata +2 -4
- data/test/test_helper.rb +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 08a6c1aa3ca40c8747c5fb2f38e09e1917226416
|
4
|
+
data.tar.gz: faf34c7659e88abdf6eeab8d3edd2f4e7cc17cbc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 730baa609cc36db7c9e414a3496adbc8cccdda637a9baaf73103f72ec377ef3a99e9e550bf9ec08f88ac27926d491e62cfd9c4d4cf488984c66d76d9aa57d965
|
7
|
+
data.tar.gz: b194e1444dff7a82ea0e24ade7627c215549136b8816da892a268f988af57e10f70eade5e3add0f8f730a197a50e776414ebf8740c8b2ea5287455aeba29fd48
|
data/CHANGELOG
CHANGED
data/colorize.gemspec
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'colorize'
|
3
|
-
s.version = '0.7.
|
3
|
+
s.version = '0.7.2'
|
4
4
|
|
5
5
|
s.authors = ['fazibear']
|
6
6
|
s.email = 'fazibear@gmail.com'
|
7
7
|
|
8
|
-
s.date =
|
8
|
+
s.date = Time.now.strftime("%Y-%m-%d")
|
9
9
|
|
10
10
|
s.homepage = 'http://github.com/fazibear/colorize'
|
11
11
|
s.description = 'Ruby String class extension. Adds methods to set text color, background color and, text effects on ruby console and command line output, using ANSI escape sequences.'
|
@@ -22,10 +22,8 @@ Gem::Specification.new do |s|
|
|
22
22
|
'colorize.gemspec',
|
23
23
|
'lib/colorize.rb',
|
24
24
|
'test/test_colorize.rb',
|
25
|
-
'test/test_helper.rb'
|
26
25
|
]
|
27
26
|
s.test_files = [
|
28
|
-
'test/test_helper.rb',
|
29
27
|
'test/test_colorize.rb'
|
30
28
|
]
|
31
29
|
end
|
data/lib/colorize.rb
CHANGED
@@ -78,7 +78,7 @@ class String
|
|
78
78
|
match[0] = MODES[params[:mode]] if params[:mode] && MODES[params[:mode]]
|
79
79
|
match[1] = COLORS[params[:color]] + COLOR_OFFSET if params[:color] && COLORS[params[:color]]
|
80
80
|
match[2] = COLORS[params[:background]] + BACKGROUND_OFFSET if params[:background] && COLORS[params[:background]]
|
81
|
-
elsif (params.instance_of?(Symbol))
|
81
|
+
elsif (params.instance_of?(Symbol))
|
82
82
|
match[1] = COLORS[params] + COLOR_OFFSET if params && COLORS[params]
|
83
83
|
end
|
84
84
|
|
data/test/test_colorize.rb
CHANGED
@@ -1,66 +1,84 @@
|
|
1
|
-
require
|
1
|
+
require 'test/unit'
|
2
|
+
require File.dirname(__FILE__) + '/../lib/colorize'
|
2
3
|
|
3
4
|
class TestColorize < Test::Unit::TestCase
|
4
5
|
def test_blue_symbol
|
5
|
-
|
6
|
+
assert_equal 'This is blue'.colorize(:blue),
|
7
|
+
"\e[0;34;49mThis is blue\e[0m"
|
6
8
|
end
|
7
9
|
|
8
10
|
def test_incorrect_symbol
|
9
|
-
|
11
|
+
assert_equal 'This is incorrect color'.colorize(:bold),
|
12
|
+
"\e[0;39;49mThis is incorrect color\e[0m"
|
10
13
|
end
|
11
|
-
|
14
|
+
|
12
15
|
def test_incorrect_hash
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
+
assert_equal 'This is incorrect color'.colorize(:color => :bold),
|
17
|
+
"\e[0;39;49mThis is incorrect color\e[0m"
|
18
|
+
|
19
|
+
assert_equal 'This is incorrect color'.colorize(:mode => :green),
|
20
|
+
"\e[0;39;49mThis is incorrect color\e[0m"
|
21
|
+
|
22
|
+
assert_equal 'This is incorrect color'.colorize(:background => :bold),
|
23
|
+
"\e[0;39;49mThis is incorrect color\e[0m"
|
16
24
|
end
|
17
25
|
|
18
26
|
def test_blue_hash
|
19
|
-
|
27
|
+
assert_equal 'This is also blue'.colorize(:color => :blue),
|
28
|
+
"\e[0;34;49mThis is also blue\e[0m"
|
20
29
|
end
|
21
30
|
|
22
31
|
def test_light_blue_symbol
|
23
|
-
|
32
|
+
assert_equal 'This is light blue'.colorize(:light_blue),
|
33
|
+
"\e[0;94;49mThis is light blue\e[0m"
|
24
34
|
end
|
25
35
|
|
26
36
|
def test_light_blue_with_red_background_hash
|
27
|
-
|
37
|
+
assert_equal 'This is light blue with red background'.colorize(:color => :light_blue, :background => :red),
|
38
|
+
"\e[0;94;41mThis is light blue with red background\e[0m"
|
28
39
|
end
|
29
|
-
|
40
|
+
|
30
41
|
def test_light_blue_with_red_background_symbol_and_hash
|
31
|
-
|
42
|
+
assert_equal 'This is light blue with red background'.colorize(:light_blue).colorize(:background => :red),
|
43
|
+
"\e[0;94;41mThis is light blue with red background\e[0m"
|
32
44
|
end
|
33
|
-
|
45
|
+
|
34
46
|
def test_blue_with_red_background_method
|
35
|
-
|
47
|
+
assert_equal 'This is blue text on red'.blue.on_red,
|
48
|
+
"\e[0;34;41mThis is blue text on red\e[0m"
|
36
49
|
end
|
37
50
|
|
38
51
|
def test_red_with_blue_background_symbol_and_method
|
39
|
-
|
52
|
+
assert_equal 'This is red on blue'.colorize(:red).on_blue,
|
53
|
+
"\e[0;31;44mThis is red on blue\e[0m"
|
40
54
|
end
|
41
55
|
|
42
56
|
def test_red_with_blue_background_and_underline_sumbol_and_methods
|
43
|
-
|
57
|
+
assert_equal 'This is red on blue and underline'.colorize(:red).on_blue.underline,
|
58
|
+
"\e[4;31;44mThis is red on blue and underline\e[0m"
|
44
59
|
end
|
45
60
|
|
46
61
|
def test_blue_with_red_background_and_blink_methods
|
47
|
-
|
62
|
+
assert_equal 'This is blue text on red'.blue.on_red.blink,
|
63
|
+
"\e[5;34;41mThis is blue text on red\e[0m"
|
48
64
|
end
|
49
65
|
|
50
66
|
def test_uncolorize
|
51
|
-
|
67
|
+
assert_equal 'This is uncolorized'.blue.on_red.uncolorize,
|
68
|
+
"This is uncolorized"
|
52
69
|
end
|
53
70
|
|
54
71
|
def test_colorized?
|
55
|
-
|
56
|
-
|
57
|
-
|
72
|
+
assert_equal 'Red'.red.colorized?, true
|
73
|
+
assert_equal 'Blue'.colorized?, false
|
74
|
+
assert_equal 'Green'.blue.green.uncolorize.colorized?, false
|
58
75
|
end
|
59
76
|
|
60
77
|
def test_concatenated_strings_on_green
|
61
|
-
|
78
|
+
assert_equal ('none' + 'red'.red + 'none' + 'blue'.blue + 'none').on_green,
|
79
|
+
"\e[0;39;42mnone\e[0m\e[0;31;42mred\e[0m\e[0;39;42mnone\e[0m\e[0;34;42mblue\e[0m\e[0;39;42mnone\e[0m"
|
62
80
|
end
|
63
|
-
|
81
|
+
|
64
82
|
def test_concatenated_strings_uncolorize
|
65
83
|
assert ('none' + 'red'.red + 'none' + 'blue'.blue + 'none').uncolorize == "nonerednonebluenone"
|
66
84
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: colorize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fazibear
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Ruby String class extension. Adds methods to set text color, background
|
14
14
|
color and, text effects on ruby console and command line output, using ANSI escape
|
@@ -25,7 +25,6 @@ files:
|
|
25
25
|
- colorize.gemspec
|
26
26
|
- lib/colorize.rb
|
27
27
|
- test/test_colorize.rb
|
28
|
-
- test/test_helper.rb
|
29
28
|
homepage: http://github.com/fazibear/colorize
|
30
29
|
licenses:
|
31
30
|
- GPL-2
|
@@ -51,5 +50,4 @@ signing_key:
|
|
51
50
|
specification_version: 4
|
52
51
|
summary: Add color methods to String class
|
53
52
|
test_files:
|
54
|
-
- test/test_helper.rb
|
55
53
|
- test/test_colorize.rb
|
data/test/test_helper.rb
DELETED