squib 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitmodules +14 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.md +201 -175
- data/Gemfile +2 -4
- data/README.md +650 -645
- data/RELEASE TODO.md +18 -18
- data/Rakefile +106 -99
- data/appveyor.yml +29 -0
- data/lib/squib.rb +32 -32
- data/lib/squib/api/background.rb +20 -20
- data/lib/squib/api/data.rb +131 -131
- data/lib/squib/api/image.rb +108 -90
- data/lib/squib/api/save.rb +151 -149
- data/lib/squib/api/settings.rb +35 -35
- data/lib/squib/api/shapes.rb +255 -230
- data/lib/squib/api/text.rb +65 -65
- data/lib/squib/api/text_embed.rb +96 -96
- data/lib/squib/args/arg_loader.rb +138 -138
- data/lib/squib/args/box.rb +54 -54
- data/lib/squib/args/card_range.rb +32 -32
- data/lib/squib/args/color_validator.rb +11 -11
- data/lib/squib/args/coords.rb +32 -32
- data/lib/squib/args/dir_validator.rb +16 -16
- data/lib/squib/args/draw.rb +92 -92
- data/lib/squib/args/embed_adjust.rb +25 -25
- data/lib/squib/args/embed_key.rb +17 -17
- data/lib/squib/args/hand_special.rb +37 -37
- data/lib/squib/args/import.rb +39 -39
- data/lib/squib/args/input_file.rb +37 -37
- data/lib/squib/args/paint.rb +43 -43
- data/lib/squib/args/paragraph.rb +116 -115
- data/lib/squib/args/save_batch.rb +63 -60
- data/lib/squib/args/scale_box.rb +53 -53
- data/lib/squib/args/sheet.rb +72 -72
- data/lib/squib/args/showcase_special.rb +38 -38
- data/lib/squib/args/svg_special.rb +37 -37
- data/lib/squib/args/transform.rb +60 -24
- data/lib/squib/args/typographer.rb +117 -117
- data/lib/squib/card.rb +66 -67
- data/lib/squib/conf.rb +131 -117
- data/lib/squib/constants.rb +12 -178
- data/lib/squib/deck.rb +113 -113
- data/lib/squib/graphics/cairo_context_wrapper.rb +113 -99
- data/lib/squib/graphics/gradient_regex.rb +46 -46
- data/lib/squib/graphics/hand.rb +42 -42
- data/lib/squib/graphics/image.rb +103 -76
- data/lib/squib/graphics/save_doc.rb +103 -103
- data/lib/squib/graphics/save_images.rb +39 -33
- data/lib/squib/graphics/shapes.rb +135 -119
- data/lib/squib/graphics/showcase.rb +85 -85
- data/lib/squib/graphics/text.rb +176 -176
- data/lib/squib/layout_parser.rb +91 -91
- data/lib/squib/layouts/economy.yml +85 -85
- data/lib/squib/layouts/fantasy.yml +101 -101
- data/lib/squib/layouts/hand.yml +62 -62
- data/lib/squib/layouts/playing-card.yml +35 -35
- data/lib/squib/layouts/tuck_box.yml +45 -45
- data/lib/squib/project_template/IDEAS.md +22 -0
- data/lib/squib/project_template/PLAYTESTING.md +26 -0
- data/lib/squib/project_template/RULES.md +21 -0
- data/lib/squib/project_template/config.yml +49 -45
- data/lib/squib/sample_helpers.rb +34 -0
- data/lib/squib/version.rb +10 -10
- data/samples/autoscale_font/_autoscale_font.rb +29 -0
- data/samples/color_shortcuts.rb +6 -6
- data/samples/csv_import.rb +26 -26
- data/samples/custom-config.yml +5 -5
- data/samples/custom_config.rb +18 -18
- data/samples/draw_shapes.rb +48 -45
- data/samples/embed_text.rb +88 -88
- data/samples/excel.rb +55 -55
- data/samples/hand.rb +24 -24
- data/samples/images/_images.rb +104 -0
- data/samples/intro/01_hello.rb +9 -0
- data/samples/intro/02_options.rb +15 -0
- data/samples/intro/03_layout.rb +12 -0
- data/samples/intro/04_arrays.rb +16 -0
- data/samples/intro/05_excel.rb +15 -0
- data/samples/layouts.rb +62 -62
- data/samples/layouts_builtin.rb +51 -51
- data/samples/load_images.rb +99 -78
- data/samples/load_images_config.yml +1 -0
- data/samples/quantity_explosion.csv +2 -2
- data/samples/ranges.rb +64 -64
- data/samples/sample.csv +2 -2
- data/samples/saves.rb +9 -1
- data/samples/sprites.png +0 -0
- data/samples/text/_text.rb +46 -0
- data/samples/text_options.rb +102 -102
- data/spec/api/api_data_spec.rb +117 -117
- data/spec/api/api_settings_spec.rb +37 -37
- data/spec/args/box_spec.rb +127 -127
- data/spec/args/draw_spec.rb +101 -95
- data/spec/args/embed_key_spec.rb +13 -13
- data/spec/args/input_file_spec.rb +21 -21
- data/spec/args/paint_spec.rb +21 -21
- data/spec/args/paragraph_spec.rb +152 -152
- data/spec/args/range_spec.rb +40 -40
- data/spec/args/save_batch_spec.rb +51 -51
- data/spec/args/scale_box_spec.rb +71 -71
- data/spec/args/sheet_spec.rb +58 -58
- data/spec/args/showcase_special_spec.rb +15 -15
- data/spec/args/transform_spec.rb +25 -0
- data/spec/card_spec.rb +11 -0
- data/spec/conf_spec.rb +13 -3
- data/spec/data/conf/unrecognized.yml +4 -0
- data/spec/data/csv/qty.csv +2 -2
- data/spec/data/csv/qty_named.csv +2 -2
- data/spec/data/csv/with_spaces.csv +2 -2
- data/spec/data/samples/autoscale_font.rb.txt +84 -84
- data/spec/data/samples/basic.rb.txt +227 -209
- data/spec/data/samples/config_text_markup.rb.txt +72 -72
- data/spec/data/samples/csv_import.rb.txt +213 -213
- data/spec/data/samples/custom_config.rb.txt +57 -48
- data/spec/data/samples/draw_shapes.rb.txt +555 -3
- data/spec/data/samples/embed_text.rb.txt +283 -283
- data/spec/data/samples/excel.rb.txt +661 -661
- data/spec/data/samples/gradients.rb.txt +77 -79
- data/spec/data/samples/hand.rb.txt +538 -538
- data/spec/data/samples/hello_world.rb.txt +36 -36
- data/spec/data/samples/load_images.rb.txt +170 -0
- data/spec/data/samples/portrait-landscape.rb.txt +51 -49
- data/spec/data/samples/ranges.rb.txt +472 -460
- data/spec/data/samples/saves.rb.txt +810 -801
- data/spec/data/samples/showcase.rb.txt +5926 -5910
- data/spec/data/samples/text_options.rb.txt +1125 -1125
- data/spec/data/samples/tgc_proofs.rb.txt +95 -81
- data/spec/graphics/cairo_context_wrapper_spec.rb +104 -84
- data/spec/graphics/graphics_save_doc_spec.rb +67 -67
- data/spec/samples/diff-with-css.example.html +39 -0
- data/spec/samples/expected/load_images_00.png +0 -0
- data/spec/samples/expected/shape_00.png +0 -0
- data/spec/samples/run_samples_spec.rb +17 -0
- data/spec/samples/samples_regression_spec.rb +72 -82
- data/spec/spec_helper.rb +9 -1
- data/squib.gemspec +49 -48
- data/squib.sublime-project +42 -42
- metadata +94 -48
- data/spec/graphics/graphics_images_spec.rb +0 -94
data/spec/args/box_spec.rb
CHANGED
@@ -1,127 +1,127 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'squib/args/box'
|
3
|
-
|
4
|
-
describe Squib::Args::Box do
|
5
|
-
subject(:box) { Squib::Args::Box.new }
|
6
|
-
let(:expected_defaults) { {x: [0], y: [0], width: [:deck], height: [:deck] } }
|
7
|
-
|
8
|
-
it 'intitially has no params set' do
|
9
|
-
expect(box).not_to respond_to(:x, :y, :width, :height)
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'extracts the defaults from Box on an empty hash' do
|
13
|
-
box.load!({})
|
14
|
-
expect(box).to have_attributes(expected_defaults)
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'extracts what is specified and fills in defaults from Box' do
|
18
|
-
box.load!(x: 4, width: 40)
|
19
|
-
expect(box).to have_attributes(x: [4], width: [40], y: [0], height: [:deck])
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'extracts the defaults from Box on an empty hash' do
|
23
|
-
box.load!({foo: :bar})
|
24
|
-
expect(box).to have_attributes(expected_defaults)
|
25
|
-
expect(box).not_to respond_to(:foo)
|
26
|
-
end
|
27
|
-
|
28
|
-
context 'single expansion' do
|
29
|
-
let(:args) { {x: [1, 2], y: 3} }
|
30
|
-
before(:each) { box.load!(args, expand_by: 2) }
|
31
|
-
it 'expands box' do
|
32
|
-
expect(box).to have_attributes({
|
33
|
-
x: [1, 2],
|
34
|
-
y: [3, 3],
|
35
|
-
height: [:deck, :deck],
|
36
|
-
width: [:deck, :deck]
|
37
|
-
})
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'gives access to each card too' do
|
41
|
-
expect(box[0]).to have_attributes({
|
42
|
-
x: 1,
|
43
|
-
y: 3,
|
44
|
-
height: :deck,
|
45
|
-
width: :deck
|
46
|
-
})
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context 'layouts' do
|
51
|
-
let(:layout) do
|
52
|
-
{ 'attack' => { 'x' => 50 },
|
53
|
-
'defend' => { 'x' => 60 } }
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'are used when not specified' do
|
57
|
-
args = { layout: ['attack', 'defend'] }
|
58
|
-
box.load!(args, expand_by: 2, layout: layout)
|
59
|
-
expect(box).to have_attributes(
|
60
|
-
x: [50, 60], # set by layout
|
61
|
-
y: [0, 0], # Box default
|
62
|
-
)
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'handle single expansion' do
|
66
|
-
args = { layout: 'attack' }
|
67
|
-
box.load!(args, expand_by: 2, layout: layout)
|
68
|
-
expect(box).to have_attributes(
|
69
|
-
x: [50, 50], # set by layout
|
70
|
-
y: [0, 0], # Box default
|
71
|
-
)
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'handles symbols' do
|
75
|
-
args = { layout: :attack }
|
76
|
-
box.load!(args, expand_by: 2, layout: layout)
|
77
|
-
expect(box).to have_attributes(
|
78
|
-
x: [50, 50], # set by layout
|
79
|
-
y: [0, 0], # Box default
|
80
|
-
)
|
81
|
-
end
|
82
|
-
|
83
|
-
it 'warns on non-existent layouts' do
|
84
|
-
args = { layout: :heal}
|
85
|
-
expect(Squib.logger).to receive(:warn).with('Layout "heal" does not exist in layout file - using default instead').at_least(:once)
|
86
|
-
box.load!(args, expand_by: 2, layout: layout)
|
87
|
-
expect(box).to have_attributes(
|
88
|
-
x: [0, 0], # Box default
|
89
|
-
y: [0, 0], # Box default
|
90
|
-
)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
context 'unit conversion' do
|
95
|
-
|
96
|
-
it 'converts units on all args' do
|
97
|
-
args = {x: ['1in', '2in'], y: 300, width: '1in', height: '1in'}
|
98
|
-
box.load!(args, expand_by: 2)
|
99
|
-
expect(box).to have_attributes(
|
100
|
-
x: [300, 600],
|
101
|
-
y: [300, 300],
|
102
|
-
width: [300, 300],
|
103
|
-
height: [300, 300],
|
104
|
-
)
|
105
|
-
end
|
106
|
-
|
107
|
-
end
|
108
|
-
|
109
|
-
context 'validation' do
|
110
|
-
it 'replaces with deck width and height' do
|
111
|
-
args = {width: :deck, height: :deck}
|
112
|
-
deck = OpenStruct.new(width: 123, height: 456)
|
113
|
-
box = Squib::Args::Box.new(deck)
|
114
|
-
box.load!(args, expand_by: 1)
|
115
|
-
expect(box).to have_attributes(width: [123], height: [456])
|
116
|
-
end
|
117
|
-
|
118
|
-
it 'has radius override x_radius and y_radius' do
|
119
|
-
args = {x_radius: 1, y_radius: 2, radius: 3}
|
120
|
-
box.load!(args, expand_by: 2)
|
121
|
-
expect(box).to have_attributes(x_radius: [3, 3], y_radius: [3, 3])
|
122
|
-
end
|
123
|
-
|
124
|
-
end
|
125
|
-
|
126
|
-
|
127
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'squib/args/box'
|
3
|
+
|
4
|
+
describe Squib::Args::Box do
|
5
|
+
subject(:box) { Squib::Args::Box.new }
|
6
|
+
let(:expected_defaults) { {x: [0], y: [0], width: [:deck], height: [:deck] } }
|
7
|
+
|
8
|
+
it 'intitially has no params set' do
|
9
|
+
expect(box).not_to respond_to(:x, :y, :width, :height)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'extracts the defaults from Box on an empty hash' do
|
13
|
+
box.load!({})
|
14
|
+
expect(box).to have_attributes(expected_defaults)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'extracts what is specified and fills in defaults from Box' do
|
18
|
+
box.load!(x: 4, width: 40)
|
19
|
+
expect(box).to have_attributes(x: [4], width: [40], y: [0], height: [:deck])
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'extracts the defaults from Box on an empty hash' do
|
23
|
+
box.load!({foo: :bar})
|
24
|
+
expect(box).to have_attributes(expected_defaults)
|
25
|
+
expect(box).not_to respond_to(:foo)
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'single expansion' do
|
29
|
+
let(:args) { {x: [1, 2], y: 3} }
|
30
|
+
before(:each) { box.load!(args, expand_by: 2) }
|
31
|
+
it 'expands box' do
|
32
|
+
expect(box).to have_attributes({
|
33
|
+
x: [1, 2],
|
34
|
+
y: [3, 3],
|
35
|
+
height: [:deck, :deck],
|
36
|
+
width: [:deck, :deck]
|
37
|
+
})
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'gives access to each card too' do
|
41
|
+
expect(box[0]).to have_attributes({
|
42
|
+
x: 1,
|
43
|
+
y: 3,
|
44
|
+
height: :deck,
|
45
|
+
width: :deck
|
46
|
+
})
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'layouts' do
|
51
|
+
let(:layout) do
|
52
|
+
{ 'attack' => { 'x' => 50 },
|
53
|
+
'defend' => { 'x' => 60 } }
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'are used when not specified' do
|
57
|
+
args = { layout: ['attack', 'defend'] }
|
58
|
+
box.load!(args, expand_by: 2, layout: layout)
|
59
|
+
expect(box).to have_attributes(
|
60
|
+
x: [50, 60], # set by layout
|
61
|
+
y: [0, 0], # Box default
|
62
|
+
)
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'handle single expansion' do
|
66
|
+
args = { layout: 'attack' }
|
67
|
+
box.load!(args, expand_by: 2, layout: layout)
|
68
|
+
expect(box).to have_attributes(
|
69
|
+
x: [50, 50], # set by layout
|
70
|
+
y: [0, 0], # Box default
|
71
|
+
)
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'handles symbols' do
|
75
|
+
args = { layout: :attack }
|
76
|
+
box.load!(args, expand_by: 2, layout: layout)
|
77
|
+
expect(box).to have_attributes(
|
78
|
+
x: [50, 50], # set by layout
|
79
|
+
y: [0, 0], # Box default
|
80
|
+
)
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'warns on non-existent layouts' do
|
84
|
+
args = { layout: :heal}
|
85
|
+
expect(Squib.logger).to receive(:warn).with('Layout "heal" does not exist in layout file - using default instead').at_least(:once)
|
86
|
+
box.load!(args, expand_by: 2, layout: layout)
|
87
|
+
expect(box).to have_attributes(
|
88
|
+
x: [0, 0], # Box default
|
89
|
+
y: [0, 0], # Box default
|
90
|
+
)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
context 'unit conversion' do
|
95
|
+
|
96
|
+
it 'converts units on all args' do
|
97
|
+
args = {x: ['1in', '2in'], y: 300, width: '1in', height: '1in'}
|
98
|
+
box.load!(args, expand_by: 2)
|
99
|
+
expect(box).to have_attributes(
|
100
|
+
x: [300, 600],
|
101
|
+
y: [300, 300],
|
102
|
+
width: [300, 300],
|
103
|
+
height: [300, 300],
|
104
|
+
)
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
context 'validation' do
|
110
|
+
it 'replaces with deck width and height' do
|
111
|
+
args = {width: :deck, height: :deck}
|
112
|
+
deck = OpenStruct.new(width: 123, height: 456)
|
113
|
+
box = Squib::Args::Box.new(deck)
|
114
|
+
box.load!(args, expand_by: 1)
|
115
|
+
expect(box).to have_attributes(width: [123], height: [456])
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'has radius override x_radius and y_radius' do
|
119
|
+
args = {x_radius: 1, y_radius: 2, radius: 3}
|
120
|
+
box.load!(args, expand_by: 2)
|
121
|
+
expect(box).to have_attributes(x_radius: [3, 3], y_radius: [3, 3])
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
|
126
|
+
|
127
|
+
end
|
data/spec/args/draw_spec.rb
CHANGED
@@ -1,95 +1,101 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'squib/args/draw'
|
3
|
-
|
4
|
-
describe Squib::Args::Draw do
|
5
|
-
let(:custom_colors) { {'foo' => 'abc'} }
|
6
|
-
subject(:draw) {Squib::Args::Draw.new(custom_colors)}
|
7
|
-
|
8
|
-
context 'unit conversion' do
|
9
|
-
|
10
|
-
it 'converts units on stroke width' do
|
11
|
-
args = {stroke_width: '2in'}
|
12
|
-
draw.load!(args, expand_by: 2)
|
13
|
-
expect(draw).to have_attributes(stroke_width: [600, 600])
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
context 'dsl overrides' do
|
19
|
-
subject(:draw) {Squib::Args::Draw.new(custom_colors, {stroke_width: 0.0})}
|
20
|
-
|
21
|
-
it 'works when specified' do
|
22
|
-
draw.load!({}) # go right to defaults
|
23
|
-
expect(draw.stroke_width).to eq( [0.0] ) #ordinarily a non-zero according
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
context 'validation' do
|
29
|
-
|
30
|
-
it 'converts to Cairo options' do
|
31
|
-
args = {join: 'bevel', cap: 'round'}
|
32
|
-
draw.load!(args)
|
33
|
-
expect(draw).to have_attributes(
|
34
|
-
join: [Cairo::LINE_JOIN_BEVEL],
|
35
|
-
cap: [Cairo::LINE_JOIN_ROUND]
|
36
|
-
)
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'parses dash options' do
|
40
|
-
args = {dash: '3 4 5'}
|
41
|
-
draw.load!(args)
|
42
|
-
expect(draw).to have_attributes(dash: [[3, 4, 5]])
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'parses more complex dash options' do
|
46
|
-
args = {dash: '30.5, 90, 5'}
|
47
|
-
draw.load!(args)
|
48
|
-
expect(draw).to have_attributes(dash: [[30.5, 90, 5]])
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'does unit conversion on dash options' do
|
52
|
-
args = {dash: '3in 4in 5in'}
|
53
|
-
draw.load!(args)
|
54
|
-
expect(draw).to have_attributes(dash: [[900, 1200, 1500]])
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'converts line caps to Cairo constants' do
|
58
|
-
args = {cap: :SQUARE}
|
59
|
-
draw.load! args
|
60
|
-
expect(draw).to have_attributes( cap: [Cairo::LINE_CAP_SQUARE] )
|
61
|
-
end
|
62
|
-
|
63
|
-
it '
|
64
|
-
args = {
|
65
|
-
draw.load! args
|
66
|
-
expect(draw).to have_attributes(
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'allows
|
70
|
-
args = {stroke_strategy:
|
71
|
-
draw.load! args
|
72
|
-
expect(draw).to have_attributes( stroke_strategy: [:
|
73
|
-
end
|
74
|
-
|
75
|
-
it '
|
76
|
-
args = {stroke_strategy: '
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
draw.load!({color: '
|
90
|
-
expect(draw.color).to eq ['
|
91
|
-
end
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'squib/args/draw'
|
3
|
+
|
4
|
+
describe Squib::Args::Draw do
|
5
|
+
let(:custom_colors) { {'foo' => 'abc'} }
|
6
|
+
subject(:draw) {Squib::Args::Draw.new(custom_colors)}
|
7
|
+
|
8
|
+
context 'unit conversion' do
|
9
|
+
|
10
|
+
it 'converts units on stroke width' do
|
11
|
+
args = {stroke_width: '2in'}
|
12
|
+
draw.load!(args, expand_by: 2)
|
13
|
+
expect(draw).to have_attributes(stroke_width: [600, 600])
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'dsl overrides' do
|
19
|
+
subject(:draw) {Squib::Args::Draw.new(custom_colors, {stroke_width: 0.0})}
|
20
|
+
|
21
|
+
it 'works when specified' do
|
22
|
+
draw.load!({}) # go right to defaults
|
23
|
+
expect(draw.stroke_width).to eq( [0.0] ) #ordinarily a non-zero according
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'validation' do
|
29
|
+
|
30
|
+
it 'converts to Cairo options' do
|
31
|
+
args = {join: 'bevel', cap: 'round'}
|
32
|
+
draw.load!(args)
|
33
|
+
expect(draw).to have_attributes(
|
34
|
+
join: [Cairo::LINE_JOIN_BEVEL],
|
35
|
+
cap: [Cairo::LINE_JOIN_ROUND]
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'parses dash options' do
|
40
|
+
args = {dash: '3 4 5'}
|
41
|
+
draw.load!(args)
|
42
|
+
expect(draw).to have_attributes(dash: [[3, 4, 5]])
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'parses more complex dash options' do
|
46
|
+
args = {dash: '30.5, 90, 5'}
|
47
|
+
draw.load!(args)
|
48
|
+
expect(draw).to have_attributes(dash: [[30.5, 90, 5]])
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'does unit conversion on dash options' do
|
52
|
+
args = {dash: '3in 4in 5in'}
|
53
|
+
draw.load!(args)
|
54
|
+
expect(draw).to have_attributes(dash: [[900, 1200, 1500]])
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'converts line caps to Cairo constants' do
|
58
|
+
args = {cap: :SQUARE}
|
59
|
+
draw.load! args
|
60
|
+
expect(draw).to have_attributes( cap: [Cairo::LINE_CAP_SQUARE] )
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'converts line join' do
|
64
|
+
args = {join: 'round'}
|
65
|
+
draw.load! args
|
66
|
+
expect(draw).to have_attributes( join: [Cairo::LINE_JOIN_ROUND] )
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'allows fill_first stroke_strategy' do
|
70
|
+
args = {stroke_strategy: :FILL_first}
|
71
|
+
draw.load! args
|
72
|
+
expect(draw).to have_attributes( stroke_strategy: [:fill_first] )
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'allows stroke_first stroke_strategy' do
|
76
|
+
args = {stroke_strategy: ' stroke_FIRST '}
|
77
|
+
draw.load! args
|
78
|
+
expect(draw).to have_attributes( stroke_strategy: [:stroke_first] )
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'disallows anything not stroke_first and fill_first' do
|
82
|
+
args = {stroke_strategy: 'foo'}
|
83
|
+
expect { draw.load! args }.to raise_error("Only 'stroke_first' or 'fill_first' allowed")
|
84
|
+
end
|
85
|
+
|
86
|
+
context 'custom colors' do
|
87
|
+
|
88
|
+
it 'looks up custom colors in the config' do
|
89
|
+
draw.load!({color: 'foo'})
|
90
|
+
expect(draw.color).to eq ['abc']
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'passes on through for non-custom color' do
|
94
|
+
draw = Squib::Args::Draw.new(custom_colors)
|
95
|
+
draw.load!({color: 'bar'})
|
96
|
+
expect(draw.color).to eq ['bar']
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
data/spec/args/embed_key_spec.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'squib/args/embed_key'
|
3
|
-
|
4
|
-
describe Squib::Args::EmbedKey do
|
5
|
-
|
6
|
-
context '#validate_key' do
|
7
|
-
|
8
|
-
it 'converts to string' do
|
9
|
-
expect(subject.validate_key(2.5)).to eq ('2.5')
|
10
|
-
end
|
11
|
-
|
12
|
-
end
|
13
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'squib/args/embed_key'
|
3
|
+
|
4
|
+
describe Squib::Args::EmbedKey do
|
5
|
+
|
6
|
+
context '#validate_key' do
|
7
|
+
|
8
|
+
it 'converts to string' do
|
9
|
+
expect(subject.validate_key(2.5)).to eq ('2.5')
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|