color_echo 0.4.0 → 0.5.0

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: 39af711706bd8e500fc5673edc8df5a5fb03d607
4
- data.tar.gz: 15a50d0d65ebcedaf5d3ea50e20963278aacbddb
3
+ metadata.gz: 7565b0674d6e694fb86b29c669f8e9580bcba009
4
+ data.tar.gz: a7af71f546e59d6f34cb474a9c62e64689c5966a
5
5
  SHA512:
6
- metadata.gz: 2d0c3bb3813a90203a0d99f1dbc4519ea9991ad15310d5496284602bdcb26c62b6c58bd6e08d01688bcaccef7adb66470924f4689c17a2a993d6208185d90ed3
7
- data.tar.gz: a37cb37999324b77806bf25ef69781f8e8091355231d0534b1fa2ab3ec7edbacbbf63746aea89045782b636f8ef2b9e594d8addd3826d6ad1d613fd1248e91e8
6
+ metadata.gz: ed1abf84de39e9b85d2ca6354a3ed6889f2c9489039eebd1737f6cb3d0ec580cf8720ab60c64693c9c58e10e4885ed90e87f44a4ddbab0a8423a589b62f4e8c1
7
+ data.tar.gz: 8b37bcab33978dbddc0d3e397ecc01f47db1e40227ebeb0ff73e812ded1d83b9f2c3e7c6231a279da742ed811f21c48bb5920e979a4afb824bdbce553a2d1b63
data/README.md CHANGED
@@ -3,7 +3,7 @@ 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.4.0
6
+ Version: 0.5.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
@@ -22,10 +22,10 @@ Or install it yourself as:
22
22
 
23
23
  ### module functions
24
24
  #### CE.ch_fg :symbol
25
- Change the foreground color to the your specified color.
26
- Alias is, fg
27
- This method alias is available in version 0.2.0 on and after.
28
- return self.
25
+ Change the foreground color to the your specified color.
26
+ - Alias -> fg (available in v0.2.0 on and after)
27
+ - Parameter -> Symbol
28
+ - Return -> self
29
29
 
30
30
  * symbol list:
31
31
  * black
@@ -37,7 +37,7 @@ return self.
37
37
  * cyan
38
38
  * white
39
39
 
40
- available in version 0.3.0 on and after.
40
+ available in v0.3.0 on and after.
41
41
  * gray
42
42
  * h_red
43
43
  * h_green
@@ -47,18 +47,20 @@ return self.
47
47
  * h_cyan
48
48
  * h_white
49
49
 
50
- available in version 0.4.0 on and after.
50
+ available in v0.4.0 on and after.
51
51
  * index[1-256]
52
52
 
53
53
  ex.) CE.ch_fg :red #=> foreground color will be changed red
54
54
 
55
- #### CE.ch_bg :symbol
56
- Change the background color to the your specified color.
57
- Alias is, bg
58
- This method alias is available in version 0.2.0 on and after.
59
- return self.
60
55
 
61
56
 
57
+
58
+ #### CE.ch_bg :symbol
59
+ Change the background color to the your specified color.
60
+ - Alias -> bg (available in v0.2.0 on and after)
61
+ - Parameter -> Symbol
62
+ - Return -> self
63
+
62
64
  * symbol list:
63
65
  * black
64
66
  * red
@@ -69,7 +71,7 @@ return self.
69
71
  * cyan
70
72
  * white
71
73
 
72
- available in version 0.3.0 on and after.
74
+ available in v0.3.0 on and after.
73
75
  * gray
74
76
  * h_red
75
77
  * h_green
@@ -79,7 +81,7 @@ return self.
79
81
  * h_cyan
80
82
  * h_white
81
83
 
82
- available in version 0.4.0 on and after.
84
+ available in v0.4.0 on and after.
83
85
  * index[1-256]
84
86
 
85
87
  ex.) CE.ch_bg :white #=> background color will be changed white
@@ -87,7 +89,10 @@ ex.) CE.ch_bg :white #=> background color will be changed white
87
89
 
88
90
 
89
91
  #### CE.ch_tx :symbol
90
- Change the text attribute to the your specified decoration.
92
+ Change the text attribute to the your specified decoration.
93
+ - Alias -> tx (available in v0.2.0 on and after)
94
+ - Parameter -> Symbol
95
+ - Return -> self
91
96
 
92
97
  * symbol list:
93
98
  * bold
@@ -96,46 +101,74 @@ Change the text attribute to the your specified decoration.
96
101
  * reverse_video
97
102
  * concealed
98
103
 
99
- Alias is, tx
100
- This method alias is available in version 0.2.0 on and after.
101
- return self.
102
104
  ex.) CE.ch_tx :blink #=> text blink on
103
105
 
104
106
 
105
-
106
107
  #### CE.ch foreground [,background [,text_attribute]]
107
- Change collectively.
108
+ Change collectively.
109
+ This method is available in v0.1.0 on and after.
110
+ - Parameter foreground -> Symbol
111
+ - Parameter background -> Symbol
112
+ - Parameter text_attribute -> Symbol
113
+ - Return -> self
114
+
108
115
  ex.) CE.ch :white, :green
109
- This method is available in version 0.1.0 on and after.
110
- return self.
111
116
 
112
117
 
113
- #### CE.reset([target={:fg|:bg]})
118
+ #### CE.reset([target={:fg|:bg]})
114
119
  Reset to set the escape sequence.
115
- Alias is, off, disable
116
- This method alias is available in version 0.1.0 on and after.
117
- Parameters can v0.3.0 on and after be specified.
120
+ - Alias -> off, disable (available in v0.1.0 on and after)
121
+ - Parameter target -> Symbol (available in v0.3.0 on and after)
122
+ - Return -> self
123
+
118
124
  ex.) CE.reset :fg #=> foreground color will be reset.
119
125
  ex.) CE.reset :bg #=> background color will be reset.
120
126
  ex.) CE.reset #=> All reset the set escape sequence.
121
- return self.
122
127
 
123
128
 
129
+ #### CE.once
130
+ Reset automatically after once output.
131
+ This method is available in v0.5.0 on and after.
132
+ - Return -> self
133
+
134
+ #### CE.times(cnt)
135
+ Reset automatically after cnt times output.
136
+ This method is available in v0.5.0 on and after.
137
+ - Parameter cnt -> Integer
138
+ - Return -> self
139
+
140
+ ```ruby
141
+ CE.once.ch :h_yellow, :h_red, :underscore
142
+ puts "decorated"
143
+ puts "switch off"
144
+
145
+ puts "\n"
146
+
147
+ CE.times(3).rainbow
148
+ puts "one"
149
+ puts "two"
150
+ puts "three"
151
+ puts "switch off"
152
+ ```
153
+ ![screen shot](/images/result_off.png)
154
+
124
155
  #### CE.unuse
125
156
  Force ignore the function of this library.
126
- This method is available in version 0.1.0 on and after.
157
+ This method is available in v0.1.0 on and after.
127
158
 
128
159
 
129
160
  #### CE.rainbow
130
161
  Text color will change to rainbow color.
131
162
  ~~String Object only. Non-string object is excluded.~~
132
163
  -> Can v0.2.4 on and after be able to specify a non-string when rainbow mode.
133
- This method is available in version 0.2.0 on and after.
164
+ This method is available in v0.2.0 on and after.
134
165
 
135
166
 
136
167
  ### Can to select 256 colors!
137
168
  Please install color_echo and do `ruby test/check_color_index_list.rb`.
169
+ ex.) CE.ch :index197, :index230
138
170
  ![screen shot](/images/color_index.png)
171
+ ![screen shot](/images/color_index2.png)
139
172
 
140
173
 
141
174
  ### Example
@@ -166,7 +199,7 @@ p "AAAAA", "BBBBB", "CCCCC"
166
199
  ary = ["Duis", "aute", "irure", "dolor", "in", "reprehenderit", "in", "voluptate"]
167
200
 
168
201
  CE.off
169
- puts "turn off all colors and attribute."
202
+ puts "switch off all colors and attribute."
170
203
 
171
204
  CE.fg :red
172
205
  puts ary
@@ -224,6 +257,9 @@ puts "Disable rainbow mode."
224
257
  ![screen shot](/images/screenshot.png)
225
258
 
226
259
  ## Release Note
260
+ * v0.5.0, 2014-12-16
261
+ * added a new method -> \#once, \#times
262
+
227
263
  * v0.4.0, 2014-12-11
228
264
  * Can to select 256 colors.
229
265
 
@@ -38,6 +38,18 @@ module CE
38
38
  return self
39
39
  end
40
40
 
41
+ # auto off until output set count
42
+ # @params int cnt
43
+ # @return self
44
+ def times(cnt)
45
+ @@cnt_limit = cnt
46
+ return self
47
+ end
48
+
49
+ def once
50
+ times(1)
51
+ end
52
+
41
53
  # @param Symbol name
42
54
  # @return self
43
55
  def ch_fg(name)
@@ -187,6 +199,8 @@ module CE
187
199
  :reset,
188
200
  :off,
189
201
  :disable,
202
+ :times,
203
+ :once,
190
204
  :ch_fg,
191
205
  :fg,
192
206
  :ch_bg,
@@ -6,6 +6,7 @@ module CE
6
6
  @@code_text_attr = ""
7
7
  @@code_rainbow = ""
8
8
  @@rainbow = false
9
+ @@cnt_limit = 0
9
10
 
10
11
  @@print = method :print
11
12
  @@p = method :p
@@ -33,6 +34,12 @@ module CE
33
34
  $stdout.print add_reset_line_feed(strio.string)
34
35
  end
35
36
 
37
+ # auto off
38
+ if @@cnt_limit > 0
39
+ @@cnt_limit -= 1
40
+ reset if @@cnt_limit == 0
41
+ end
42
+
36
43
  # no available "color echo"
37
44
  else
38
45
  # call original method
@@ -1,3 +1,3 @@
1
1
  module CE
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: color_echo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.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 00:00:00.000000000 Z
11
+ date: 2014-12-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  Using the ANSI escape sequence and give it a color on the command line output.