colorable 0.1.2 → 0.1.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.
- checksums.yaml +4 -4
- data/lib/colorable/colorset.rb +2 -2
- data/lib/colorable/version.rb +1 -1
- data/spec/color_spec.rb +12 -0
- data/spec/colorset_spec.rb +6 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac8fe28fac5a9c9eee459a8927d35e94146ed21d
|
4
|
+
data.tar.gz: cd1262d7726f2cfd0003a0b486115c36cb4223f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9abd7f790c84433b91e95cf3aae951960b355311be9436be65686ee375233611742edcdc53ca4cb1089b74ea8ea5465d5bac89bc47d99ae19920cacc085d46cf
|
7
|
+
data.tar.gz: 72d843af6dc8e343a96142b78700e2167b99eaa59da813a43b2170e9d94cf7321f737b910327eff8413d2e52fbb603f0c9f3325ca3c16754b42cce55c61d149d
|
data/lib/colorable/colorset.rb
CHANGED
@@ -78,6 +78,7 @@ module Colorable
|
|
78
78
|
when :name then :NAME
|
79
79
|
when :rgb, *rgb_part then :RGB
|
80
80
|
when :hsb, :hsv, *hsb_part then :HSB
|
81
|
+
when :hex then :HEX
|
81
82
|
else
|
82
83
|
raise ArgumentError, "Invalid order option given"
|
83
84
|
end
|
@@ -92,7 +93,7 @@ module Colorable
|
|
92
93
|
->color{ color.rgb.move_to_top rgb_part.index(order) }
|
93
94
|
when *hsb_part
|
94
95
|
->color{ color.hsb.move_to_top hsb_part.index(order) }
|
95
|
-
when :name, :rgb, :hsb, :hsv
|
96
|
+
when :name, :rgb, :hsb, :hsv, :hex
|
96
97
|
->color{ color.send order }
|
97
98
|
end
|
98
99
|
|
@@ -105,6 +106,5 @@ module Colorable
|
|
105
106
|
raise ArgumentError, "Invalid dir option given"
|
106
107
|
end
|
107
108
|
end
|
108
|
-
|
109
109
|
end
|
110
110
|
end
|
data/lib/colorable/version.rb
CHANGED
data/spec/color_spec.rb
CHANGED
@@ -112,6 +112,12 @@ describe Color do
|
|
112
112
|
it { @c.next(2).to_s.should eql "hsb(60,6,100)" } #Ivory
|
113
113
|
end
|
114
114
|
|
115
|
+
context "with :HEX mode" do
|
116
|
+
subject { Color.new '#32CD32' }
|
117
|
+
it { subject.next.to_s.should eql "#3CB371" }
|
118
|
+
it { subject.next(2).to_s.should eql "#40E0D0" }
|
119
|
+
end
|
120
|
+
|
115
121
|
context "when color is not in X11 colorset" do
|
116
122
|
it { Color.new([100,10,10]).name.should be_nil }
|
117
123
|
end
|
@@ -139,6 +145,12 @@ describe Color do
|
|
139
145
|
it { @c.prev(2).to_s.should eql "hsb(55,20,100)" } #Lemon Chiffon
|
140
146
|
end
|
141
147
|
|
148
|
+
context "with :HEX mode" do
|
149
|
+
subject { Color.new '#32CD32' }
|
150
|
+
it { subject.prev.to_s.should eql "#2F4F4F" }
|
151
|
+
it { subject.prev(2).to_s.should eql "#2E8B57" }
|
152
|
+
end
|
153
|
+
|
142
154
|
context "when color is not in X11 colorset" do
|
143
155
|
it { Color.new([100,10,10]).name.should be_nil }
|
144
156
|
end
|
data/spec/colorset_spec.rb
CHANGED
@@ -32,6 +32,12 @@ describe Colorset do
|
|
32
32
|
it { subject.take(3).map(&:to_s).should eql ['hsb(0,0,0)', 'hsb(0,0,41)', 'hsb(0,0,50)'] }
|
33
33
|
it { subject.last.to_s.should eql 'hsb(352,29,100)' }
|
34
34
|
end
|
35
|
+
|
36
|
+
context "with HEX order" do
|
37
|
+
subject { Colorset.new order: :hex }
|
38
|
+
it { subject.take(3).map(&:to_s).should eql ["#000000", "#000080", "#00008B"] }
|
39
|
+
it { subject.last.to_s.should eql '#FFFFFF' }
|
40
|
+
end
|
35
41
|
end
|
36
42
|
|
37
43
|
describe "#at" do
|