style_train 0.3.2 → 0.4.0
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.
- data/VERSION +1 -1
- data/lib/style_train.rb +0 -7
- data/lib/style_train/color.rb +769 -97
- data/lib/style_train/sheet.rb +6 -2
- data/lib/style_train/support/numbers.rb +6 -2
- data/spec/color_spec.rb +1447 -0
- data/spec/numbers_spec.rb +13 -1
- data/spec/sheet_spec.rb +24 -10
- data/spec/themed_sheet_spec.rb +2 -2
- data/style_train.gemspec +4 -17
- metadata +7 -20
- data/lib/style_train/color_types/color_type.rb +0 -233
- data/lib/style_train/color_types/hex_color.rb +0 -44
- data/lib/style_train/color_types/hsl_color.rb +0 -5
- data/lib/style_train/color_types/keyword_color.rb +0 -192
- data/lib/style_train/color_types/rgb_color.rb +0 -57
- data/spec/color/color_spec.rb +0 -252
- data/spec/color/color_type_spec.rb +0 -389
- data/spec/color/hex_color_spec.rb +0 -160
- data/spec/color/keyword_color_spec.rb +0 -56
- data/spec/color/rgb_color_spec.rb +0 -75
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
|
-
|
|
3
|
-
KeywordColor = StyleTrain::KeywordColor unless defined?( KeywordColor )
|
|
4
|
-
|
|
5
|
-
describe KeywordColor do
|
|
6
|
-
describe 'accessors' do
|
|
7
|
-
it 'should have methods for #keyword= and #keyword' do
|
|
8
|
-
KeywordColor.instance_methods.should include( 'keyword=', 'keyword' )
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
it 'should raise an error if the keyword is not found' do
|
|
12
|
-
lambda{ KeywordColor.new(:color => :puke) }.should raise_error( KeywordColor::KeywordError)
|
|
13
|
-
color = KeywordColor.new(:color => :lightyellow)
|
|
14
|
-
lambda{ color.keyword = :puke }.should raise_error(KeywordColor::KeywordError)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it 'should set the keyword attribute' do
|
|
18
|
-
color = KeywordColor.new(:color => :lightyellow)
|
|
19
|
-
color.keyword.should == :lightyellow
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
describe 'initialization' do
|
|
24
|
-
describe 'from a color' do
|
|
25
|
-
it 'should find a keyword if it maps' do
|
|
26
|
-
rgb = StyleTrain::RGBcolor.new(:color => [255,255,224])
|
|
27
|
-
light_yellow = KeywordColor.new( rgb )
|
|
28
|
-
light_yellow.r.should == 255
|
|
29
|
-
light_yellow.g.should == 255
|
|
30
|
-
light_yellow.b.should == 224
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
it 'should raise an error if it does not map' do
|
|
34
|
-
rgb = StyleTrain::RGBcolor.new(:color => [255,255,220])
|
|
35
|
-
lambda{ KeywordColor.new( rgb ) }.should raise_error( KeywordColor::KeywordError )
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
describe 'from a keyword' do
|
|
40
|
-
it 'should have the right rgb values' do
|
|
41
|
-
light_yellow = KeywordColor.new(:color => :lightyellow)
|
|
42
|
-
light_yellow.r.should == 255
|
|
43
|
-
light_yellow.g.should == 255
|
|
44
|
-
light_yellow.b.should == 224
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
describe 'rendering' do
|
|
50
|
-
it 'should render as given by default' do
|
|
51
|
-
light_yellow = KeywordColor.new(:color => :lightyellow)
|
|
52
|
-
light_yellow.render.should == 'lightyellow'
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
end
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
|
-
|
|
3
|
-
RGBcolor = StyleTrain::RGBcolor unless defined?( RGBcolor )
|
|
4
|
-
|
|
5
|
-
describe RGBcolor do
|
|
6
|
-
|
|
7
|
-
it 'should have methods for #red=, #green= and #blue=' do
|
|
8
|
-
RGBcolor.instance_methods.should include( 'red=', 'green=', 'blue=' )
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
describe 'array initialization' do
|
|
12
|
-
it '#red #green and #blue should be set to passed values' do
|
|
13
|
-
color = RGBcolor.new(:color => [20, 40, 60])
|
|
14
|
-
color.red.should == 20
|
|
15
|
-
color.green.should == 40
|
|
16
|
-
color.blue.should == 60
|
|
17
|
-
|
|
18
|
-
color = RGBcolor.new(:color => ['20', '40', '60'])
|
|
19
|
-
color.red.should == '20'
|
|
20
|
-
color.green.should == '40'
|
|
21
|
-
color.blue.should == '60'
|
|
22
|
-
|
|
23
|
-
color = RGBcolor.new(:color => ['0%', '50%', '100%'])
|
|
24
|
-
color.red.should == '0%'
|
|
25
|
-
color.green.should == '50%'
|
|
26
|
-
color.blue.should == '100%'
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
it '#r #g and #b (the internal storage ) should be set' do
|
|
30
|
-
color = RGBcolor.new(:color => [20, 40, 60])
|
|
31
|
-
color.r.should == 20
|
|
32
|
-
color.g.should == 40
|
|
33
|
-
color.b.should == 60
|
|
34
|
-
|
|
35
|
-
color = RGBcolor.new(:color => ['20', '40', '60'])
|
|
36
|
-
color.r.should == 20
|
|
37
|
-
color.g.should == 40
|
|
38
|
-
color.b.should == 60
|
|
39
|
-
|
|
40
|
-
color = RGBcolor.new(:color => ['0%', '50%', '100%'])
|
|
41
|
-
color.r.should == 0
|
|
42
|
-
color.g.should == 127
|
|
43
|
-
color.b.should == 255
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
# This should be a shared example
|
|
48
|
-
describe 'alpha' do
|
|
49
|
-
it 'should be 1.0 by default' do
|
|
50
|
-
color = RGBcolor.new(:color => ['0%', '50%', '100%'])
|
|
51
|
-
color.alpha.should == 1.0
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
it 'should be set by the alpha parameter' do
|
|
55
|
-
color = RGBcolor.new(:color => ['0%', '50%', '100%'], :alpha => 0.5 )
|
|
56
|
-
color.alpha.should == 0.5
|
|
57
|
-
|
|
58
|
-
color = RGBcolor.new(:color => ['0%', '50%', '100%'], :alpha => '0.5' )
|
|
59
|
-
color.alpha.should == 0.5
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
it 'render should output rgb css tag' do
|
|
64
|
-
RGBcolor.new(:color => ['0%', '50%', '100%'] ).render.should ==
|
|
65
|
-
"rgb( 0%, 50%, 100% )"
|
|
66
|
-
|
|
67
|
-
RGBcolor.new(:color => [255, 255, 255] ).render.should ==
|
|
68
|
-
"rgb( 255, 255, 255 )"
|
|
69
|
-
|
|
70
|
-
RGBcolor.new(:color => ['255', '255', '255'] ).render.should ==
|
|
71
|
-
"rgb( 255, 255, 255 )"
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
end
|