colorb 0.0.2.1 → 0.0.3

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.
Files changed (2) hide show
  1. data/lib/colorb.rb +11 -3
  2. metadata +3 -4
@@ -32,7 +32,7 @@ class String
32
32
  }
33
33
 
34
34
  Extra = {
35
- :default => 0,
35
+ :clean => 0,
36
36
 
37
37
  :bold => 1,
38
38
  :underline => 4,
@@ -70,9 +70,17 @@ class String
70
70
  @flags.member?(name)
71
71
  else
72
72
  @flags << name
73
+ @flags.uniq!
73
74
  end
74
75
  end
75
76
 
77
+ @lazy ? self : self.colorify!
78
+ end
79
+
80
+ def lazy; @lazy = true; self end
81
+ def lazy?; @lazy end
82
+
83
+ def colorify!
76
84
  String.colorify(self, @foreground, @background, @flags)
77
85
  end
78
86
 
@@ -84,12 +92,12 @@ class String
84
92
  result.sub!(/^/, [
85
93
  String.color!(foreground),
86
94
  String.color!(background, true),
87
- [flags].flatten.compact.map {|f|
95
+ [flags].flatten.compact.uniq.map {|f|
88
96
  String.extra!(f)
89
97
  }
90
98
  ].flatten.compact.join(''))
91
99
 
92
- result.sub!(/$/, String.extra!(:default))
100
+ result.sub!(/$/, String.extra!(:clean))
93
101
 
94
102
  result
95
103
  end
metadata CHANGED
@@ -5,9 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- - 1
10
- version: 0.0.2.1
8
+ - 3
9
+ version: 0.0.3
11
10
  platform: ruby
12
11
  authors:
13
12
  - meh.
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-12-11 00:00:00 +01:00
17
+ date: 2010-12-12 00:00:00 +01:00
19
18
  default_executable:
20
19
  dependencies: []
21
20