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 CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 1.0.2
@@ -74,10 +74,10 @@ module SmartColored
74
74
  self.class.new(str)
75
75
  end
76
76
 
77
- NAME_TO_ATTRIBUTES = {}
77
+ @@name_to_attributes = {}
78
78
  def self.map_name_to_attributes(name, attributes)
79
79
  name = name.to_sym
80
- NAME_TO_ATTRIBUTES[name] = attributes
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 = NAME_TO_ATTRIBUTES.values_at(*method_s.scan(COMBINED_REGEXP_PART).map(&:to_sym)).inject(&:merge)
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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{smart_colored}
8
- s.version = "1.0.1"
8
+ s.version = "1.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ivan Kuchin"]
@@ -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: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 1
10
- version: 1.0.1
9
+ - 2
10
+ version: 1.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ivan Kuchin