colorable 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +123 -93
- data/lib/colorable.rb +6 -2
- data/lib/colorable/color.rb +87 -24
- data/lib/colorable/color_space.rb +250 -205
- data/lib/colorable/colorset.rb +4 -4
- data/lib/colorable/version.rb +1 -1
- data/spec/color_space_spec.rb +99 -27
- data/spec/color_spec.rb +124 -40
- data/spec/colorable_spec.rb +63 -49
- data/spec/colorset_spec.rb +2 -2
- metadata +2 -2
data/spec/colorable_spec.rb
CHANGED
@@ -1,53 +1,67 @@
|
|
1
1
|
require_relative 'spec_helper'
|
2
2
|
|
3
3
|
describe Colorable do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
4
|
+
describe "String#to_color" do
|
5
|
+
context "apply a colorname string" do
|
6
|
+
subject { "Lime Green".to_color }
|
7
|
+
it { should be_instance_of Colorable::Color }
|
8
|
+
its(:to_s) { should eql "Lime Green" }
|
9
|
+
end
|
10
|
+
|
11
|
+
context "apply a hex string" do
|
12
|
+
subject { "#32CD32".to_color }
|
13
|
+
it { should be_instance_of Colorable::Color }
|
14
|
+
its(:to_s) { should eql "#32CD32" }
|
15
|
+
end
|
16
|
+
|
17
|
+
context "apply a invalid string" do
|
18
|
+
it "raise ArgumentError" do
|
19
|
+
expect { "Bad Green".to_color }.to raise_error ArgumentError
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "Symbol#to_color" do
|
25
|
+
context "apply a colorname symbol" do
|
26
|
+
subject { :lime_green.to_color }
|
27
|
+
it { should be_instance_of Colorable::Color }
|
28
|
+
its(:to_s) { should eql "Lime Green" }
|
29
|
+
end
|
30
|
+
|
31
|
+
context "apply a invalid symbol" do
|
32
|
+
it "raise ArgumentError" do
|
33
|
+
expect { :bad_green.to_color }.to raise_error ArgumentError
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "Array#to_color" do
|
39
|
+
context "apply a RGB values" do
|
40
|
+
subject { [50, 205, 50].to_color }
|
41
|
+
it { should be_instance_of Colorable::Color }
|
42
|
+
its(:to_s) { should eql "rgb(50,205,50)" }
|
43
|
+
end
|
44
|
+
|
45
|
+
context "apply a invalid array" do
|
46
|
+
it "raise ArgumentError" do
|
47
|
+
expect { [50, 205].to_color }.to raise_error ArgumentError
|
48
|
+
expect { [50, 205, 300].to_color }.to raise_error ArgumentError
|
49
|
+
expect { ['50', '205', '205'].to_color }.to raise_error ArgumentError
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "Fixnum#to_color" do
|
55
|
+
context "apply a hex Fixnum" do
|
56
|
+
subject { 0x32CD32.to_color }
|
57
|
+
it { should be_instance_of Colorable::Color }
|
58
|
+
its(:to_s) { should eql "#32CD32" }
|
59
|
+
end
|
60
|
+
|
61
|
+
context "apply a invalid Fixnum" do
|
62
|
+
it "raise ArgumentError" do
|
63
|
+
expect { 323232.to_color }.to raise_error ArgumentError
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
53
67
|
end
|
data/spec/colorset_spec.rb
CHANGED
@@ -88,7 +88,7 @@ describe Colorset do
|
|
88
88
|
|
89
89
|
describe "#to_s" do
|
90
90
|
before(:all) { @cs = Colorset.new }
|
91
|
-
it { @cs.to_s.should eql "#<Colorset 0/144 pos='Alice Blue
|
92
|
-
it { @cs.next;@cs.to_s.should eql "#<Colorset 1/144 pos='Antique White
|
91
|
+
it { @cs.to_s.should eql "#<Colorable::Colorset 0/144 pos='Alice Blue<rgb(240,248,255)/hsb(208,6,100)>'>"}
|
92
|
+
it { @cs.next;@cs.to_s.should eql "#<Colorable::Colorset 1/144 pos='Antique White<rgb(250,235,215)/hsb(35,14,98)>'>"}
|
93
93
|
end
|
94
94
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: colorable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kyoendo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-05-
|
11
|
+
date: 2013-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|