ztk 1.4.0 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ztk/ansi.rb +17 -3
- data/lib/ztk/version.rb +1 -1
- metadata +3 -3
data/lib/ztk/ansi.rb
CHANGED
@@ -54,7 +54,9 @@ module ZTK
|
|
54
54
|
:bold => 1
|
55
55
|
}
|
56
56
|
|
57
|
-
|
57
|
+
ANSI_REGEX = /\e\[(?:(?:[349]|10)[0-7]|[0-9]|[34]8;5;\d{1,3})?m/
|
58
|
+
|
59
|
+
def build_ansi_methods(hash)
|
58
60
|
hash.each do |key, value|
|
59
61
|
define_method(key) do |string=nil, &block|
|
60
62
|
result = Array.new
|
@@ -75,11 +77,23 @@ module ZTK
|
|
75
77
|
end
|
76
78
|
end
|
77
79
|
|
78
|
-
|
79
|
-
|
80
|
+
def uncolor(string=nil)
|
81
|
+
if block_given?
|
82
|
+
yield.to_str.gsub(ANSI_REGEX, '')
|
83
|
+
elsif string.respond_to?(:to_str)
|
84
|
+
string.to_str.gsub(ANSI_REGEX, '')
|
85
|
+
elsif respond_to?(:to_str)
|
86
|
+
to_str.gsub(ANSI_REGEX, '')
|
87
|
+
else
|
88
|
+
''
|
89
|
+
end
|
90
|
+
end
|
80
91
|
|
81
92
|
extend self
|
82
93
|
|
94
|
+
build_ansi_methods(COLOR_MATRIX)
|
95
|
+
build_ansi_methods(ATTRIBUTE_MATRIX)
|
96
|
+
|
83
97
|
end
|
84
98
|
|
85
99
|
end
|
data/lib/ztk/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ztk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -247,7 +247,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
247
247
|
version: '0'
|
248
248
|
segments:
|
249
249
|
- 0
|
250
|
-
hash:
|
250
|
+
hash: -4161660178397173415
|
251
251
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
252
252
|
none: false
|
253
253
|
requirements:
|
@@ -256,7 +256,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
256
256
|
version: '0'
|
257
257
|
segments:
|
258
258
|
- 0
|
259
|
-
hash:
|
259
|
+
hash: -4161660178397173415
|
260
260
|
requirements: []
|
261
261
|
rubyforge_project:
|
262
262
|
rubygems_version: 1.8.25
|