squib 0.12.0 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -2
- data/CHANGELOG.md +16 -1
- data/appveyor.yml +2 -3
- data/lib/squib/args/sheet.rb +66 -34
- data/lib/squib/graphics/save_pdf.rb +1 -1
- data/lib/squib/import/data_frame.rb +7 -7
- data/lib/squib/version.rb +1 -1
- data/samples/autoscale_font/_autoscale_font.rb +1 -1
- data/samples/build_groups/build_groups.rb +3 -3
- data/samples/colors/_colors.rb +1 -0
- data/samples/{config_text_markup.rb → config/config_text_markup.rb} +0 -0
- data/samples/{custom_config.rb → config/custom_config.rb} +0 -0
- data/samples/{cairo_access.rb → images/_cairo_access.rb} +0 -0
- data/samples/images/_images.rb +1 -1
- data/samples/{unicode.rb → images/_unicode.rb} +0 -0
- data/samples/intro/01_hello.rb +1 -2
- data/samples/intro/02_options.rb +1 -2
- data/samples/intro/03_layout.rb +1 -2
- data/samples/intro/04_arrays.rb +1 -2
- data/samples/intro/05_excel.rb +3 -4
- data/samples/{tgc_proofs.rb → proofs/_tgc_proofs.rb} +1 -4
- data/samples/saves/_save_pdf.rb +7 -0
- data/samples/{embed_text.rb → text/_embed_text.rb} +1 -0
- data/samples/text/_text.rb +1 -1
- data/samples/{text_options.rb → text/_text_options.rb} +1 -1
- data/samples/{bug134.rb → text/bug134.rb} +0 -0
- data/squib.gemspec +17 -16
- metadata +90 -596
- data/benchmarks/antialias_best.rb +0 -13
- data/benchmarks/antialias_best.yml +0 -1
- data/benchmarks/antialias_fast.rb +0 -13
- data/benchmarks/antialias_fast.yml +0 -1
- data/benchmarks/backend-svg.yml +0 -4
- data/benchmarks/backend_memory.rb +0 -14
- data/benchmarks/backend_svg.rb +0 -14
- data/benchmarks/shiny-purse.png +0 -0
- data/benchmarks/spanner.svg +0 -91
- data/benchmarks/tons_of_png.rb +0 -6
- data/benchmarks/tons_of_svg.rb +0 -7
- data/benchmarks/tons_of_text.rb +0 -8
- data/docs/Makefile +0 -216
- data/docs/_static/css/squibdocs.css +0 -23
- data/docs/args/draw.rst +0 -36
- data/docs/args/expansion.rst +0 -3
- data/docs/args/layout.rst +0 -6
- data/docs/args/output_dir.rst +0 -6
- data/docs/args/range.rst +0 -6
- data/docs/args/transform.rst +0 -51
- data/docs/args/trim.rst +0 -11
- data/docs/args/wh.rst +0 -12
- data/docs/args/xy.rst +0 -12
- data/docs/arrays.rst +0 -80
- data/docs/backends.rst +0 -20
- data/docs/bleed.rst +0 -13
- data/docs/build_groups.rst +0 -45
- data/docs/colors.rst +0 -90
- data/docs/conf.py +0 -287
- data/docs/config.rst +0 -135
- data/docs/data.rst +0 -26
- data/docs/dsl/background.rst +0 -20
- data/docs/dsl/build.rst +0 -32
- data/docs/dsl/build_groups.rst +0 -23
- data/docs/dsl/circle.rst +0 -27
- data/docs/dsl/cm.rst +0 -19
- data/docs/dsl/configure.rst +0 -18
- data/docs/dsl/csv.rst +0 -81
- data/docs/dsl/curve.rst +0 -63
- data/docs/dsl/data_frame.rst +0 -85
- data/docs/dsl/deck.rst +0 -45
- data/docs/dsl/disable_build.rst +0 -25
- data/docs/dsl/disable_build_globally.rst +0 -46
- data/docs/dsl/ellipse.rst +0 -23
- data/docs/dsl/enable_build.rst +0 -25
- data/docs/dsl/enable_build_globally.rst +0 -44
- data/docs/dsl/grid.rst +0 -31
- data/docs/dsl/hand.rst +0 -40
- data/docs/dsl/hint.rst +0 -15
- data/docs/dsl/inches.rst +0 -19
- data/docs/dsl/index.rst +0 -9
- data/docs/dsl/line.rst +0 -52
- data/docs/dsl/mm.rst +0 -19
- data/docs/dsl/png.rst +0 -49
- data/docs/dsl/polygon.rst +0 -28
- data/docs/dsl/rect.rst +0 -22
- data/docs/dsl/save.rst +0 -23
- data/docs/dsl/save_pdf.rst +0 -89
- data/docs/dsl/save_png.rst +0 -46
- data/docs/dsl/save_sheet.rst +0 -55
- data/docs/dsl/showcase.rst +0 -76
- data/docs/dsl/star.rst +0 -35
- data/docs/dsl/svg.rst +0 -119
- data/docs/dsl/text.rst +0 -292
- data/docs/dsl/triangle.rst +0 -50
- data/docs/dsl/use_layout.rst +0 -16
- data/docs/dsl/xlsx.rst +0 -56
- data/docs/guides/game_icons.rst +0 -126
- data/docs/guides/getting-started/index.rst +0 -5
- data/docs/guides/getting-started/part_0_learning_ruby.rst +0 -145
- data/docs/guides/getting-started/part_1_zero_to_game.rst +0 -217
- data/docs/guides/getting-started/part_2_iconography.rst +0 -228
- data/docs/guides/getting-started/part_3_workflows.rst +0 -46
- data/docs/guides/getting-started/part_4_ruby_power.rst +0 -18
- data/docs/guides/git.rst +0 -14
- data/docs/guides/guard.rst +0 -84
- data/docs/guides/hello_world.rst +0 -65
- data/docs/guides/projects.rst +0 -35
- data/docs/help.rst +0 -157
- data/docs/index.rst +0 -35
- data/docs/install.rst +0 -68
- data/docs/layouts.rst +0 -290
- data/docs/learning.rst +0 -12
- data/docs/make.bat +0 -263
- data/docs/parameters.rst +0 -34
- data/docs/server.bat +0 -1
- data/docs/text_feature.rst +0 -115
- data/docs/units.rst +0 -14
- data/samples/autoscale_font/.gitignore +0 -2
- data/samples/autoscale_font/card_00_expected.png +0 -0
- data/samples/backend/.gitignore +0 -1
- data/samples/backend/_backend-config.yml +0 -5
- data/samples/backend/backend_00_expected.png +0 -0
- data/samples/backend/backend_01_expected.png +0 -0
- data/samples/backend/backend_vectorized_expected.pdf +0 -0
- data/samples/backend/backend_vectors_00_expected.svg +0 -84
- data/samples/backend/backend_vectors_01_expected.svg +0 -84
- data/samples/backend/shiny-purse.png +0 -0
- data/samples/backend/showcase_expected.png +0 -0
- data/samples/backend/spanner.svg +0 -91
- data/samples/ball.png +0 -0
- data/samples/build_groups/.gitignore +0 -1
- data/samples/build_groups/Rakefile +0 -25
- data/samples/colors/.gitignore +0 -1
- data/samples/colors/color_constants_00_expected.png +0 -0
- data/samples/colors/colors_00_expected.png +0 -0
- data/samples/colors/gradient_00_expected.png +0 -0
- data/samples/config_disable_quotes.yml +0 -3
- data/samples/config_text_markup.yml +0 -9
- data/samples/custom-config.yml +0 -5
- data/samples/customconfig-imgdir/shiny-purse2.png +0 -0
- data/samples/customconfig-imgdir/spanner2.svg +0 -91
- data/samples/data/.gitignore +0 -1
- data/samples/data/explode_quantities.xlsx +0 -0
- data/samples/data/quantity_explosion.csv +0 -3
- data/samples/data/sample.csv +0 -3
- data/samples/data/sample.xlsx +0 -0
- data/samples/data/sample_csv_00_expected.png +0 -0
- data/samples/data/sample_csv_01_expected.png +0 -0
- data/samples/data/sample_csv_qty_00_expected.png +0 -0
- data/samples/data/sample_excel_00_expected.png +0 -0
- data/samples/data/sample_excel_01_expected.png +0 -0
- data/samples/data/sample_excel_02_expected.png +0 -0
- data/samples/data/sample_excel_resources_00_expected.png +0 -0
- data/samples/data/sample_excel_resources_01_expected.png +0 -0
- data/samples/data/sample_xlsx_qty_00_expected.png +0 -0
- data/samples/glass-heart.svg +0 -52
- data/samples/grit.png +0 -0
- data/samples/images/.gitignore +0 -8
- data/samples/images/_images_00_expected.png +0 -0
- data/samples/images/angler-fish.png +0 -0
- data/samples/images/ball.png +0 -0
- data/samples/images/glass-heart.svg +0 -52
- data/samples/images/grit.png +0 -0
- data/samples/images/offset.svg +0 -85
- data/samples/images/robot-golem.svg +0 -1
- data/samples/images/shiny-purse.png +0 -0
- data/samples/images/spanner.svg +0 -91
- data/samples/images/sprites.png +0 -0
- data/samples/images/with-alpha.png +0 -0
- data/samples/intro/.gitignore +0 -2
- data/samples/intro/auto-repair.svg +0 -1
- data/samples/intro/crawling.svg +0 -1
- data/samples/intro/data.xlsx +0 -0
- data/samples/intro/humans.svg +0 -1
- data/samples/intro/ninja-mask.svg +0 -1
- data/samples/intro/part1_00_expected.png +0 -0
- data/samples/intro/part2_00_expected.png +0 -0
- data/samples/intro/part3_00_expected.png +0 -0
- data/samples/intro/part3_layout.yml +0 -34
- data/samples/intro/part4_00_expected.png +0 -0
- data/samples/intro/part4_01_expected.png +0 -0
- data/samples/intro/part5_00_expected.png +0 -0
- data/samples/intro/part5_01_expected.png +0 -0
- data/samples/intro/part5_02_expected.png +0 -0
- data/samples/intro/part5_03_expected.png +0 -0
- data/samples/intro/part5_hand_expected.png +0 -0
- data/samples/intro/part5_showcase_expected.png +0 -0
- data/samples/intro/pirate-skull.svg +0 -1
- data/samples/intro/robot-golem.svg +0 -1
- data/samples/layouts/custom-layout.yml +0 -60
- data/samples/layouts/custom-layout2.yml +0 -15
- data/samples/layouts/expected_layouts_builtin_economy_00.png +0 -0
- data/samples/layouts/expected_layouts_builtin_fantasy_00.png +0 -0
- data/samples/layouts/expected_layouts_builtin_hand_00.png +0 -0
- data/samples/layouts/expected_layouts_builtin_playing_card_00.png +0 -0
- data/samples/layouts/expected_layouts_builtin_tuck_box_00.png +0 -0
- data/samples/layouts/shiny-purse.png +0 -0
- data/samples/layouts/spanner.svg +0 -91
- data/samples/load_images_config.yml +0 -1
- data/samples/offset.svg +0 -71
- data/samples/pokercard.png +0 -0
- data/samples/project/Gemfile +0 -6
- data/samples/project/Guardfile +0 -18
- data/samples/project/Rakefile +0 -25
- data/samples/project/bw/robot-golem.svg +0 -53
- data/samples/project/color/robot-golem.svg +0 -1
- data/samples/project/config.yml +0 -2
- data/samples/project/layouts/characters.yml +0 -3
- data/samples/project/layouts/skills.yml +0 -3
- data/samples/ranges/glass-heart.svg +0 -52
- data/samples/ranges/ranges_00_expected.png +0 -0
- data/samples/saves/.gitignore +0 -1
- data/samples/saves/hand_expected.png +0 -0
- data/samples/saves/hand_pretty_expected.png +0 -0
- data/samples/saves/save-pdf-small_expected.pdf +0 -0
- data/samples/saves/save-pdf_expected.pdf +0 -0
- data/samples/saves/save_png_00_expected.png +0 -0
- data/samples/saves/save_png_trimmed_00_expected.png +0 -0
- data/samples/saves/save_sheet_00_expected.png +0 -0
- data/samples/saves/save_sheet_01_expected.png +0 -0
- data/samples/saves/save_sheet_range_00_expected.png +0 -0
- data/samples/saves/save_sheet_range_01_expected.png +0 -0
- data/samples/saves/save_single_sheet_00_expected.png +0 -0
- data/samples/saves/saves_notrim_01_expected.png +0 -0
- data/samples/saves/showcase2_expected.png +0 -0
- data/samples/saves/showcase_expected.png +0 -0
- data/samples/saves/showcase_individual_00_expected.png +0 -0
- data/samples/saves/showcase_individual_01_expected.png +0 -0
- data/samples/saves/showcase_individual_02_expected.png +0 -0
- data/samples/saves/showcase_individual_03_expected.png +0 -0
- data/samples/saves/spanner.svg +0 -91
- data/samples/shapes/.gitignore +0 -1
- data/samples/shapes/shape_00_expected.png +0 -0
- data/samples/shiny-purse.png +0 -0
- data/samples/spanner.svg +0 -91
- data/samples/sprites.png +0 -0
- data/samples/text/.gitignore +0 -2
- data/samples/text/README.md +0 -1
- data/samples/text/_text_00_expected.png +0 -0
- data/samples/text/config.yml +0 -2
- data/samples/units/units_00_expected.png +0 -0
- data/samples/units/using_units.yml +0 -10
- data/spec/api/api_data_spec.rb +0 -172
- data/spec/api/api_groups_spec.rb +0 -49
- data/spec/api/api_settings_spec.rb +0 -38
- data/spec/api/api_units_spec.rb +0 -37
- data/spec/args/box_spec.rb +0 -127
- data/spec/args/draw_spec.rb +0 -101
- data/spec/args/embed_key_spec.rb +0 -13
- data/spec/args/input_file_spec.rb +0 -21
- data/spec/args/paint_spec.rb +0 -22
- data/spec/args/paragraph_spec.rb +0 -153
- data/spec/args/range_spec.rb +0 -41
- data/spec/args/save_batch_spec.rb +0 -51
- data/spec/args/scale_box_spec.rb +0 -71
- data/spec/args/sheet_spec.rb +0 -80
- data/spec/args/showcase_special_spec.rb +0 -15
- data/spec/args/transform_spec.rb +0 -25
- data/spec/args/typographer_spec.rb +0 -71
- data/spec/args/unit_conversion_spec.rb +0 -29
- data/spec/card_spec.rb +0 -11
- data/spec/commands/new_spec.rb +0 -48
- data/spec/conf_spec.rb +0 -47
- data/spec/data/conf/basic.yml +0 -1
- data/spec/data/conf/empty.yml +0 -1
- data/spec/data/conf/unrecognized.yml +0 -4
- data/spec/data/csv/basic.csv +0 -3
- data/spec/data/csv/custom_opts.csv +0 -2
- data/spec/data/csv/dup_cols.csv +0 -3
- data/spec/data/csv/newline.csv +0 -3
- data/spec/data/csv/qty.csv +0 -3
- data/spec/data/csv/qty_named.csv +0 -3
- data/spec/data/csv/with_spaces.csv +0 -3
- data/spec/data/csv/yield.csv +0 -3
- data/spec/data/layouts/easy-circular-extends.yml +0 -6
- data/spec/data/layouts/empty-rule.yml +0 -1
- data/spec/data/layouts/empty.yml +0 -1
- data/spec/data/layouts/extends-nonexists.yml +0 -3
- data/spec/data/layouts/extends-units-mixed.yml +0 -8
- data/spec/data/layouts/extends-units.yml +0 -8
- data/spec/data/layouts/hard-circular-extends.yml +0 -9
- data/spec/data/layouts/multi-extends-single-entry.yml +0 -14
- data/spec/data/layouts/multi-level-extends.yml +0 -10
- data/spec/data/layouts/multifile-a.yml +0 -4
- data/spec/data/layouts/multifile-b.yml +0 -4
- data/spec/data/layouts/multifile-extends-a.yml +0 -8
- data/spec/data/layouts/multifile-extends-b.yml +0 -9
- data/spec/data/layouts/no-extends.yml +0 -5
- data/spec/data/layouts/pre-extends.yml +0 -7
- data/spec/data/layouts/self-circular-extends.yml +0 -3
- data/spec/data/layouts/single-extends.yml +0 -7
- data/spec/data/layouts/single-level-multi-extends.yml +0 -12
- data/spec/data/samples/autoscale_font/_autoscale_font.rb.txt +0 -133
- data/spec/data/samples/basic.rb.txt +0 -248
- data/spec/data/samples/cairo_access.rb.txt +0 -59
- data/spec/data/samples/colors/_gradients.rb.txt +0 -84
- data/spec/data/samples/config_text_markup.rb.txt +0 -74
- data/spec/data/samples/custom_config.rb.txt +0 -59
- data/spec/data/samples/data/_csv.rb.txt +0 -231
- data/spec/data/samples/data/_excel.rb.txt +0 -704
- data/spec/data/samples/embed_text.rb.txt +0 -431
- data/spec/data/samples/hello_world.rb.txt +0 -38
- data/spec/data/samples/images/_more_load_images.rb.txt +0 -335
- data/spec/data/samples/layouts.rb.txt +0 -489
- data/spec/data/samples/ranges/_ranges.rb.txt +0 -484
- data/spec/data/samples/saves/_hand.rb.txt +0 -594
- data/spec/data/samples/saves/_portrait_landscape.rb.txt +0 -57
- data/spec/data/samples/saves/_save_pdf.rb.txt +0 -1601
- data/spec/data/samples/saves/_saves.rb.txt +0 -873
- data/spec/data/samples/saves/_showcase.rb.txt +0 -5942
- data/spec/data/samples/shapes/_draw_shapes.rb.txt +0 -757
- data/spec/data/samples/text_options.rb.txt +0 -1158
- data/spec/data/samples/tgc_proofs.rb.txt +0 -102
- data/spec/data/samples/units/_units.rb.txt +0 -53
- data/spec/data/xlsx/basic.xlsx +0 -0
- data/spec/data/xlsx/explode_quantities.xlsx +0 -0
- data/spec/data/xlsx/formulas.xlsx +0 -0
- data/spec/data/xlsx/whitespace.xlsx +0 -0
- data/spec/data/xlsx/with_macros.xlsm +0 -0
- data/spec/deck_spec.rb +0 -73
- data/spec/graphics/cairo_context_wrapper_spec.rb +0 -104
- data/spec/graphics/embedding_utils_spec.rb +0 -73
- data/spec/graphics/graphics_save_doc_spec.rb +0 -74
- data/spec/import/data_frame_spec.rb +0 -251
- data/spec/layout_parser_spec.rb +0 -226
- data/spec/logger_spec.rb +0 -12
- data/spec/samples/_diffs/gitkeep.txt +0 -0
- data/spec/samples/diff-with-css.example.html +0 -39
- data/spec/samples/expected/autoscale_00.png +0 -0
- data/spec/samples/expected/autoscale_01.png +0 -0
- data/spec/samples/expected/autoscale_02.png +0 -0
- data/spec/samples/expected/backend_00.png +0 -0
- data/spec/samples/expected/backend_00.svg +0 -78
- data/spec/samples/expected/backend_01.png +0 -0
- data/spec/samples/expected/backend_01.svg +0 -78
- data/spec/samples/expected/basic_00.png +0 -0
- data/spec/samples/expected/basic_01.png +0 -0
- data/spec/samples/expected/basic_02.png +0 -0
- data/spec/samples/expected/cairo_access_00.png +0 -0
- data/spec/samples/expected/cairo_access_01.png +0 -0
- data/spec/samples/expected/card_00.png +0 -0
- data/spec/samples/expected/card_01.png +0 -0
- data/spec/samples/expected/colors_00.png +0 -0
- data/spec/samples/expected/config_disable_text_00.png +0 -0
- data/spec/samples/expected/config_text_00.png +0 -0
- data/spec/samples/expected/custom-config_00.png +0 -0
- data/spec/samples/expected/embed_00.png +0 -0
- data/spec/samples/expected/embed_multisheet_00.png +0 -0
- data/spec/samples/expected/gitkeep.txt +0 -0
- data/spec/samples/expected/gradient_00.png +0 -0
- data/spec/samples/expected/hand.png +0 -0
- data/spec/samples/expected/hand_pretty.png +0 -0
- data/spec/samples/expected/landscape_00.png +0 -0
- data/spec/samples/expected/layout2_00.png +0 -0
- data/spec/samples/expected/layout_00.png +0 -0
- data/spec/samples/expected/layout_builtin_hand_00.png +0 -0
- data/spec/samples/expected/layout_builtin_playing_card_00.png +0 -0
- data/spec/samples/expected/load_images_00.png +0 -0
- data/spec/samples/expected/portrait_00.png +0 -0
- data/spec/samples/expected/ranges_00.png +0 -0
- data/spec/samples/expected/sample_csv_00.png +0 -0
- data/spec/samples/expected/sample_csv_01.png +0 -0
- data/spec/samples/expected/sample_excel_00.png +0 -0
- data/spec/samples/expected/sample_excel_01.png +0 -0
- data/spec/samples/expected/sample_excel_02.png +0 -0
- data/spec/samples/expected/save_sheet_00.png +0 -0
- data/spec/samples/expected/save_sheet_01.png +0 -0
- data/spec/samples/expected/save_sheet_range_00.png +0 -0
- data/spec/samples/expected/save_sheet_range_01.png +0 -0
- data/spec/samples/expected/save_single_sheet_00.png +0 -0
- data/spec/samples/expected/saves_notrim_01.png +0 -0
- data/spec/samples/expected/shape_00.png +0 -0
- data/spec/samples/expected/showcase.png +0 -0
- data/spec/samples/expected/showcase2.png +0 -0
- data/spec/samples/expected/showcase_individual_00.png +0 -0
- data/spec/samples/expected/showcase_individual_01.png +0 -0
- data/spec/samples/expected/showcase_individual_02.png +0 -0
- data/spec/samples/expected/showcase_individual_03.png +0 -0
- data/spec/samples/expected/text_00.png +0 -0
- data/spec/samples/expected/text_01.png +0 -0
- data/spec/samples/expected/text_02.png +0 -0
- data/spec/samples/expected/tgc_sample_00.png +0 -0
- data/spec/samples/expected/units_00.png +0 -0
- data/spec/samples/run_samples_spec.rb +0 -17
- data/spec/samples/samples_regression_spec.rb +0 -71
- data/spec/samples/sanity.html.erb +0 -28
- data/spec/samples/sanity.rb +0 -70
- data/spec/sanity/.gitignore +0 -1
- data/spec/sanity/sanity.html.erb +0 -42
- data/spec/sanity/sanity_test.rb +0 -42
- data/spec/sanity/tests.yml +0 -12
- data/spec/spec_helper.rb +0 -159
data/spec/args/draw_spec.rb
DELETED
@@ -1,101 +0,0 @@
|
|
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
DELETED
@@ -1,21 +0,0 @@
|
|
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
DELETED
@@ -1,22 +0,0 @@
|
|
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
|
-
end
|
data/spec/args/paragraph_spec.rb
DELETED
@@ -1,153 +0,0 @@
|
|
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
|
-
end
|
data/spec/args/range_spec.rb
DELETED
@@ -1,41 +0,0 @@
|
|
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
|
-
end
|
@@ -1,51 +0,0 @@
|
|
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
DELETED
@@ -1,71 +0,0 @@
|
|
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
|