color_echo 0.2.4 → 0.3.0
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/README.md +60 -20
- data/lib/color_echo.rb +6 -6
- data/lib/color_echo/background.module.rb +16 -8
- data/lib/color_echo/foreground.module.rb +16 -8
- data/lib/color_echo/module_functions.rb +53 -36
- data/lib/color_echo/off.module.rb +7 -0
- data/lib/color_echo/textattr.module.rb +5 -5
- data/lib/color_echo/version.rb +1 -1
- metadata +9 -7
- data/lib/color_echo/const.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 222c2ae72f62a588fc6e1f25a214bda6103e69f8
|
4
|
+
data.tar.gz: 0170867e3a2ac9f705226f2a3d86656bf1b0fcd1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bea7e278f6e1a131970bcb82d647e571610f5d8e33630a76d8f727305af5a63c3408dc1161d3aa32a83a98724e5a02fbb571f7ec3cbba83c6db51fd5e62cbaef
|
7
|
+
data.tar.gz: 5c64c7aefdf1aa03972a5ee8daeca71afe958ddeb63a64c451c0aa428115583ed1a28a77579e4f46959ab863afc78399b587b7b6a93e817c589f1929013f4d10
|
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# color_echo
|
2
|
-
|
2
|
+
Using the ANSI escape sequence and give it a color on the command line output.
|
3
3
|
This Library will extend the Kernel module's functions(#print, #puts, #p).
|
4
|
-
|
4
|
+
Required StringIO.
|
5
5
|
|
6
|
-
Version: 0.
|
6
|
+
Version: 0.3.0
|
7
7
|
Compliant Rubys Version: 1.9.3, 2.0.0, 2.1.0 (for Linux)
|
8
8
|
License: MIT
|
9
9
|
Gems repository: http://rubygems.org/gems/color_echo
|
@@ -25,6 +25,7 @@ Or install it yourself as:
|
|
25
25
|
Change the foreground color to the your specified color.
|
26
26
|
Alias is, fg
|
27
27
|
This method alias is available in version 0.2.0 on and after.
|
28
|
+
return self.
|
28
29
|
|
29
30
|
* symbol list:
|
30
31
|
* black
|
@@ -34,7 +35,17 @@ This method alias is available in version 0.2.0 on and after.
|
|
34
35
|
* blue
|
35
36
|
* magenta
|
36
37
|
* cyan
|
37
|
-
* white
|
38
|
+
* white
|
39
|
+
|
40
|
+
available in version 0.3.0 on and after.
|
41
|
+
* gray
|
42
|
+
* h_red
|
43
|
+
* h_green
|
44
|
+
* h_yellow
|
45
|
+
* h_blue
|
46
|
+
* h_magenta
|
47
|
+
* h_cyan
|
48
|
+
* h_white
|
38
49
|
|
39
50
|
ex.) CE.ch_fg :red #=> foreground color will be changed red
|
40
51
|
|
@@ -42,6 +53,7 @@ ex.) CE.ch_fg :red #=> foreground color will be changed red
|
|
42
53
|
Change the background color to the your specified color.
|
43
54
|
Alias is, bg
|
44
55
|
This method alias is available in version 0.2.0 on and after.
|
56
|
+
return self.
|
45
57
|
|
46
58
|
|
47
59
|
* symbol list:
|
@@ -53,9 +65,21 @@ This method alias is available in version 0.2.0 on and after.
|
|
53
65
|
* magenta
|
54
66
|
* cyan
|
55
67
|
* white
|
68
|
+
|
69
|
+
available in version 0.3.0 on and after.
|
70
|
+
* gray
|
71
|
+
* h_red
|
72
|
+
* h_green
|
73
|
+
* h_yellow
|
74
|
+
* h_blue
|
75
|
+
* h_magenta
|
76
|
+
* h_cyan
|
77
|
+
* h_white
|
56
78
|
|
57
79
|
ex.) CE.ch_bg :white #=> background color will be changed white
|
58
80
|
|
81
|
+
|
82
|
+
|
59
83
|
#### CE.ch_tx :symbol
|
60
84
|
Change the text attribute to the your specified decoration.
|
61
85
|
|
@@ -66,28 +90,40 @@ Change the text attribute to the your specified decoration.
|
|
66
90
|
* reverse_video
|
67
91
|
* concealed
|
68
92
|
|
69
|
-
ex.) CE.ch_tx :blink #=> text blink on
|
70
93
|
Alias is, tx
|
71
94
|
This method alias is available in version 0.2.0 on and after.
|
95
|
+
return self.
|
96
|
+
ex.) CE.ch_tx :blink #=> text blink on
|
97
|
+
|
98
|
+
|
72
99
|
|
73
|
-
#### CE.ch
|
100
|
+
#### CE.ch foreground [,background [,text_attribute]]
|
74
101
|
Change collectively.
|
75
|
-
This method is available in version 0.1.0 on and after.
|
76
102
|
ex.) CE.ch :white, :green
|
103
|
+
This method is available in version 0.1.0 on and after.
|
104
|
+
return self.
|
77
105
|
|
78
|
-
|
79
|
-
|
106
|
+
|
107
|
+
#### CE.reset([target={:fg|:bg]})
|
108
|
+
Reset to set the escape sequence.
|
80
109
|
Alias is, off, disable
|
81
110
|
This method alias is available in version 0.1.0 on and after.
|
111
|
+
Parameters can v0.3.0 on and after be specified.
|
112
|
+
ex.) CE.reset :fg #=> foreground color will be reset.
|
113
|
+
ex.) CE.reset :bg #=> background color will be reset.
|
114
|
+
ex.) CE.reset #=> All reset the set escape sequence.
|
115
|
+
return self.
|
116
|
+
|
82
117
|
|
83
118
|
#### CE.unuse
|
84
119
|
Force ignore the function of this library.
|
85
120
|
This method is available in version 0.1.0 on and after.
|
86
121
|
|
122
|
+
|
87
123
|
#### CE.rainbow
|
88
124
|
Text color will change to rainbow color.
|
89
|
-
~~String Object only. Non-string object is excluded.~~
|
90
|
-
|
125
|
+
~~String Object only. Non-string object is excluded.~~
|
126
|
+
-> Can v0.2.4 on and after be able to specify a non-string when rainbow mode.
|
91
127
|
This method is available in version 0.2.0 on and after.
|
92
128
|
|
93
129
|
### Example
|
@@ -95,7 +131,7 @@ This method is available in version 0.2.0 on and after.
|
|
95
131
|
#
|
96
132
|
# Example Code
|
97
133
|
#
|
98
|
-
require "color_echo"
|
134
|
+
#require "color_echo"
|
99
135
|
|
100
136
|
# force ignore the function of this library
|
101
137
|
#CE.unuse
|
@@ -129,7 +165,7 @@ print ary
|
|
129
165
|
CE.tx :underscore
|
130
166
|
p ary
|
131
167
|
|
132
|
-
CE.
|
168
|
+
CE.fg(:black).bg(:white).tx(:blink)
|
133
169
|
puts <<EOM
|
134
170
|
Lorem ipsum dolor sit amet,
|
135
171
|
consectetur adipisicing elit,
|
@@ -137,6 +173,7 @@ sed do eiusmod tempor incididunt
|
|
137
173
|
ut labore et dolore magna aliqua.
|
138
174
|
EOM
|
139
175
|
|
176
|
+
CE.off
|
140
177
|
CE.rainbow
|
141
178
|
puts "fooooooooo"
|
142
179
|
puts "baaaaaaaar"
|
@@ -160,8 +197,7 @@ sed do eiusmod tempor incididunt
|
|
160
197
|
ut labore et dolore magna aliqua.
|
161
198
|
EOM
|
162
199
|
|
163
|
-
CE.tx
|
164
|
-
CE.bg :black
|
200
|
+
CE.tx(:underscore).bg(:black)
|
165
201
|
CE.rainbow
|
166
202
|
hash = {:foo => [111, 222, 333], :bar => {:str => String}}
|
167
203
|
p hash
|
@@ -175,11 +211,15 @@ puts "Disable rainbow mode."
|
|
175
211
|
|
176
212
|

|
177
213
|
|
178
|
-
|
179
214
|
## Release Note
|
180
|
-
* v0.
|
181
|
-
*
|
215
|
+
* v0.3.0, 2014-12-08
|
216
|
+
* High color can now be selected.
|
217
|
+
* Multiple text attribute can now be selected.
|
218
|
+
* Add parameter to the #reset method.
|
182
219
|
|
183
220
|
* v0.2.4, 2014-12-04
|
184
|
-
*
|
185
|
-
*
|
221
|
+
* Can now be able to specify a non-string when rainbow mode.
|
222
|
+
* Cab now be able to take over the setting of other types of sequence when rainbow mode.
|
223
|
+
|
224
|
+
* v0.2.3, 2014-12-02
|
225
|
+
* Fixed small bugs.
|
data/lib/color_echo.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# color_echo
|
2
2
|
#
|
3
|
-
#
|
3
|
+
# Using the ANSI escape sequence and give it a color on the command line output.
|
4
4
|
# This Library will extend the Kernel module's functions(#print, #puts, #p).
|
5
|
-
#
|
6
|
-
|
5
|
+
# Required StringIO.
|
6
|
+
#
|
7
7
|
begin
|
8
8
|
require "stringio"
|
9
9
|
rescue LoadError
|
@@ -11,10 +11,10 @@ rescue LoadError
|
|
11
11
|
end
|
12
12
|
|
13
13
|
require_relative "color_echo/version.rb"
|
14
|
-
require_relative "color_echo/const.rb"
|
15
|
-
require_relative "color_echo/variables.rb"
|
16
|
-
require_relative "color_echo/background.module.rb"
|
17
14
|
require_relative "color_echo/foreground.module.rb"
|
15
|
+
require_relative "color_echo/background.module.rb"
|
18
16
|
require_relative "color_echo/textattr.module.rb"
|
17
|
+
require_relative "color_echo/off.module.rb"
|
18
|
+
require_relative "color_echo/variables.rb"
|
19
19
|
require_relative "color_echo/module_functions.rb"
|
20
20
|
require_relative "color_echo/override.rb"
|
@@ -1,12 +1,20 @@
|
|
1
1
|
module CE
|
2
2
|
module BackGround
|
3
|
-
BLACK
|
4
|
-
RED
|
5
|
-
GREEN
|
6
|
-
YELLOW
|
7
|
-
BLUE
|
8
|
-
MAGENTA
|
9
|
-
CYAN
|
10
|
-
WHITE
|
3
|
+
BLACK = "\033[40m"
|
4
|
+
RED = "\033[41m"
|
5
|
+
GREEN = "\033[42m"
|
6
|
+
YELLOW = "\033[43m"
|
7
|
+
BLUE = "\033[44m"
|
8
|
+
MAGENTA = "\033[45m"
|
9
|
+
CYAN = "\033[46m"
|
10
|
+
WHITE = "\033[47m"
|
11
|
+
GRAY = "\033[100m"
|
12
|
+
H_RED = "\033[101m"
|
13
|
+
H_GREEN = "\033[102m"
|
14
|
+
H_YELLOW = "\033[103m"
|
15
|
+
H_BLUE = "\033[104m"
|
16
|
+
H_MAGENTA = "\033[105m"
|
17
|
+
H_CYAN = "\033[106m"
|
18
|
+
H_WHITE = "\033[107m"
|
11
19
|
end
|
12
20
|
end
|
@@ -1,12 +1,20 @@
|
|
1
1
|
module CE
|
2
2
|
module ForeGround
|
3
|
-
BLACK
|
4
|
-
RED
|
5
|
-
GREEN
|
6
|
-
YELLOW
|
7
|
-
BLUE
|
8
|
-
MAGENTA
|
9
|
-
CYAN
|
10
|
-
WHITE
|
3
|
+
BLACK = "\033[30m"
|
4
|
+
RED = "\033[31m"
|
5
|
+
GREEN = "\033[32m"
|
6
|
+
YELLOW = "\033[33m"
|
7
|
+
BLUE = "\033[34m"
|
8
|
+
MAGENTA = "\033[35m"
|
9
|
+
CYAN = "\033[36m"
|
10
|
+
WHITE = "\033[37m"
|
11
|
+
GRAY = "\033[90m"
|
12
|
+
H_RED = "\033[91m"
|
13
|
+
H_GREEN = "\033[92m"
|
14
|
+
H_YELLOW = "\033[93m"
|
15
|
+
H_BLUE = "\033[94m"
|
16
|
+
H_MAGENTA = "\033[95m"
|
17
|
+
H_CYAN = "\033[96m"
|
18
|
+
H_WHITE = "\033[97m"
|
11
19
|
end
|
12
20
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module CE
|
2
2
|
# @return bool
|
3
3
|
def available?
|
4
|
-
return @@enable &&
|
4
|
+
return @@enable && isset?
|
5
5
|
end
|
6
6
|
|
7
7
|
# @return bool
|
8
8
|
def isset?
|
9
|
-
return @@
|
9
|
+
return get_start_code != "" || @@rainbow
|
10
10
|
end
|
11
11
|
|
12
12
|
# @return bool
|
@@ -19,51 +19,69 @@ module CE
|
|
19
19
|
@@enable = false
|
20
20
|
end
|
21
21
|
|
22
|
-
# @return
|
23
|
-
def reset
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
22
|
+
# @return self
|
23
|
+
def reset(target=nil)
|
24
|
+
if (target == :fg)
|
25
|
+
@@code_fg_color = ""
|
26
|
+
|
27
|
+
elsif (target == :bg)
|
28
|
+
@@code_bg_color = ""
|
29
|
+
|
30
|
+
else
|
31
|
+
@@code_bg_color = ""
|
32
|
+
@@code_fg_color = ""
|
33
|
+
@@code_text_attr = ""
|
34
|
+
@@code_rainbow = ""
|
35
|
+
@@rainbow = false
|
36
|
+
end
|
37
|
+
|
38
|
+
return self
|
30
39
|
end
|
31
40
|
|
32
41
|
# @param Symbol name
|
33
|
-
# @return
|
42
|
+
# @return self
|
34
43
|
def ch_fg(name)
|
35
44
|
return nil if !name.instance_of?(Symbol)
|
36
|
-
@@
|
37
|
-
@@rainbow = false if @@rainbow
|
45
|
+
@@rainbow = false if @@rainbow
|
38
46
|
@@code_fg_color = convert_to_code("ForeGround", name)
|
47
|
+
|
48
|
+
return self
|
39
49
|
end
|
40
50
|
|
41
51
|
# @param Symbol name
|
42
|
-
# @return
|
52
|
+
# @return self
|
43
53
|
def ch_bg(name)
|
44
54
|
return nil if !name.instance_of?(Symbol)
|
45
|
-
@@
|
46
|
-
@@rainbow = false if @@rainbow
|
55
|
+
@@rainbow = false if @@rainbow
|
47
56
|
@@code_bg_color = convert_to_code("BackGround", name)
|
57
|
+
|
58
|
+
return self
|
48
59
|
end
|
49
60
|
|
50
|
-
# @param
|
51
|
-
# @return
|
52
|
-
def ch_tx(
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
61
|
+
# @param array name - array of Symbols
|
62
|
+
# @return self
|
63
|
+
def ch_tx(*names)
|
64
|
+
@@rainbow = false if @@rainbow
|
65
|
+
names = names[0] if names[0].instance_of?(Array)
|
66
|
+
|
67
|
+
names.each do |name|
|
68
|
+
return nil if !name.instance_of?(Symbol)
|
69
|
+
@@code_text_attr += convert_to_code("TextAttr", name)
|
70
|
+
end
|
71
|
+
|
72
|
+
return self
|
57
73
|
end
|
58
74
|
|
59
75
|
# @param Symbol fg
|
60
76
|
# @param Symbol bg
|
61
|
-
# @param
|
62
|
-
# @return
|
63
|
-
def ch(fg, bg=nil,
|
77
|
+
# @param array txs
|
78
|
+
# @return self
|
79
|
+
def ch(fg, bg=nil, txs=nil)
|
64
80
|
ch_fg(fg)
|
65
81
|
ch_bg(bg)
|
66
|
-
ch_tx(
|
82
|
+
ch_tx(*txs)
|
83
|
+
|
84
|
+
return self
|
67
85
|
end
|
68
86
|
|
69
87
|
# return start color sequence code
|
@@ -78,7 +96,7 @@ module CE
|
|
78
96
|
|
79
97
|
# @return String
|
80
98
|
def get_reset_code
|
81
|
-
return self::
|
99
|
+
return self::Off::ALL
|
82
100
|
end
|
83
101
|
|
84
102
|
# add reset & start code to line feed code
|
@@ -92,7 +110,6 @@ module CE
|
|
92
110
|
# change mode to rainbow
|
93
111
|
# @return void
|
94
112
|
def rainbow
|
95
|
-
@@isset = true if !@@isset
|
96
113
|
@@rainbow = true
|
97
114
|
@@code_rainbow = @@code_bg_color + @@code_text_attr
|
98
115
|
end
|
@@ -112,19 +129,19 @@ module CE
|
|
112
129
|
|
113
130
|
case cnt
|
114
131
|
when 0
|
115
|
-
output += ForeGround::RED + char +
|
132
|
+
output += ForeGround::RED + char + Off::ALL + get_start_code
|
116
133
|
when 1
|
117
|
-
output += ForeGround::GREEN + char +
|
134
|
+
output += ForeGround::GREEN + char + Off::ALL + get_start_code
|
118
135
|
when 2
|
119
|
-
output += ForeGround::YELLOW + char +
|
136
|
+
output += ForeGround::YELLOW + char + Off::ALL + get_start_code
|
120
137
|
when 3
|
121
|
-
output += ForeGround::BLUE + char +
|
138
|
+
output += ForeGround::BLUE + char + Off::ALL + get_start_code
|
122
139
|
when 4
|
123
|
-
output += ForeGround::MAGENTA + char +
|
140
|
+
output += ForeGround::MAGENTA + char + Off::ALL + get_start_code
|
124
141
|
when 5
|
125
|
-
output += ForeGround::CYAN + char +
|
142
|
+
output += ForeGround::CYAN + char + Off::ALL + get_start_code
|
126
143
|
when 6
|
127
|
-
output += ForeGround::WHITE + char +
|
144
|
+
output += ForeGround::WHITE + char + Off::ALL + get_start_code
|
128
145
|
end
|
129
146
|
cnt += 1
|
130
147
|
cnt = 0 if cnt >= 7
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module CE
|
2
2
|
module TextAttr
|
3
|
-
BOLD = "\
|
4
|
-
UNDERSCORE = "\
|
5
|
-
BLINK = "\
|
6
|
-
REVERSE_VIDEO = "\
|
7
|
-
CONCEALED = "\
|
3
|
+
BOLD = "\033[1m"
|
4
|
+
UNDERSCORE = "\033[4m"
|
5
|
+
BLINK = "\033[5m"
|
6
|
+
REVERSE_VIDEO = "\033[7m"
|
7
|
+
CONCEALED = "\033[8m"
|
8
8
|
end
|
9
9
|
end
|
data/lib/color_echo/version.rb
CHANGED
metadata
CHANGED
@@ -1,19 +1,21 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: color_echo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nyanko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
14
|
-
|
13
|
+
description: |
|
14
|
+
Using the ANSI escape sequence and give it a color on the command line output.
|
15
|
+
This Library will extend the Kernel module's functions(#print, #puts, #p).
|
16
|
+
Required StringIO.
|
15
17
|
email:
|
16
|
-
-
|
18
|
+
- khotta@users.noreply.github.com
|
17
19
|
executables: []
|
18
20
|
extensions: []
|
19
21
|
extra_rdoc_files: []
|
@@ -23,9 +25,9 @@ files:
|
|
23
25
|
- lib/color_echo.rb
|
24
26
|
- lib/color_echo/alias_method.rb
|
25
27
|
- lib/color_echo/background.module.rb
|
26
|
-
- lib/color_echo/const.rb
|
27
28
|
- lib/color_echo/foreground.module.rb
|
28
29
|
- lib/color_echo/module_functions.rb
|
30
|
+
- lib/color_echo/off.module.rb
|
29
31
|
- lib/color_echo/override.rb
|
30
32
|
- lib/color_echo/textattr.module.rb
|
31
33
|
- lib/color_echo/variables.rb
|
@@ -54,5 +56,5 @@ rubyforge_project:
|
|
54
56
|
rubygems_version: 2.2.2
|
55
57
|
signing_key:
|
56
58
|
specification_version: 4
|
57
|
-
summary:
|
59
|
+
summary: Using the ANSI escape sequence and give it a color on the command line output.
|
58
60
|
test_files: []
|
data/lib/color_echo/const.rb
DELETED