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
@@ -1,51 +1,51 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'squib/args/save_batch'
|
3
|
-
|
4
|
-
describe Squib::Args::SaveBatch do
|
5
|
-
subject(:save_batch) {Squib::Args::SaveBatch.new}
|
6
|
-
|
7
|
-
context 'dir' do
|
8
|
-
it 'is created if not exists (and warns)' do
|
9
|
-
opts = {dir: 'tocreate'}
|
10
|
-
Dir.chdir(output_dir) do
|
11
|
-
FileUtils.rm_rf('tocreate', secure: true)
|
12
|
-
expect(Squib.logger).to receive(:warn).with("Dir 'tocreate' does not exist, creating it.").once
|
13
|
-
save_batch.load! opts
|
14
|
-
expect(save_batch).to have_attributes({dir: ['tocreate']})
|
15
|
-
expect(Dir.exists? 'tocreate').to be true
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
context 'rotate' do
|
21
|
-
it 'does nothing by default' do
|
22
|
-
opts = {}
|
23
|
-
save_batch.load! opts
|
24
|
-
expect(save_batch[0]).to have_attributes({rotate: false, angle: 0})
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'rotates by pi/2 with true' do
|
28
|
-
opts = {rotate: true}
|
29
|
-
save_batch.load! opts
|
30
|
-
expect(save_batch[0]).to have_attributes({rotate: true, angle: Math::PI / 2})
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'rotates by pi/2' do
|
34
|
-
opts = {rotate: :clockwise}
|
35
|
-
save_batch.load! opts
|
36
|
-
expect(save_batch[0]).to have_attributes({rotate: true, angle: Math::PI / 2})
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'rotates by pi/2 with counterclockwise' do
|
40
|
-
opts = {rotate: :counterclockwise}
|
41
|
-
save_batch.load! opts
|
42
|
-
expect(save_batch[0]).to have_attributes({rotate: true, angle: 3 * Math::PI / 2})
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'raises error on a number' do
|
46
|
-
opts = {rotate: 5.0}
|
47
|
-
expect { save_batch.load!(opts) }.to raise_error('invalid option to rotate: only [true, false, :clockwise, :counterclockwise]')
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'squib/args/save_batch'
|
3
|
+
|
4
|
+
describe Squib::Args::SaveBatch do
|
5
|
+
subject(:save_batch) {Squib::Args::SaveBatch.new}
|
6
|
+
|
7
|
+
context 'dir' do
|
8
|
+
it 'is created if not exists (and warns)' do
|
9
|
+
opts = {dir: 'tocreate'}
|
10
|
+
Dir.chdir(output_dir) do
|
11
|
+
FileUtils.rm_rf('tocreate', secure: true)
|
12
|
+
expect(Squib.logger).to receive(:warn).with("Dir 'tocreate' does not exist, creating it.").once
|
13
|
+
save_batch.load! opts
|
14
|
+
expect(save_batch).to have_attributes({dir: ['tocreate']})
|
15
|
+
expect(Dir.exists? 'tocreate').to be true
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'rotate' do
|
21
|
+
it 'does nothing by default' do
|
22
|
+
opts = {}
|
23
|
+
save_batch.load! opts
|
24
|
+
expect(save_batch[0]).to have_attributes({rotate: false, angle: 0})
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'rotates by pi/2 with true' do
|
28
|
+
opts = {rotate: true}
|
29
|
+
save_batch.load! opts
|
30
|
+
expect(save_batch[0]).to have_attributes({rotate: true, angle: Math::PI / 2})
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'rotates by pi/2' do
|
34
|
+
opts = {rotate: :clockwise}
|
35
|
+
save_batch.load! opts
|
36
|
+
expect(save_batch[0]).to have_attributes({rotate: true, angle: Math::PI / 2})
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'rotates by pi/2 with counterclockwise' do
|
40
|
+
opts = {rotate: :counterclockwise}
|
41
|
+
save_batch.load! opts
|
42
|
+
expect(save_batch[0]).to have_attributes({rotate: true, angle: 3 * Math::PI / 2})
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'raises error on a number' do
|
46
|
+
opts = {rotate: 5.0}
|
47
|
+
expect { save_batch.load!(opts) }.to raise_error('invalid option to rotate: only [true, false, :clockwise, :counterclockwise]')
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
data/spec/args/scale_box_spec.rb
CHANGED
@@ -1,71 +1,71 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'squib/args/scale_box'
|
3
|
-
|
4
|
-
describe Squib::Args::ScaleBox do
|
5
|
-
subject(:box) { Squib::Args::ScaleBox.new({}) }
|
6
|
-
|
7
|
-
context 'unit conversion' do
|
8
|
-
it 'converts units on all args' do
|
9
|
-
args = {x: ['1in', '2in'], y: 300, width: '1in', height: '1in'}
|
10
|
-
box.load!(args, expand_by: 2)
|
11
|
-
expect(box).to have_attributes(
|
12
|
-
x: [300, 600],
|
13
|
-
y: [300, 300],
|
14
|
-
width: [300, 300],
|
15
|
-
height: [300, 300],
|
16
|
-
)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
context 'validation' do
|
21
|
-
it 'replaces with deck width and height' do
|
22
|
-
args = {width: :deck, height: :deck}
|
23
|
-
deck = OpenStruct.new(width: 123, height: 456)
|
24
|
-
box = Squib::Args::Box.new(deck)
|
25
|
-
box.load!(args, expand_by: 1)
|
26
|
-
expect(box).to have_attributes(width: [123], height: [456])
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'allows :native' do
|
30
|
-
args = {width: :native, height: :native}
|
31
|
-
box.load!(args, expand_by: 1)
|
32
|
-
expect(box).to have_attributes(width: [:native], height: [:native])
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'allows native to be a string' do
|
36
|
-
args = {width: 'native'}
|
37
|
-
box.load!(args, expand_by: 1)
|
38
|
-
expect(box).to have_attributes(width: [:native], height: [:native])
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'allows :scale on width if height has to_f' do
|
42
|
-
args = {width: :scale, height: 75}
|
43
|
-
box.load!(args, expand_by: 1)
|
44
|
-
expect(box).to have_attributes(width: [:scale], height: [75])
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'allows :scale on width if height has to_f' do
|
48
|
-
args = {width: 75, height: :scale}
|
49
|
-
box.load!(args, expand_by: 1)
|
50
|
-
expect(box).to have_attributes(width: [75], height: [:scale])
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'disallows both :scale' do
|
54
|
-
args = {width: :scale, height: :scale}
|
55
|
-
expect { box.load!(args, expand_by: 1) }.to raise_error('if width is :scale, height must be a number')
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'disallows non-to_f on width' do
|
59
|
-
args = {width: :foo}
|
60
|
-
expect { box.load!(args, expand_by: 1) }.to raise_error('width must be a number, :scale, :native, or :deck')
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'disallows non-to_f on height' do
|
64
|
-
args = {height: :foo}
|
65
|
-
expect { box.load!(args, expand_by: 1) }.to raise_error('height must be a number, :scale, :native, or :deck')
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
69
|
-
|
70
|
-
|
71
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'squib/args/scale_box'
|
3
|
+
|
4
|
+
describe Squib::Args::ScaleBox do
|
5
|
+
subject(:box) { Squib::Args::ScaleBox.new({}) }
|
6
|
+
|
7
|
+
context 'unit conversion' do
|
8
|
+
it 'converts units on all args' do
|
9
|
+
args = {x: ['1in', '2in'], y: 300, width: '1in', height: '1in'}
|
10
|
+
box.load!(args, expand_by: 2)
|
11
|
+
expect(box).to have_attributes(
|
12
|
+
x: [300, 600],
|
13
|
+
y: [300, 300],
|
14
|
+
width: [300, 300],
|
15
|
+
height: [300, 300],
|
16
|
+
)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'validation' do
|
21
|
+
it 'replaces with deck width and height' do
|
22
|
+
args = {width: :deck, height: :deck}
|
23
|
+
deck = OpenStruct.new(width: 123, height: 456)
|
24
|
+
box = Squib::Args::Box.new(deck)
|
25
|
+
box.load!(args, expand_by: 1)
|
26
|
+
expect(box).to have_attributes(width: [123], height: [456])
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'allows :native' do
|
30
|
+
args = {width: :native, height: :native}
|
31
|
+
box.load!(args, expand_by: 1)
|
32
|
+
expect(box).to have_attributes(width: [:native], height: [:native])
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'allows native to be a string' do
|
36
|
+
args = {width: 'native'}
|
37
|
+
box.load!(args, expand_by: 1)
|
38
|
+
expect(box).to have_attributes(width: [:native], height: [:native])
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'allows :scale on width if height has to_f' do
|
42
|
+
args = {width: :scale, height: 75}
|
43
|
+
box.load!(args, expand_by: 1)
|
44
|
+
expect(box).to have_attributes(width: [:scale], height: [75])
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'allows :scale on width if height has to_f' do
|
48
|
+
args = {width: 75, height: :scale}
|
49
|
+
box.load!(args, expand_by: 1)
|
50
|
+
expect(box).to have_attributes(width: [75], height: [:scale])
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'disallows both :scale' do
|
54
|
+
args = {width: :scale, height: :scale}
|
55
|
+
expect { box.load!(args, expand_by: 1) }.to raise_error('if width is :scale, height must be a number')
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'disallows non-to_f on width' do
|
59
|
+
args = {width: :foo}
|
60
|
+
expect { box.load!(args, expand_by: 1) }.to raise_error('width must be a number, :scale, :native, or :deck')
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'disallows non-to_f on height' do
|
64
|
+
args = {height: :foo}
|
65
|
+
expect { box.load!(args, expand_by: 1) }.to raise_error('height must be a number, :scale, :native, or :deck')
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
end
|
data/spec/args/sheet_spec.rb
CHANGED
@@ -1,58 +1,58 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'squib/args/sheet'
|
3
|
-
|
4
|
-
describe Squib::Args::Sheet do
|
5
|
-
|
6
|
-
context 'dsl overrides' do
|
7
|
-
subject(:sheet) { Squib::Args::Sheet.new({}, {file: 'foo'}) }
|
8
|
-
|
9
|
-
it 'works when specified' do
|
10
|
-
sheet.load!({}) # go right to defaults
|
11
|
-
expect(sheet.file).to eq( 'foo' ) # dsl method default override
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
context 'rows and colums' do
|
17
|
-
subject(:sheet) { Squib::Args::Sheet.new({}, {}, 4) }
|
18
|
-
|
19
|
-
it 'does nothing on a perfect fit' do
|
20
|
-
opts = { columns: 2, rows: 2 }
|
21
|
-
sheet.load! opts
|
22
|
-
expect(sheet).to have_attributes(columns: 2, rows: 2)
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'keeps both if specified' do
|
26
|
-
opts = { columns: 1, rows: 1 }
|
27
|
-
sheet.load! opts
|
28
|
-
expect(sheet).to have_attributes(columns: 1, rows: 1)
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'computes properly on non-integer' do
|
32
|
-
opts = {columns: 1, rows: :infinite}
|
33
|
-
sheet.load! opts
|
34
|
-
expect(sheet).to have_attributes( columns: 1, rows: 4 )
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'computes properly on unspecified rows' do
|
38
|
-
opts = {columns: 1}
|
39
|
-
sheet.load! opts
|
40
|
-
expect(sheet).to have_attributes( columns: 1, rows: 4 )
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'computes properly on unspecified, too-big column' do
|
44
|
-
opts = {}
|
45
|
-
sheet.load! opts
|
46
|
-
expect(sheet).to have_attributes( columns: 5, rows: 1 )
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'fails on a non-integer column' do
|
50
|
-
opts = {columns: :infinite}
|
51
|
-
expect { sheet.load!(opts) }.to raise_error('columns must be an integer')
|
52
|
-
end
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'squib/args/sheet'
|
3
|
+
|
4
|
+
describe Squib::Args::Sheet do
|
5
|
+
|
6
|
+
context 'dsl overrides' do
|
7
|
+
subject(:sheet) { Squib::Args::Sheet.new({}, {file: 'foo'}) }
|
8
|
+
|
9
|
+
it 'works when specified' do
|
10
|
+
sheet.load!({}) # go right to defaults
|
11
|
+
expect(sheet.file).to eq( 'foo' ) # dsl method default override
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'rows and colums' do
|
17
|
+
subject(:sheet) { Squib::Args::Sheet.new({}, {}, 4) }
|
18
|
+
|
19
|
+
it 'does nothing on a perfect fit' do
|
20
|
+
opts = { columns: 2, rows: 2 }
|
21
|
+
sheet.load! opts
|
22
|
+
expect(sheet).to have_attributes(columns: 2, rows: 2)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'keeps both if specified' do
|
26
|
+
opts = { columns: 1, rows: 1 }
|
27
|
+
sheet.load! opts
|
28
|
+
expect(sheet).to have_attributes(columns: 1, rows: 1)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'computes properly on non-integer' do
|
32
|
+
opts = {columns: 1, rows: :infinite}
|
33
|
+
sheet.load! opts
|
34
|
+
expect(sheet).to have_attributes( columns: 1, rows: 4 )
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'computes properly on unspecified rows' do
|
38
|
+
opts = {columns: 1}
|
39
|
+
sheet.load! opts
|
40
|
+
expect(sheet).to have_attributes( columns: 1, rows: 4 )
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'computes properly on unspecified, too-big column' do
|
44
|
+
opts = {}
|
45
|
+
sheet.load! opts
|
46
|
+
expect(sheet).to have_attributes( columns: 5, rows: 1 )
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'fails on a non-integer column' do
|
50
|
+
opts = {columns: :infinite}
|
51
|
+
expect { sheet.load!(opts) }.to raise_error('columns must be an integer')
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
@@ -1,15 +1,15 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'squib/args/showcase_special'
|
3
|
-
|
4
|
-
describe Squib::Args::ShowcaseSpecial do
|
5
|
-
subject(:showcase_special) { Squib::Args::ShowcaseSpecial.new }
|
6
|
-
|
7
|
-
context '#face_right?' do
|
8
|
-
it 'compares face to right' do
|
9
|
-
opts = { face: 'LEFT ' }
|
10
|
-
showcase_special.load! opts
|
11
|
-
expect(showcase_special.face_right?).to be false
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'squib/args/showcase_special'
|
3
|
+
|
4
|
+
describe Squib::Args::ShowcaseSpecial do
|
5
|
+
subject(:showcase_special) { Squib::Args::ShowcaseSpecial.new }
|
6
|
+
|
7
|
+
context '#face_right?' do
|
8
|
+
it 'compares face to right' do
|
9
|
+
opts = { face: 'LEFT ' }
|
10
|
+
showcase_special.load! opts
|
11
|
+
expect(showcase_special.face_right?).to be false
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'squib/args/transform'
|
3
|
+
|
4
|
+
describe Squib::Args::Box do
|
5
|
+
subject(:trans) { Squib::Args::Transform.new }
|
6
|
+
let(:expected_defaults) { {x: [0], y: [0], crop_width: [:native], crop_height: [:native] } }
|
7
|
+
|
8
|
+
context 'validation' do
|
9
|
+
it 'replaces with deck width and height' do
|
10
|
+
args = {crop_width: :deck, crop_height: :deck}
|
11
|
+
deck = OpenStruct.new(width: 123, height: 456)
|
12
|
+
trans = Squib::Args::Transform.new(deck)
|
13
|
+
trans.load!(args, expand_by: 1)
|
14
|
+
expect(trans).to have_attributes(crop_width: [123], crop_height: [456])
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'has radius override x_radius and y_radius' do
|
18
|
+
args = {crop_corner_x_radius: 1, crop_corner_y_radius: 2, crop_corner_radius: 3}
|
19
|
+
trans.load!(args, expand_by: 2)
|
20
|
+
expect(trans).to have_attributes(crop_corner_x_radius: [3, 3], crop_corner_y_radius: [3, 3])
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
data/spec/card_spec.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'squib/card'
|
3
|
+
|
4
|
+
describe Squib::Card do
|
5
|
+
it 'logs fatal for unknown backend' do
|
6
|
+
deck = OpenStruct.new(dir: '.', prefix: '', count_format: '%02d', backend: 'broken robots')
|
7
|
+
|
8
|
+
expect(Squib::logger).to receive(:fatal).with("Back end not recognized: 'broken robots'")
|
9
|
+
expect { Squib::Card.new(deck, 100, 100, 0) }.to raise_error SystemExit
|
10
|
+
end
|
11
|
+
end
|
data/spec/conf_spec.rb
CHANGED
@@ -4,17 +4,17 @@ require 'spec_helper'
|
|
4
4
|
describe Squib::Conf do
|
5
5
|
|
6
6
|
it 'parses the project template file just fine' do
|
7
|
-
conf = Squib::Conf.load
|
7
|
+
conf = Squib::Conf.load project_template('config.yml')
|
8
8
|
expect(conf.backend).to eq(Squib::Conf::DEFAULTS['backend'])
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'parses an empty file' do
|
12
|
-
conf = Squib::Conf.load
|
12
|
+
conf = Squib::Conf.load conf('empty.yml')
|
13
13
|
expect(conf.backend).to eq(Squib::Conf::DEFAULTS['backend'])
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'parses the sample custom config' do
|
17
|
-
conf = Squib::Conf.load
|
17
|
+
conf = Squib::Conf.load sample_file('custom-config.yml')
|
18
18
|
expect(conf.progress_bars).to be true
|
19
19
|
expect(conf.text_hint).to eq '#FF0000'
|
20
20
|
expect(conf.custom_colors).to eq({ 'foo' => '#ccc' })
|
@@ -26,4 +26,14 @@ describe Squib::Conf do
|
|
26
26
|
expect(Squib::Conf.new.antialias).to eq 'subpixel'
|
27
27
|
end
|
28
28
|
|
29
|
+
it 'warns when the yml has an unrecognized option' do
|
30
|
+
expect(Squib::logger).to receive(:warn).with('Unrecognized configuration option(s): unicorns')
|
31
|
+
Squib::Conf.load conf('unrecognized.yml')
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'helps Andy get full coverage with a test on to_s' do
|
35
|
+
conf = Squib::Conf.load conf('empty.yml')
|
36
|
+
expect(conf.to_s).to start_with 'Conf: '
|
37
|
+
end
|
38
|
+
|
29
39
|
end
|