squib 0.12.0 → 0.13.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/.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
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
|
-
|
|
3
|
-
require 'spec_helper'
|
|
4
|
-
require 'squib/import/data_frame'
|
|
5
|
-
|
|
6
|
-
describe Squib::DataFrame do
|
|
7
|
-
let(:basic) do
|
|
8
|
-
{
|
|
9
|
-
'Name' => ['Mage', 'Rogue', 'Warrior'],
|
|
10
|
-
'Cost' => [1, 2, 3],
|
|
11
|
-
}
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
let(:uneven) do
|
|
15
|
-
{
|
|
16
|
-
'Name' => ['Mage', 'Rogue', 'Warrior'],
|
|
17
|
-
'Cost' => [1, 2],
|
|
18
|
-
}
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
let(:whitespace) do
|
|
22
|
-
{
|
|
23
|
-
'Name \n\r\t' => [' Mage \t\r\n'],
|
|
24
|
-
}
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
let(:defined) do
|
|
28
|
-
{
|
|
29
|
-
'nrows' => [1,2,3],
|
|
30
|
-
}
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
context 'is Enumerable and like a hash, so it' do
|
|
34
|
-
it 'responds to each' do
|
|
35
|
-
expect(subject).to respond_to(:each)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
it 'responds to any?' do
|
|
39
|
-
expect(subject.any?).to be false
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it 'responds to []' do
|
|
43
|
-
data = Squib::DataFrame.new basic
|
|
44
|
-
expect(data['Cost']).to eq([1, 2, 3])
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
it 'responds to []=' do
|
|
48
|
-
data = Squib::DataFrame.new basic
|
|
49
|
-
data[:a] = 2
|
|
50
|
-
expect(data[:a]).to eq(2)
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
context :columns do
|
|
55
|
-
it 'provides a list of columns' do
|
|
56
|
-
data = Squib::DataFrame.new basic
|
|
57
|
-
expect(data.columns).to eq %w(Name Cost)
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
context :ncolumns do
|
|
62
|
-
it 'provides column count' do
|
|
63
|
-
data = Squib::DataFrame.new basic
|
|
64
|
-
expect(data.ncolumns).to eq 2
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
context :row do
|
|
69
|
-
it 'returns a hash of each row' do
|
|
70
|
-
data = Squib::DataFrame.new basic
|
|
71
|
-
expect(data.row(0)).to eq ({'Name' => 'Mage', 'Cost' => 1})
|
|
72
|
-
expect(data.row(1)).to eq ({'Name' => 'Rogue', 'Cost' => 2})
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
it 'returns nil for uneven data' do
|
|
76
|
-
data = Squib::DataFrame.new uneven
|
|
77
|
-
expect(data.row(2)).to eq ({'Name' => 'Warrior', 'Cost' => nil})
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
context :nrows do
|
|
82
|
-
it 'returns a row count on even data' do
|
|
83
|
-
data = Squib::DataFrame.new basic
|
|
84
|
-
expect(data.nrows).to eq 3
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
it 'returns largest row count on uneven data' do
|
|
88
|
-
data = Squib::DataFrame.new basic
|
|
89
|
-
expect(data.nrows).to eq 3
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
context :json do
|
|
94
|
-
it 'returns quoty json' do
|
|
95
|
-
data = Squib::DataFrame.new basic
|
|
96
|
-
expect(data.to_json).to eq "{\"Name\":[\"Mage\",\"Rogue\",\"Warrior\"],\"Cost\":[1,2,3]}"
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
it 'returns pretty json' do
|
|
100
|
-
data = Squib::DataFrame.new basic
|
|
101
|
-
str = <<-EOS
|
|
102
|
-
{
|
|
103
|
-
"Name": [
|
|
104
|
-
"Mage",
|
|
105
|
-
"Rogue",
|
|
106
|
-
"Warrior"
|
|
107
|
-
],
|
|
108
|
-
"Cost": [
|
|
109
|
-
1,
|
|
110
|
-
2,
|
|
111
|
-
3
|
|
112
|
-
]
|
|
113
|
-
}
|
|
114
|
-
EOS
|
|
115
|
-
expect(data.to_pretty_json).to eq str.chomp
|
|
116
|
-
end
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
context :def_column do
|
|
120
|
-
it 'creates name for Name column' do
|
|
121
|
-
data = Squib::DataFrame.new basic
|
|
122
|
-
expect(data).to respond_to(:name)
|
|
123
|
-
expect(data.name).to eq %w(Mage Rogue Warrior)
|
|
124
|
-
expect(data.cost).to eq [1, 2, 3]
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
it 'does not redefine methods' do
|
|
128
|
-
data = Squib::DataFrame.new defined
|
|
129
|
-
expect(data).to respond_to(:nrows)
|
|
130
|
-
expect(data.nrows).to eq 3
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
it 'defines a new column from empty data frame' do
|
|
134
|
-
data = Squib::DataFrame.new
|
|
135
|
-
expect(data).not_to respond_to(:snark)
|
|
136
|
-
data['snark'] = [1,2,3]
|
|
137
|
-
expect(data.snark).to eq [1,2,3]
|
|
138
|
-
end
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
context :snake_case do
|
|
142
|
-
subject { Squib::DataFrame.new }
|
|
143
|
-
it 'strips leading & trailing whitespace' do
|
|
144
|
-
expect(subject.send(:snake_case, ' A ')).to eq :a
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
it 'converts space to _' do
|
|
148
|
-
expect(subject.send(:snake_case, 'A b')).to eq :a_b
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
it 'handles multiwhitespace' do
|
|
152
|
-
expect(subject.send(:snake_case, 'A b')).to eq :a_b
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
it 'handles camelcase' do
|
|
156
|
-
expect(subject.send(:snake_case, 'fooBar')).to eq :foo_bar
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
it 'handles camelcase with multiple capitals' do
|
|
160
|
-
expect(subject.send(:snake_case, 'FOOBar')).to eq :foo_bar
|
|
161
|
-
end
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
context :col? do
|
|
165
|
-
it 'returns true if a column exists' do
|
|
166
|
-
data = Squib::DataFrame.new basic
|
|
167
|
-
expect(data.col? 'Name').to be true
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
it 'returns false if a column does not exist' do
|
|
171
|
-
data = Squib::DataFrame.new basic
|
|
172
|
-
expect(data.col? 'ROUS').to be false
|
|
173
|
-
end
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
context :wrap_n_pad do
|
|
177
|
-
subject { Squib::DataFrame.new basic }
|
|
178
|
-
|
|
179
|
-
it 'returns a handles a single line' do
|
|
180
|
-
expect(subject.send(:wrap_n_pad, 'a', 3)).
|
|
181
|
-
to eq "| a |\n"
|
|
182
|
-
end
|
|
183
|
-
|
|
184
|
-
it 'wraps multiple a lines at 34 characters' do
|
|
185
|
-
expect(subject.send(:wrap_n_pad, 'a' * 40, 3)).
|
|
186
|
-
to eq <<-EOS
|
|
187
|
-
| aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
|
|
188
|
-
| aaaaaa |
|
|
189
|
-
EOS
|
|
190
|
-
end
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
context :to_pretty_text do
|
|
194
|
-
|
|
195
|
-
let(:verbose) do
|
|
196
|
-
{
|
|
197
|
-
'Name' => ['Mage', 'Rogue', 'Warrior'],
|
|
198
|
-
'Cost' => [1, 2, 3],
|
|
199
|
-
'Description' => [
|
|
200
|
-
'Magic, dude.',
|
|
201
|
-
'I like to be sneaky',
|
|
202
|
-
'I have a long story to tell to test the word-wrapping ability of pretty text formatting.'
|
|
203
|
-
],
|
|
204
|
-
'Snark' => [nil, '', ' ']
|
|
205
|
-
}
|
|
206
|
-
end
|
|
207
|
-
|
|
208
|
-
it 'returns fun ascii art of the card' do
|
|
209
|
-
data = Squib::DataFrame.new verbose
|
|
210
|
-
expect(data.to_pretty_text).to eq <<-EOS
|
|
211
|
-
╭------------------------------------╮
|
|
212
|
-
Name | Mage |
|
|
213
|
-
Cost | 1 |
|
|
214
|
-
Description | Magic, dude. |
|
|
215
|
-
Snark | |
|
|
216
|
-
╰------------------------------------╯
|
|
217
|
-
╭------------------------------------╮
|
|
218
|
-
Name | Rogue |
|
|
219
|
-
Cost | 2 |
|
|
220
|
-
Description | I like to be sneaky |
|
|
221
|
-
Snark | |
|
|
222
|
-
╰------------------------------------╯
|
|
223
|
-
╭------------------------------------╮
|
|
224
|
-
Name | Warrior |
|
|
225
|
-
Cost | 3 |
|
|
226
|
-
Description | I have a long story to tell to tes |
|
|
227
|
-
| t the word-wrapping ability of pre |
|
|
228
|
-
| tty text formatting. |
|
|
229
|
-
Snark | |
|
|
230
|
-
╰------------------------------------╯
|
|
231
|
-
EOS
|
|
232
|
-
end
|
|
233
|
-
|
|
234
|
-
let(:utf8_fun) do
|
|
235
|
-
{
|
|
236
|
-
'Fun with UTF8!' => ['👊'],
|
|
237
|
-
}
|
|
238
|
-
end
|
|
239
|
-
|
|
240
|
-
it 'is admittedly janky with multibyte chars' do
|
|
241
|
-
# I hate how Ruby handles multibyte chars. Blech!
|
|
242
|
-
data = Squib::DataFrame.new utf8_fun
|
|
243
|
-
expect(data.to_pretty_text).to eq <<-EOS
|
|
244
|
-
╭------------------------------------╮
|
|
245
|
-
Fun with UTF8! | 👊 |
|
|
246
|
-
╰------------------------------------╯
|
|
247
|
-
EOS
|
|
248
|
-
end
|
|
249
|
-
end
|
|
250
|
-
|
|
251
|
-
end
|
data/spec/layout_parser_spec.rb
DELETED
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Squib::LayoutParser do
|
|
4
|
-
|
|
5
|
-
it 'loads a normal layout with no extends' do
|
|
6
|
-
layout = subject.load_layout(layout_file('no-extends.yml'))
|
|
7
|
-
expect(layout).to eq({ 'frame' => {
|
|
8
|
-
'x' => 38,
|
|
9
|
-
'valign' => :middle,
|
|
10
|
-
'str' => 'blah',
|
|
11
|
-
'font' => 'Mr. Font',
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it 'loads with a single extends' do
|
|
18
|
-
layout = subject.load_layout(layout_file('single-extends.yml'))
|
|
19
|
-
expect(layout).to eq({ 'frame' => {
|
|
20
|
-
'x' => 38,
|
|
21
|
-
'y' => 38,
|
|
22
|
-
},
|
|
23
|
-
'title' => {
|
|
24
|
-
'extends' => 'frame',
|
|
25
|
-
'x' => 38,
|
|
26
|
-
'y' => 50,
|
|
27
|
-
'width' => 100,
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
it 'applies the extends regardless of order' do
|
|
34
|
-
layout = subject.load_layout(layout_file('pre-extends.yml'))
|
|
35
|
-
expect(layout).to eq({ 'frame' => {
|
|
36
|
-
'x' => 38,
|
|
37
|
-
'y' => 38,
|
|
38
|
-
},
|
|
39
|
-
'title' => {
|
|
40
|
-
'extends' => 'frame',
|
|
41
|
-
'x' => 38,
|
|
42
|
-
'y' => 50,
|
|
43
|
-
'width' => 100,
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
it 'applies the single-level extends multiple times' do
|
|
50
|
-
layout = subject.load_layout(layout_file('single-level-multi-extends.yml'))
|
|
51
|
-
expect(layout).to eq({ 'frame' => {
|
|
52
|
-
'x' => 38,
|
|
53
|
-
'y' => 38,
|
|
54
|
-
},
|
|
55
|
-
'title' => {
|
|
56
|
-
'extends' => 'frame',
|
|
57
|
-
'x' => 38,
|
|
58
|
-
'y' => 50,
|
|
59
|
-
'width' => 100,
|
|
60
|
-
},
|
|
61
|
-
'title2' => {
|
|
62
|
-
'extends' => 'frame',
|
|
63
|
-
'x' => 75,
|
|
64
|
-
'y' => 150,
|
|
65
|
-
'width' => 150,
|
|
66
|
-
},
|
|
67
|
-
}
|
|
68
|
-
)
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
it 'applies multiple extends in a single rule' do
|
|
72
|
-
layout = subject.load_layout(layout_file('multi-extends-single-entry.yml'))
|
|
73
|
-
expect(layout).to eq({ 'aunt' => {
|
|
74
|
-
'a' => 101,
|
|
75
|
-
'b' => 102,
|
|
76
|
-
'c' => 103,
|
|
77
|
-
},
|
|
78
|
-
'uncle' => {
|
|
79
|
-
'x' => 104,
|
|
80
|
-
'y' => 105,
|
|
81
|
-
'b' => 106,
|
|
82
|
-
},
|
|
83
|
-
'child' => {
|
|
84
|
-
'extends' => ['uncle', 'aunt'],
|
|
85
|
-
'a' => 107, # my own
|
|
86
|
-
'b' => 102, # from the younger aunt
|
|
87
|
-
'c' => 103, # from aunt
|
|
88
|
-
'x' => 108, # my own
|
|
89
|
-
'y' => 105, # from uncle
|
|
90
|
-
},
|
|
91
|
-
}
|
|
92
|
-
)
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
it 'applies multi-level extends' do
|
|
96
|
-
layout = subject.load_layout(layout_file('multi-level-extends.yml'))
|
|
97
|
-
expect(layout).to eq({ 'frame' => {
|
|
98
|
-
'x' => 38,
|
|
99
|
-
'y' => 38,
|
|
100
|
-
},
|
|
101
|
-
'title' => {
|
|
102
|
-
'extends' => 'frame',
|
|
103
|
-
'x' => 38,
|
|
104
|
-
'y' => 50,
|
|
105
|
-
'width' => 100,
|
|
106
|
-
},
|
|
107
|
-
'subtitle' => {
|
|
108
|
-
'extends' => 'title',
|
|
109
|
-
'x' => 38,
|
|
110
|
-
'y' => 150,
|
|
111
|
-
'width' => 100,
|
|
112
|
-
},
|
|
113
|
-
}
|
|
114
|
-
)
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
it 'fails on a self-circular extends' do
|
|
118
|
-
file = layout_file('self-circular-extends.yml')
|
|
119
|
-
expect { subject.load_layout(file)}
|
|
120
|
-
.to raise_error(RuntimeError, 'Invalid layout: circular extends with \'a\'')
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
it 'fails on a easy-circular extends' do
|
|
124
|
-
file = layout_file('easy-circular-extends.yml')
|
|
125
|
-
expect { subject.load_layout(file)}
|
|
126
|
-
.to raise_error(RuntimeError, 'Invalid layout: circular extends with \'a\'')
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
it 'hard on a easy-circular extends' do
|
|
130
|
-
file = layout_file('hard-circular-extends.yml')
|
|
131
|
-
expect { subject.load_layout(file)}
|
|
132
|
-
.to raise_error(RuntimeError, 'Invalid layout: circular extends with \'a\'')
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
it 'redefines keys on multiple layouts' do
|
|
136
|
-
a = layout_file('multifile-a.yml')
|
|
137
|
-
b = layout_file('multifile-b.yml')
|
|
138
|
-
layout = subject.load_layout([a, b])
|
|
139
|
-
expect(layout).to eq({
|
|
140
|
-
'title' => { 'x' => 300 },
|
|
141
|
-
'subtitle' => { 'x' => 200 },
|
|
142
|
-
'desc' => { 'x' => 400 }
|
|
143
|
-
})
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
it 'evaluates extends on each file first' do
|
|
147
|
-
a = layout_file('multifile-extends-a.yml')
|
|
148
|
-
b = layout_file('multifile-extends-b.yml')
|
|
149
|
-
layout = subject.load_layout([a, b])
|
|
150
|
-
expect(layout).to eq({
|
|
151
|
-
'grandparent' => { 'x' => 100 },
|
|
152
|
-
'parent_a' => { 'x' => 110, 'extends' => 'grandparent' },
|
|
153
|
-
'parent_b' => { 'x' => 130, 'extends' => 'grandparent' },
|
|
154
|
-
'child_a' => { 'x' => 113, 'extends' => 'parent_a' },
|
|
155
|
-
'child_b' => { 'x' => 133, 'extends' => 'parent_b' }
|
|
156
|
-
})
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
it 'loads nothing on an empty layout file' do
|
|
160
|
-
layout = subject.load_layout(layout_file('empty.yml'))
|
|
161
|
-
expect(layout).to eq({})
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
it 'handles extends on a rule with no args' do
|
|
165
|
-
layout = subject.load_layout(layout_file('empty-rule.yml'))
|
|
166
|
-
expect(layout).to eq({
|
|
167
|
-
'empty' => nil
|
|
168
|
-
})
|
|
169
|
-
end
|
|
170
|
-
|
|
171
|
-
it 'logs an error when a file is not found' do
|
|
172
|
-
expect(Squib.logger).to receive(:error).once
|
|
173
|
-
subject.load_layout('yeti')
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
it 'freaks out if you extend something doesn\'t exist' do
|
|
177
|
-
expect(Squib.logger)
|
|
178
|
-
.to receive(:error)
|
|
179
|
-
.with("Processing layout: 'verbal' attempts to extend a missing 'kaisersoze'")
|
|
180
|
-
layout = subject.load_layout(layout_file('extends-nonexists.yml'))
|
|
181
|
-
expect(layout).to eq({
|
|
182
|
-
'verbal' => {
|
|
183
|
-
'font_size' => 25,
|
|
184
|
-
'extends' => 'kaisersoze'
|
|
185
|
-
}
|
|
186
|
-
})
|
|
187
|
-
end
|
|
188
|
-
|
|
189
|
-
it 'does unit conversion when extending' do
|
|
190
|
-
layout = subject.load_layout(layout_file('extends-units.yml'))
|
|
191
|
-
expect(layout).to eq({
|
|
192
|
-
'parent' => { 'x' => '0.5in', 'y' => '1in'},
|
|
193
|
-
'child' => { 'x' => 450.0, 'y' => 150.0, 'extends' => 'parent' },
|
|
194
|
-
})
|
|
195
|
-
end
|
|
196
|
-
|
|
197
|
-
it 'does unit conversion on non-300 dpis' do
|
|
198
|
-
parser = Squib::LayoutParser.new(100)
|
|
199
|
-
layout = parser.load_layout(layout_file('extends-units.yml'))
|
|
200
|
-
expect(layout).to eq({
|
|
201
|
-
'parent' => { 'x' => '0.5in', 'y' => '1in'},
|
|
202
|
-
'child' => { 'x' => 150.0, 'y' => 50.0, 'extends' => 'parent' },
|
|
203
|
-
})
|
|
204
|
-
end
|
|
205
|
-
|
|
206
|
-
it 'does mixed unit conversion when extending' do
|
|
207
|
-
layout = subject.load_layout(layout_file('extends-units-mixed.yml'))
|
|
208
|
-
expect(layout).to eq({
|
|
209
|
-
'parent' => { 'x' => '0.5in', 'y' => '1in'},
|
|
210
|
-
'child' => { 'x' => 450.0, 'y' => 150.0, 'extends' => 'parent' },
|
|
211
|
-
})
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
it 'loads progressively on multiple calls' do
|
|
215
|
-
a = layout_file('multifile-a.yml')
|
|
216
|
-
b = layout_file('multifile-b.yml')
|
|
217
|
-
layout = subject.load_layout(a)
|
|
218
|
-
layout = subject.load_layout(b, layout)
|
|
219
|
-
expect(layout).to eq({
|
|
220
|
-
'title' => { 'x' => 300 },
|
|
221
|
-
'subtitle' => { 'x' => 200 },
|
|
222
|
-
'desc' => { 'x' => 400 }
|
|
223
|
-
})
|
|
224
|
-
end
|
|
225
|
-
|
|
226
|
-
end
|