color_echo 0.2.1 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 20f0a1335862325dff3433310f6d1b45280f35a7
4
- data.tar.gz: 2c01eb7e252a8a2d7040ce0cfd62e45094ca9b3a
3
+ metadata.gz: 8bb34e234d1acce0b26eda0cfac75c2bc98f7b7f
4
+ data.tar.gz: 81bfc6f30d698dbd09bb4e7fed2a141e0e499468
5
5
  SHA512:
6
- metadata.gz: 3b582122725922b6118c7b08cb9e0dc9d6fb70c248dc2ba66e733e715a034f12f5d4b1451d857fe6e93fddb73e258e712b525baee82d7c1fa38f1383cd2d5e69
7
- data.tar.gz: ce0641f425d46376657872e46c21e4505576f8bd4d530109ffb0633515e3d6c93cf73fb4334f8d8b1aa9cd501a921e3577823d3b68a33b260430cb6d3c1401c0
6
+ metadata.gz: bc1963db6bdf205aae374a8e7cc7c4dc62de956e5f2af09db53e9d6391356a5378ae2947c22c330bf2b5a8b63e0bd054c909f55e5b3665b1f499ba0f387e31cd
7
+ data.tar.gz: 9a42346beef4d45057fbe4f927096d5d2fafc2c3d8ecf3eef41e9b802cfc5f632630a815324a4cf81c2e9eec2ca6fcd516f12a22d8cd9c0157dddcf66ac54248
data/README.md CHANGED
@@ -3,7 +3,7 @@ To add color to 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.2.1
6
+ Version: 0.2.2
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
@@ -137,6 +137,14 @@ CE.rainbow
137
137
  puts "String will be rainbow! You can specify the argument only one."
138
138
  puts ["rainbow", "is", "String", "only"]
139
139
  puts "this is rainbow.", "This argument is ignored when rainbow mode."
140
+
141
+ CE.rainbow
142
+ puts <<EOS
143
+ aaaaaaaaaaaaaaaaaaa
144
+ aaaaaaaaaaaaaaaaaaa
145
+ aaaaaaaaaaaaaaaaaaa
146
+ EOS
147
+
140
148
  CE.off
141
149
  puts "Disable rainbow mode."
142
150
  </pre>
data/lib/color_echo.rb CHANGED
@@ -3,10 +3,11 @@
3
3
  # To add color to the command line output.
4
4
  # This Library will extend the Kernel module's functions(#print, #puts, #p).
5
5
  # @autor: Kazuya Hotta (nyanko)
6
+
6
7
  begin
7
8
  require "stringio"
8
9
  rescue LoadError
9
- warn "color_echo required 'stringio.'"
10
+ warn "color_echo required 'stringio'."
10
11
  end
11
12
 
12
13
  require_relative "color_echo/version.rb"
@@ -1,12 +1,12 @@
1
1
  module CE
2
2
  module BackGround
3
- BLACK = 40
4
- RED = 41
5
- GREEN = 42
6
- YELLOW = 43
7
- BLUE = 44
8
- MAGENTA = 45
9
- CYAN = 46
10
- WHITE = 47
3
+ BLACK = "\e[40m"
4
+ RED = "\e[41m"
5
+ GREEN = "\e[42m"
6
+ YELLOW = "\e[43m"
7
+ BLUE = "\e[44m"
8
+ MAGENTA = "\e[45m"
9
+ CYAN = "\e[46m"
10
+ WHITE = "\e[47m"
11
11
  end
12
12
  end
@@ -1,12 +1,12 @@
1
1
  module CE
2
2
  module ForeGround
3
- BLACK = 30
4
- RED = 31
5
- GREEN = 32
6
- YELLOW = 33
7
- BLUE = 34
8
- MAGENTA = 35
9
- CYAN = 36
10
- WHITE = 37
3
+ BLACK = "\e[30m"
4
+ RED = "\e[31m"
5
+ GREEN = "\e[32m"
6
+ YELLOW = "\e[33m"
7
+ BLUE = "\e[34m"
8
+ MAGENTA = "\e[35m"
9
+ CYAN = "\e[36m"
10
+ WHITE = "\e[37m"
11
11
  end
12
12
  end
@@ -74,27 +74,31 @@ module CE
74
74
  cnt = 0
75
75
  output = ""
76
76
  text.each_char do |char|
77
- output += $/ if char == $/
77
+ if char == $/
78
+ output += $/
79
+ next
80
+ end
78
81
 
79
82
  case cnt
80
83
  when 0
81
- output += "\e[31m" + char + "\e[0m"
84
+ output += ForeGround::RED + char + CODE_RESET
82
85
  when 1
83
- output += "\e[32m" + char + "\e[0m"
86
+ output += ForeGround::GREEN + char + CODE_RESET
84
87
  when 2
85
- output += "\e[33m" + char + "\e[0m"
88
+ output += ForeGround::YELLOW + char + CODE_RESET
86
89
  when 3
87
- output += "\e[34m" + char + "\e[0m"
90
+ output += ForeGround::BLUE + char + CODE_RESET
88
91
  when 4
89
- output += "\e[35m" + char + "\e[0m"
92
+ output += ForeGround::MAGENTA + char + CODE_RESET
90
93
  when 5
91
- output += "\e[36m" + char + "\e[0m"
94
+ output += ForeGround::CYAN + char + CODE_RESET
92
95
  when 6
93
- output += "\e[37m" + char + "\e[0m"
96
+ output += ForeGround::WHITE + char + CODE_RESET
94
97
  end
95
98
  cnt += 1
96
99
  cnt = 0 if cnt >= 7
97
100
  end
101
+
98
102
  return output
99
103
  end
100
104
 
@@ -104,7 +108,7 @@ module CE
104
108
  rescue NameError
105
109
  raise(NameError ,%{:#{name} is not defined! Please check reference.})
106
110
  end
107
- return "\e[#{code}m"
111
+ return code
108
112
  end
109
113
 
110
114
  def task
@@ -1,10 +1,9 @@
1
1
  module CE
2
2
  module TextAttr
3
- OFF = 0
4
- BOLD = 1
5
- UNDERSCORE = 4
6
- BLINK = 5
7
- REVERSE_VIDEO = 7
8
- CONCEALED = 8
3
+ BOLD = "\e[1m"
4
+ UNDERSCORE = "\e[4m"
5
+ BLINK = "\e[5m"
6
+ REVERSE_VIDEO = "\e[7m"
7
+ CONCEALED = "\e[8m"
9
8
  end
10
9
  end
@@ -1,3 +1,3 @@
1
1
  module CE
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: color_echo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - nyanko