colorable 0.0.4 → 0.0.5
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 +9 -4
- data/lib/colorable/version.rb +1 -1
- data/spec/colorset_spec.rb +20 -15
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d632dab9e8eb142bf07ac4a9390e42211092031d
|
4
|
+
data.tar.gz: 9947396d86fc127a78a2c83912edfb520c061530
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 168f110be434072d078e4255db6db262b6e563b8b00f0d072f002def13c9647f1f82cc193df38f90b91f7a26b65f6fd485de9162b8dbd0bfe2524c9c6f225c21
|
7
|
+
data.tar.gz: 93344cf79f3c319d497e22c2252f159f5472bd614984a776191d44b7b8adb5c0814a3eb623eb498fa008b97a693ae14a65d12375e76afbe4f234a6c8e6ead4a9
|
data/lib/colorable/colorset.rb
CHANGED
@@ -41,22 +41,22 @@ module Colorable
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def at(pos=0)
|
44
|
-
@colorset[pos%size]
|
44
|
+
@colorset[(@pos+pos)%size]
|
45
45
|
end
|
46
46
|
|
47
47
|
def next(n=1)
|
48
48
|
@pos = (@pos+n)%size
|
49
|
-
at
|
49
|
+
at
|
50
50
|
end
|
51
51
|
|
52
52
|
def prev(n=1)
|
53
53
|
@pos = (@pos-n)%size
|
54
|
-
at
|
54
|
+
at
|
55
55
|
end
|
56
56
|
|
57
57
|
def rewind
|
58
58
|
@pos = 0
|
59
|
-
at
|
59
|
+
at
|
60
60
|
end
|
61
61
|
|
62
62
|
def last(n=1)
|
@@ -82,5 +82,10 @@ module Colorable
|
|
82
82
|
def to_a
|
83
83
|
@colorset
|
84
84
|
end
|
85
|
+
|
86
|
+
def to_s
|
87
|
+
"#<%s %d/%d pos='%s:%s'>" % [:Colorset, @pos, size, at.name, at]
|
88
|
+
end
|
89
|
+
alias :inspect :to_s
|
85
90
|
end
|
86
91
|
end
|
data/lib/colorable/version.rb
CHANGED
data/spec/colorset_spec.rb
CHANGED
@@ -12,20 +12,20 @@ describe Colorable::Colorset do
|
|
12
12
|
describe ".[](order)" do
|
13
13
|
context "when :rgb passed" do
|
14
14
|
before(:all) { @cs = colorset[:rgb] }
|
15
|
-
it { @cs.take(3).to_s.should eql '
|
16
|
-
it { @cs.last.to_s.should eql '
|
15
|
+
it { @cs.take(3).map(&:to_s).should eql ['rgb(0,0,0)', 'rgb(0,0,128)', 'rgb(0,0,139)'] }
|
16
|
+
it { @cs.last.map(&:to_s).should eql ['rgb(255,255,255)'] }
|
17
17
|
end
|
18
18
|
|
19
19
|
context "when :red" do
|
20
20
|
before(:all) { @cs = colorset[:red] }
|
21
|
-
it { @cs.take(3).to_s.should eql '
|
22
|
-
it { @cs.last.to_s.should eql '
|
21
|
+
it { @cs.take(3).map(&:to_s).should eql ['rgb(0,0,0)', 'rgb(0,0,128)', 'rgb(0,0,139)'] }
|
22
|
+
it { @cs.last.map(&:to_s).should eql ['rgb(255,255,255)'] }
|
23
23
|
end
|
24
24
|
|
25
25
|
context "when :green in descent order" do
|
26
26
|
before(:all) { @cs = colorset[:green, :-] }
|
27
|
-
it { @cs.take(3).to_s.should eql '
|
28
|
-
it { @cs.last(3).to_s.should eql '
|
27
|
+
it { @cs.take(3).map(&:to_s).should eql ['rgb(255,255,255)', 'rgb(255,255,240)', 'rgb(255,255,224)'] }
|
28
|
+
it { @cs.last(3).map(&:to_s).should eql ['rgb(0,0,139)', 'rgb(0,0,128)', 'rgb(0,0,0)'] }
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -51,23 +51,22 @@ describe Colorable::Colorset do
|
|
51
51
|
|
52
52
|
describe "#next" do
|
53
53
|
before(:all) { @cs = colorset.new }
|
54
|
-
it { @cs.next.should eql
|
55
|
-
it { @cs.next.should eql
|
56
|
-
it { @cs.next.should eql
|
57
|
-
it { @cs.next(2).should eql @cs.at(5) }
|
54
|
+
it { @cs.next.name.should eql 'Antique White' }
|
55
|
+
it { @cs.next.name.should eql 'Aqua' }
|
56
|
+
it { @cs.next(2).name.should eql 'Azure' }
|
58
57
|
end
|
59
58
|
|
60
59
|
describe "#prev" do
|
61
60
|
before(:all) { @cs = colorset[:hsb] }
|
62
|
-
it { @cs.prev.should eql
|
63
|
-
it { @cs.prev.should eql
|
64
|
-
it { @cs.prev.should eql
|
65
|
-
it { @cs.prev(2).should eql
|
61
|
+
it { @cs.prev.name.should eql 'Light Pink' }
|
62
|
+
it { @cs.prev.name.should eql 'Pink' }
|
63
|
+
it { @cs.prev.name.should eql 'Crimson' }
|
64
|
+
it { @cs.prev(2).name.should eql 'Lavender Blush' }
|
66
65
|
end
|
67
66
|
|
68
67
|
describe "#rewind" do
|
69
68
|
before(:all) { @cs = colorset.new }
|
70
|
-
it { @cs.next(10); @cs.rewind.should eql
|
69
|
+
it { @cs.next(10); @cs.rewind.name.should eql 'Alice Blue' }
|
71
70
|
end
|
72
71
|
|
73
72
|
describe "#size" do
|
@@ -75,4 +74,10 @@ describe Colorable::Colorset do
|
|
75
74
|
colorset.new.size.should eql 144
|
76
75
|
end
|
77
76
|
end
|
77
|
+
|
78
|
+
describe "#to_s" do
|
79
|
+
before(:all) { @cs = colorset.new }
|
80
|
+
it { @cs.to_s.should eql "#<Colorset 0/144 pos='Alice Blue:rgb(240,248,255)'>"}
|
81
|
+
it { @cs.next;@cs.to_s.should eql "#<Colorset 1/144 pos='Antique White:rgb(250,235,215)'>"}
|
82
|
+
end
|
78
83
|
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.0.5
|
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-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -67,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
67
|
version: '0'
|
68
68
|
requirements: []
|
69
69
|
rubyforge_project:
|
70
|
-
rubygems_version: 2.0.
|
70
|
+
rubygems_version: 2.0.3
|
71
71
|
signing_key:
|
72
72
|
specification_version: 4
|
73
73
|
summary: A simple color handler which provide a conversion between colorname, RGB,
|