smart_colored 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/smart_colored.rb +3 -3
- data/smart_colored.gemspec +1 -1
- data/spec/smart_colored_spec.rb +14 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.2
|
data/lib/smart_colored.rb
CHANGED
@@ -74,10 +74,10 @@ module SmartColored
|
|
74
74
|
self.class.new(str)
|
75
75
|
end
|
76
76
|
|
77
|
-
|
77
|
+
@@name_to_attributes = {}
|
78
78
|
def self.map_name_to_attributes(name, attributes)
|
79
79
|
name = name.to_sym
|
80
|
-
|
80
|
+
@@name_to_attributes[name] = attributes
|
81
81
|
define_method name do
|
82
82
|
apply_format(attributes)
|
83
83
|
end
|
@@ -97,7 +97,7 @@ module SmartColored
|
|
97
97
|
|
98
98
|
def method_missing(method, *arguments, &block)
|
99
99
|
if (method_s = "#{method}_") =~ COMBINED_REGEXP
|
100
|
-
attributes =
|
100
|
+
attributes = @@name_to_attributes.values_at(*method_s.scan(COMBINED_REGEXP_PART).map(&:to_sym)).inject(&:merge)
|
101
101
|
SmartColored.map_name_to_attributes method, attributes
|
102
102
|
apply_format(attributes)
|
103
103
|
else
|
data/smart_colored.gemspec
CHANGED
data/spec/smart_colored_spec.rb
CHANGED
@@ -1,6 +1,20 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
3
|
describe SmartColored do
|
4
|
+
describe "proxied" do
|
5
|
+
it "should work" do
|
6
|
+
'bold red on green'.colored.bold_red_on_green.should == "\e[1;31;42m" 'bold red on green' "\e[0m"
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should return String subclass" do
|
10
|
+
'bold red on green'.colored.should be_instance_of(SmartColored::String)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should return String subclass after applying" do
|
14
|
+
'bold red on green'.colored.red.should be_instance_of(SmartColored::String)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
4
18
|
describe "simple" do
|
5
19
|
it "should apply none" do
|
6
20
|
'clear'.apply_format.should == 'clear'
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_colored
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 2
|
10
|
+
version: 1.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ivan Kuchin
|