squib 0.8.0 → 0.9.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.
- 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,21 +1,21 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'squib/args/input_file'
|
3
|
-
|
4
|
-
describe Squib::Args::InputFile do
|
5
|
-
subject(:ifile) {Squib::Args::InputFile.new}
|
6
|
-
|
7
|
-
context 'validate_file' do
|
8
|
-
|
9
|
-
it 'allows a file if it exists' do
|
10
|
-
args = {file: __FILE__} # I code therefore I am.
|
11
|
-
ifile.load!(args, expand_by: 1)
|
12
|
-
expect(ifile).to have_attributes(file: [File.expand_path(__FILE__)])
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'raises on non-existent file' do
|
16
|
-
args = {file: 'foo.rb'}
|
17
|
-
expect { ifile.load!(args, expand_by: 1) }.to raise_error("File #{File.expand_path('foo.rb')} does not exist!")
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'squib/args/input_file'
|
3
|
+
|
4
|
+
describe Squib::Args::InputFile do
|
5
|
+
subject(:ifile) {Squib::Args::InputFile.new}
|
6
|
+
|
7
|
+
context 'validate_file' do
|
8
|
+
|
9
|
+
it 'allows a file if it exists' do
|
10
|
+
args = {file: __FILE__} # I code therefore I am.
|
11
|
+
ifile.load!(args, expand_by: 1)
|
12
|
+
expect(ifile).to have_attributes(file: [File.expand_path(__FILE__)])
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'raises on non-existent file' do
|
16
|
+
args = {file: 'foo.rb'}
|
17
|
+
expect { ifile.load!(args, expand_by: 1) }.to raise_error("File #{File.expand_path('foo.rb')} does not exist!")
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
data/spec/args/paint_spec.rb
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'squib/args/paint'
|
3
|
-
|
4
|
-
describe Squib::Args::Draw do
|
5
|
-
let(:custom_colors) { {'foo' => 'abc'} }
|
6
|
-
subject(:paint) {Squib::Args::Paint.new(custom_colors)}
|
7
|
-
|
8
|
-
context 'alpha' do
|
9
|
-
|
10
|
-
it 'can be a float' do
|
11
|
-
args = {alpha: 0.6}
|
12
|
-
paint.load!(args)
|
13
|
-
expect(paint.alpha).to eq [0.6]
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'raises exception when not a float' do
|
17
|
-
args = {alpha: /6/}
|
18
|
-
expect { paint.load!(args) }.to raise_error('alpha must respond to to_f')
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'squib/args/paint'
|
3
|
+
|
4
|
+
describe Squib::Args::Draw do
|
5
|
+
let(:custom_colors) { {'foo' => 'abc'} }
|
6
|
+
subject(:paint) {Squib::Args::Paint.new(custom_colors)}
|
7
|
+
|
8
|
+
context 'alpha' do
|
9
|
+
|
10
|
+
it 'can be a float' do
|
11
|
+
args = {alpha: 0.6}
|
12
|
+
paint.load!(args)
|
13
|
+
expect(paint.alpha).to eq [0.6]
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'raises exception when not a float' do
|
17
|
+
args = {alpha: /6/}
|
18
|
+
expect { paint.load!(args) }.to raise_error('alpha must respond to to_f')
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
22
|
end
|
data/spec/args/paragraph_spec.rb
CHANGED
@@ -1,153 +1,153 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'squib/args/paragraph'
|
3
|
-
require 'squib/constants'
|
4
|
-
|
5
|
-
describe Squib::Args::Paragraph do
|
6
|
-
subject(:para) { Squib::Args::Paragraph.new('FooFont 32') }
|
7
|
-
|
8
|
-
context 'str validator' do
|
9
|
-
it 'converts everything to string' do
|
10
|
-
para.load!( {str: 5} )
|
11
|
-
expect(para.str).to eq ['5']
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
context 'font validator' do
|
16
|
-
it 'uses deck font by default' do
|
17
|
-
para.load!( {} )
|
18
|
-
expect(para.font).to eq ['FooFont 32']
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'uses system default font when deck font is :default' do
|
22
|
-
para = Squib::Args::Paragraph.new(:default)
|
23
|
-
para.load!( {} )
|
24
|
-
expect(para.font).to eq [Squib::
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'uses specified font when given' do
|
28
|
-
para.load!( {font: 'MyFont 8'})
|
29
|
-
expect(para.font).to eq ['MyFont 8']
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'align validator' do
|
34
|
-
it 'converts to pango left' do
|
35
|
-
para.load!( { align: :left } )
|
36
|
-
expect(para.align).to eq [Pango::ALIGN_LEFT]
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'converts to pango right' do
|
40
|
-
para.load!( { align: :RIGHT } )
|
41
|
-
expect(para.align).to eq [Pango::ALIGN_RIGHT]
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'converts to pango center' do
|
45
|
-
para.load!( { align: 'center' } )
|
46
|
-
expect(para.align).to eq [Pango::ALIGN_CENTER]
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'raises an exception on anything else' do
|
50
|
-
expect { para.load!( { align: 'foo' } ) }.to raise_error(ArgumentError, 'align must be one of: center, left, right')
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
context 'wrap validator' do
|
55
|
-
it 'converts to pango wrap word' do
|
56
|
-
para.load!( { wrap: 'word'} )
|
57
|
-
expect(para.wrap).to eq [Pango::WRAP_WORD]
|
58
|
-
end
|
59
|
-
|
60
|
-
it 'converts to pango wrap char' do
|
61
|
-
para.load!( { wrap: 'WORD_ChAr'} )
|
62
|
-
expect(para.wrap).to eq [Pango::WRAP_WORD_CHAR]
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'converts to pango wrap char on true' do
|
66
|
-
para.load!( { wrap: true} )
|
67
|
-
expect(para.wrap).to eq [Pango::WRAP_WORD_CHAR]
|
68
|
-
end
|
69
|
-
|
70
|
-
it 'converts to pango wrap char with false' do
|
71
|
-
para.load!( { wrap: false} )
|
72
|
-
expect(para.wrap).to eq [Pango::WRAP_CHAR]
|
73
|
-
end
|
74
|
-
|
75
|
-
it 'raises an exception on anything else' do
|
76
|
-
expect { para.load!( {wrap: 'foo' }) }.to raise_error(ArgumentError, 'wrap must be one of: word, char, word_char, true, or false')
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
context 'ellipsize validator' do
|
81
|
-
it 'converts to pango on none and false' do
|
82
|
-
para.load!( { ellipsize: 'none'} )
|
83
|
-
expect(para.ellipsize).to eq [Pango::Layout::ELLIPSIZE_NONE]
|
84
|
-
end
|
85
|
-
|
86
|
-
it 'converts to pango with start' do
|
87
|
-
para.load!( { ellipsize: :StArt} )
|
88
|
-
expect(para.ellipsize).to eq [Pango::Layout::ELLIPSIZE_START]
|
89
|
-
end
|
90
|
-
|
91
|
-
it 'converts to pango middle' do
|
92
|
-
para.load!( { ellipsize: 'middle'} )
|
93
|
-
expect(para.ellipsize).to eq [Pango::Layout::ELLIPSIZE_MIDDLE]
|
94
|
-
end
|
95
|
-
|
96
|
-
it 'converts to pango end' do
|
97
|
-
para.load!( { ellipsize: 'END'} )
|
98
|
-
expect(para.ellipsize).to eq [Pango::Layout::ELLIPSIZE_END]
|
99
|
-
end
|
100
|
-
|
101
|
-
it 'raises an exception on anything else' do
|
102
|
-
expect { para.load!( {ellipsize: 'foo' }) }.to raise_error(ArgumentError, 'ellipsize must be one of: none, start, middle, end, true, or false')
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
context 'justify validator' do
|
107
|
-
it 'allows nil' do
|
108
|
-
para.load!( { justify: nil} )
|
109
|
-
expect(para.justify).to eq [nil]
|
110
|
-
end
|
111
|
-
|
112
|
-
it 'can be true' do
|
113
|
-
para.load!( { justify: true} )
|
114
|
-
expect(para.justify).to eq [true]
|
115
|
-
end
|
116
|
-
|
117
|
-
it 'can be false' do
|
118
|
-
para.load!( { justify: false} )
|
119
|
-
expect(para.justify).to eq [false]
|
120
|
-
end
|
121
|
-
|
122
|
-
it 'raises an exception on anything else' do
|
123
|
-
expect { para.load!( {justify: 'false' }) }.to raise_error(ArgumentError, 'justify must be one of: nil, true, or false')
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
context 'spacing validator' do
|
128
|
-
it 'allows nil' do
|
129
|
-
para.load!( { spacing: nil} )
|
130
|
-
expect(para.spacing).to eq [nil]
|
131
|
-
end
|
132
|
-
it 'is converted to Pango space' do
|
133
|
-
para.load!( { spacing: 519} )
|
134
|
-
expect(para.spacing).to eq [Pango::SCALE * 519.0]
|
135
|
-
end
|
136
|
-
|
137
|
-
it 'raises an exception if not a float' do
|
138
|
-
expect { para.load!( {spacing: /foo/ }) }.to raise_error(ArgumentError, 'spacing must be a number or nil')
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
context 'valign validator' do
|
143
|
-
it 'converts top' do
|
144
|
-
para.load!( { valign: :top} )
|
145
|
-
expect(para.valign).to eq ['top']
|
146
|
-
end
|
147
|
-
|
148
|
-
it 'raises an exception if not one of the three' do
|
149
|
-
expect { para.load!( {valign: 'foo' }) }.to raise_error(ArgumentError, 'valign must be one of: top, middle, bottom')
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'squib/args/paragraph'
|
3
|
+
require 'squib/constants'
|
4
|
+
|
5
|
+
describe Squib::Args::Paragraph do
|
6
|
+
subject(:para) { Squib::Args::Paragraph.new('FooFont 32') }
|
7
|
+
|
8
|
+
context 'str validator' do
|
9
|
+
it 'converts everything to string' do
|
10
|
+
para.load!( {str: 5} )
|
11
|
+
expect(para.str).to eq ['5']
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'font validator' do
|
16
|
+
it 'uses deck font by default' do
|
17
|
+
para.load!( {} )
|
18
|
+
expect(para.font).to eq ['FooFont 32']
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'uses system default font when deck font is :default' do
|
22
|
+
para = Squib::Args::Paragraph.new(:default)
|
23
|
+
para.load!( {} )
|
24
|
+
expect(para.font).to eq [Squib::DEFAULT_FONT]
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'uses specified font when given' do
|
28
|
+
para.load!( {font: 'MyFont 8'})
|
29
|
+
expect(para.font).to eq ['MyFont 8']
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'align validator' do
|
34
|
+
it 'converts to pango left' do
|
35
|
+
para.load!( { align: :left } )
|
36
|
+
expect(para.align).to eq [Pango::ALIGN_LEFT]
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'converts to pango right' do
|
40
|
+
para.load!( { align: :RIGHT } )
|
41
|
+
expect(para.align).to eq [Pango::ALIGN_RIGHT]
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'converts to pango center' do
|
45
|
+
para.load!( { align: 'center' } )
|
46
|
+
expect(para.align).to eq [Pango::ALIGN_CENTER]
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'raises an exception on anything else' do
|
50
|
+
expect { para.load!( { align: 'foo' } ) }.to raise_error(ArgumentError, 'align must be one of: center, left, right')
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'wrap validator' do
|
55
|
+
it 'converts to pango wrap word' do
|
56
|
+
para.load!( { wrap: 'word'} )
|
57
|
+
expect(para.wrap).to eq [Pango::WRAP_WORD]
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'converts to pango wrap char' do
|
61
|
+
para.load!( { wrap: 'WORD_ChAr'} )
|
62
|
+
expect(para.wrap).to eq [Pango::WRAP_WORD_CHAR]
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'converts to pango wrap char on true' do
|
66
|
+
para.load!( { wrap: true} )
|
67
|
+
expect(para.wrap).to eq [Pango::WRAP_WORD_CHAR]
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'converts to pango wrap char with false' do
|
71
|
+
para.load!( { wrap: false} )
|
72
|
+
expect(para.wrap).to eq [Pango::WRAP_CHAR]
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'raises an exception on anything else' do
|
76
|
+
expect { para.load!( {wrap: 'foo' }) }.to raise_error(ArgumentError, 'wrap must be one of: word, char, word_char, true, or false')
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context 'ellipsize validator' do
|
81
|
+
it 'converts to pango on none and false' do
|
82
|
+
para.load!( { ellipsize: 'none'} )
|
83
|
+
expect(para.ellipsize).to eq [Pango::Layout::ELLIPSIZE_NONE]
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'converts to pango with start' do
|
87
|
+
para.load!( { ellipsize: :StArt} )
|
88
|
+
expect(para.ellipsize).to eq [Pango::Layout::ELLIPSIZE_START]
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'converts to pango middle' do
|
92
|
+
para.load!( { ellipsize: 'middle'} )
|
93
|
+
expect(para.ellipsize).to eq [Pango::Layout::ELLIPSIZE_MIDDLE]
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'converts to pango end' do
|
97
|
+
para.load!( { ellipsize: 'END'} )
|
98
|
+
expect(para.ellipsize).to eq [Pango::Layout::ELLIPSIZE_END]
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'raises an exception on anything else' do
|
102
|
+
expect { para.load!( {ellipsize: 'foo' }) }.to raise_error(ArgumentError, 'ellipsize must be one of: none, start, middle, end, true, or false')
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
context 'justify validator' do
|
107
|
+
it 'allows nil' do
|
108
|
+
para.load!( { justify: nil} )
|
109
|
+
expect(para.justify).to eq [nil]
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'can be true' do
|
113
|
+
para.load!( { justify: true} )
|
114
|
+
expect(para.justify).to eq [true]
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'can be false' do
|
118
|
+
para.load!( { justify: false} )
|
119
|
+
expect(para.justify).to eq [false]
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'raises an exception on anything else' do
|
123
|
+
expect { para.load!( {justify: 'false' }) }.to raise_error(ArgumentError, 'justify must be one of: nil, true, or false')
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
context 'spacing validator' do
|
128
|
+
it 'allows nil' do
|
129
|
+
para.load!( { spacing: nil} )
|
130
|
+
expect(para.spacing).to eq [nil]
|
131
|
+
end
|
132
|
+
it 'is converted to Pango space' do
|
133
|
+
para.load!( { spacing: 519} )
|
134
|
+
expect(para.spacing).to eq [Pango::SCALE * 519.0]
|
135
|
+
end
|
136
|
+
|
137
|
+
it 'raises an exception if not a float' do
|
138
|
+
expect { para.load!( {spacing: /foo/ }) }.to raise_error(ArgumentError, 'spacing must be a number or nil')
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
context 'valign validator' do
|
143
|
+
it 'converts top' do
|
144
|
+
para.load!( { valign: :top} )
|
145
|
+
expect(para.valign).to eq ['top']
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'raises an exception if not one of the three' do
|
149
|
+
expect { para.load!( {valign: 'foo' }) }.to raise_error(ArgumentError, 'valign must be one of: top, middle, bottom')
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
153
|
end
|
data/spec/args/range_spec.rb
CHANGED
@@ -1,41 +1,41 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'squib/args/card_range'
|
3
|
-
|
4
|
-
describe Squib::Args::CardRange do
|
5
|
-
|
6
|
-
it 'must be within the card size range' do
|
7
|
-
expect {Squib::Args::CardRange.new(2..3, deck_size: 2)}
|
8
|
-
.to raise_error(ArgumentError, '2..3 is outside of deck range of 0..1')
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'defaults to range of all cards if :all' do
|
12
|
-
range = Squib::Args::CardRange.new(:all, deck_size: 5)
|
13
|
-
expect(range.to_a).to eq([0, 1, 2, 3, 4])
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'creates a range of cards for singleton' do
|
17
|
-
range = Squib::Args::CardRange.new(3, deck_size: 5)
|
18
|
-
expect(range.to_a).to eq([3])
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'lets arrays pass through unchanged' do
|
22
|
-
range = Squib::Args::CardRange.new([0, 2], deck_size: 5)
|
23
|
-
expect(range.to_a).to eq([0, 2])
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'raises an error on everything else' do
|
27
|
-
expect { Squib::Args::CardRange.new(:foo, deck_size: 5) }
|
28
|
-
.to raise_error(ArgumentError, 'foo must be Enumerable (i.e. respond_to :each).')
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'allows anything with :to_i' do
|
32
|
-
range = Squib::Args::CardRange.new(0.9, deck_size: 5)
|
33
|
-
expect(range.to_a).to eq([0])
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'allows [] as an empty range' do
|
37
|
-
range = Squib::Args::CardRange.new([], deck_size: 5)
|
38
|
-
expect(range.to_a).to eq([])
|
39
|
-
end
|
40
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'squib/args/card_range'
|
3
|
+
|
4
|
+
describe Squib::Args::CardRange do
|
5
|
+
|
6
|
+
it 'must be within the card size range' do
|
7
|
+
expect {Squib::Args::CardRange.new(2..3, deck_size: 2)}
|
8
|
+
.to raise_error(ArgumentError, '2..3 is outside of deck range of 0..1')
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'defaults to range of all cards if :all' do
|
12
|
+
range = Squib::Args::CardRange.new(:all, deck_size: 5)
|
13
|
+
expect(range.to_a).to eq([0, 1, 2, 3, 4])
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'creates a range of cards for singleton' do
|
17
|
+
range = Squib::Args::CardRange.new(3, deck_size: 5)
|
18
|
+
expect(range.to_a).to eq([3])
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'lets arrays pass through unchanged' do
|
22
|
+
range = Squib::Args::CardRange.new([0, 2], deck_size: 5)
|
23
|
+
expect(range.to_a).to eq([0, 2])
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'raises an error on everything else' do
|
27
|
+
expect { Squib::Args::CardRange.new(:foo, deck_size: 5) }
|
28
|
+
.to raise_error(ArgumentError, 'foo must be Enumerable (i.e. respond_to :each).')
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'allows anything with :to_i' do
|
32
|
+
range = Squib::Args::CardRange.new(0.9, deck_size: 5)
|
33
|
+
expect(range.to_a).to eq([0])
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'allows [] as an empty range' do
|
37
|
+
range = Squib::Args::CardRange.new([], deck_size: 5)
|
38
|
+
expect(range.to_a).to eq([])
|
39
|
+
end
|
40
|
+
|
41
41
|
end
|