colorable 0.0.8 → 0.1.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 +98 -27
- data/lib/colorable.rb +1 -1
- data/lib/colorable/color.rb +125 -35
- data/lib/colorable/color_space.rb +260 -0
- data/lib/colorable/colorset.rb +59 -30
- data/lib/colorable/converter.rb +4 -39
- data/lib/colorable/system_extension.rb +6 -4
- data/lib/colorable/version.rb +1 -1
- data/spec/color_space_spec.rb +356 -0
- data/spec/color_spec.rb +220 -47
- data/spec/colorset_spec.rb +49 -44
- data/spec/converter_spec.rb +25 -44
- metadata +5 -2
data/spec/converter_spec.rb
CHANGED
@@ -1,43 +1,24 @@
|
|
1
|
-
|
1
|
+
require_relative 'spec_helper'
|
2
2
|
|
3
3
|
include Colorable::Converter
|
4
4
|
describe Colorable::Converter do
|
5
5
|
let(:conv) { Colorable::Converter }
|
6
6
|
describe "#name2rgb" do
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
context "when name not exist" do
|
17
|
-
it "raise NoNameError" do
|
18
|
-
expect { name2rgb("Hello Yellow") }.to raise_error conv::NoNameError
|
19
|
-
end
|
7
|
+
it "return a RGB value" do
|
8
|
+
name2rgb("Alice Blue").should eql [240, 248, 255]
|
9
|
+
name2rgb("Khaki").should eql [240, 230, 140]
|
10
|
+
name2rgb("Mint Cream").should eql [245, 255, 250]
|
11
|
+
name2rgb("Thistle").should eql [216, 191, 216]
|
12
|
+
name2rgb("Hello Yellow").should be_nil
|
20
13
|
end
|
21
14
|
end
|
22
15
|
|
23
16
|
describe "#rgb2name" do
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
context "when name not exist" do
|
32
|
-
it "returns nil" do
|
33
|
-
rgb2name([240, 240, 240]).should be_nil
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
context "when invalid rgb" do
|
38
|
-
it "raise ArgumentError" do
|
39
|
-
expect { rgb2name([0, 260, 0]) }.to raise_error ArgumentError
|
40
|
-
end
|
17
|
+
it "returns a name" do
|
18
|
+
rgb2name([240, 248, 255]).should eql "Alice Blue"
|
19
|
+
rgb2name([216, 191, 216]).should eql "Thistle"
|
20
|
+
rgb2name([0, 260, 0]).should be_nil
|
21
|
+
rgb2name([240, 240, 240]).should be_nil
|
41
22
|
end
|
42
23
|
end
|
43
24
|
|
@@ -51,8 +32,8 @@ describe Colorable::Converter do
|
|
51
32
|
end
|
52
33
|
|
53
34
|
context "when a invalid rgb" do
|
54
|
-
it "raise ArgumentError" do
|
55
|
-
expect { rgb2hsb([100, 100, -10]) }.
|
35
|
+
it "not raise ArgumentError" do
|
36
|
+
expect { rgb2hsb([100, 100, -10]) }.not_to raise_error ArgumentError
|
56
37
|
end
|
57
38
|
end
|
58
39
|
end
|
@@ -67,10 +48,10 @@ describe Colorable::Converter do
|
|
67
48
|
end
|
68
49
|
|
69
50
|
context "when a invalid hsb" do
|
70
|
-
it "raise ArgumentError" do
|
71
|
-
expect { hsb2rgb([-100, 50, 50]) }.
|
72
|
-
expect { hsb2rgb([350, 101, 50]) }.
|
73
|
-
expect { hsb2rgb([0, 50, -50]) }.
|
51
|
+
it "not raise ArgumentError" do
|
52
|
+
expect { hsb2rgb([-100, 50, 50]) }.not_to raise_error ArgumentError
|
53
|
+
expect { hsb2rgb([350, 101, 50]) }.not_to raise_error ArgumentError
|
54
|
+
expect { hsb2rgb([0, 50, -50]) }.not_to raise_error ArgumentError
|
74
55
|
end
|
75
56
|
end
|
76
57
|
end
|
@@ -85,8 +66,8 @@ describe Colorable::Converter do
|
|
85
66
|
end
|
86
67
|
|
87
68
|
context "when a invalid rgb" do
|
88
|
-
it "raise ArgumentError" do
|
89
|
-
expect { rgb2hex([100, 100, -10]) }.
|
69
|
+
it "not raise ArgumentError" do
|
70
|
+
expect { rgb2hex([100, 100, -10]) }.not_to raise_error ArgumentError
|
90
71
|
end
|
91
72
|
end
|
92
73
|
end
|
@@ -101,9 +82,9 @@ describe Colorable::Converter do
|
|
101
82
|
end
|
102
83
|
|
103
84
|
context "when a invalid hex" do
|
104
|
-
it "raise ArgumentError" do
|
105
|
-
expect { hex2rgb('#FFFFFG') }.
|
106
|
-
expect { hex2rgb('$FFFFFG') }.
|
85
|
+
it "not raise ArgumentError" do
|
86
|
+
expect { hex2rgb('#FFFFFG') }.not_to raise_error ArgumentError
|
87
|
+
expect { hex2rgb('$FFFFFG') }.not_to raise_error ArgumentError
|
107
88
|
end
|
108
89
|
end
|
109
90
|
end
|
@@ -119,8 +100,8 @@ describe Colorable::Converter do
|
|
119
100
|
end
|
120
101
|
|
121
102
|
context "when a invalid rgb" do
|
122
|
-
it "raise ArgumentError" do
|
123
|
-
expect { rgb2hsb([100, 100, -10]) }.
|
103
|
+
it "not raise ArgumentError" do
|
104
|
+
expect { rgb2hsb([100, 100, -10]) }.not_to raise_error ArgumentError
|
124
105
|
end
|
125
106
|
end
|
126
107
|
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.0
|
4
|
+
version: 0.1.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-
|
11
|
+
date: 2013-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -40,10 +40,12 @@ files:
|
|
40
40
|
- colorable.gemspec
|
41
41
|
- lib/colorable.rb
|
42
42
|
- lib/colorable/color.rb
|
43
|
+
- lib/colorable/color_space.rb
|
43
44
|
- lib/colorable/colorset.rb
|
44
45
|
- lib/colorable/converter.rb
|
45
46
|
- lib/colorable/system_extension.rb
|
46
47
|
- lib/colorable/version.rb
|
48
|
+
- spec/color_space_spec.rb
|
47
49
|
- spec/color_spec.rb
|
48
50
|
- spec/colorset_spec.rb
|
49
51
|
- spec/converter_spec.rb
|
@@ -73,6 +75,7 @@ specification_version: 4
|
|
73
75
|
summary: A simple color handler which provide a conversion between colorname, RGB,
|
74
76
|
HSB and HEX
|
75
77
|
test_files:
|
78
|
+
- spec/color_space_spec.rb
|
76
79
|
- spec/color_spec.rb
|
77
80
|
- spec/colorset_spec.rb
|
78
81
|
- spec/converter_spec.rb
|