colorb 0.0.5 → 0.0.6
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.
- data/lib/colorb.rb +13 -11
- metadata +3 -3
data/lib/colorb.rb
CHANGED
@@ -51,7 +51,7 @@ class String
|
|
51
51
|
def method_missing (id, *args, &block)
|
52
52
|
name = id.to_s.match(/^(.+?)[!?]?$/)[1].to_sym
|
53
53
|
|
54
|
-
result = self.frozen? ?
|
54
|
+
result = (self.frozen? || !id.to_s.end_with?('!')) ? self.clone : self
|
55
55
|
|
56
56
|
return __old_method_missing(id, *args, &block) unless Colors[name] || Extra[name]
|
57
57
|
|
@@ -81,29 +81,31 @@ class String
|
|
81
81
|
def color (code, second=nil)
|
82
82
|
return method_missing(code.to_sym) if code.is_a?(Symbol) || code.is_a?(String)
|
83
83
|
|
84
|
-
|
84
|
+
self.clone.color!(code, seond)
|
85
|
+
end
|
85
86
|
|
87
|
+
def color! (code, second=nil)
|
86
88
|
if code < 16
|
87
89
|
if code > 7
|
88
|
-
(
|
90
|
+
(self.flags ||= []) << (!self.foreground ? :bold : :blink)
|
89
91
|
end
|
90
92
|
|
91
|
-
if !
|
92
|
-
|
93
|
+
if !self.foreground
|
94
|
+
self.foreground = code - (code > 7 ? 7 : 0)
|
93
95
|
else
|
94
|
-
|
96
|
+
self.background = code - (code > 7 ? 7 : 0)
|
95
97
|
end
|
96
98
|
else
|
97
|
-
if !
|
98
|
-
|
99
|
+
if !self.foreground
|
100
|
+
self.foreground = code
|
99
101
|
else
|
100
|
-
|
102
|
+
self.background = code
|
101
103
|
end
|
102
104
|
end
|
103
105
|
|
104
|
-
|
106
|
+
self.color(second) if second
|
105
107
|
|
106
|
-
|
108
|
+
self.lazy? ? self : self.colorify!
|
107
109
|
end
|
108
110
|
|
109
111
|
def lazy; @lazy = true; self end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 6
|
9
|
+
version: 0.0.6
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- meh.
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date:
|
17
|
+
date: 2011-02-04 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|