squib 0.11.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/.travis.yml +5 -3
  4. data/CHANGELOG.md +24 -2
  5. data/README.md +2 -4
  6. data/RELEASE TODO.md +1 -0
  7. data/Rakefile +1 -1
  8. data/docs/arrays.rst +5 -2
  9. data/docs/build_groups.rst +15 -17
  10. data/docs/colors.rst +29 -3
  11. data/docs/conf.py +3 -3
  12. data/docs/config.rst +14 -1
  13. data/docs/data.rst +8 -4
  14. data/docs/dsl/configure.rst +18 -0
  15. data/docs/dsl/csv.rst +19 -0
  16. data/docs/dsl/data_frame.rst +85 -0
  17. data/docs/dsl/disable_build.rst +1 -4
  18. data/docs/dsl/disable_build_globally.rst +46 -0
  19. data/docs/dsl/enable_build.rst +1 -1
  20. data/docs/dsl/enable_build_globally.rst +44 -0
  21. data/docs/dsl/save_pdf.rst +44 -3
  22. data/docs/dsl/showcase.rst +11 -0
  23. data/docs/dsl/text.rst +3 -5
  24. data/docs/dsl/xlsx.rst +6 -0
  25. data/docs/guides/game_icons.rst +124 -4
  26. data/docs/guides/getting-started/part_1_zero_to_game.rst +4 -3
  27. data/docs/guides/getting-started/part_2_iconography.rst +92 -16
  28. data/docs/guides/getting-started/part_3_workflows.rst +43 -1
  29. data/docs/guides/getting-started/part_4_ruby_power.rst +18 -0
  30. data/docs/guides/git.rst +2 -1
  31. data/docs/guides/guard.rst +84 -0
  32. data/docs/guides/hello_world.rst +63 -4
  33. data/docs/guides/projects.rst +35 -0
  34. data/docs/install.rst +3 -1
  35. data/docs/layouts.rst +3 -3
  36. data/docs/learning.rst +3 -1
  37. data/docs/parameters.rst +14 -6
  38. data/docs/text_feature.rst +42 -13
  39. data/docs/units.rst +9 -1
  40. data/lib/squib/api/data.rb +6 -5
  41. data/lib/squib/api/groups.rb +14 -7
  42. data/lib/squib/api/save.rb +2 -1
  43. data/lib/squib/args/sheet.rb +57 -2
  44. data/lib/squib/card.rb +8 -0
  45. data/lib/squib/conf.rb +9 -1
  46. data/lib/squib/deck.rb +2 -1
  47. data/lib/squib/graphics/save_doc.rb +0 -45
  48. data/lib/squib/graphics/save_pdf.rb +85 -0
  49. data/lib/squib/graphics/showcase.rb +1 -1
  50. data/lib/squib/import/data_frame.rb +108 -0
  51. data/lib/squib/version.rb +1 -1
  52. data/samples/autoscale_font/.gitignore +2 -0
  53. data/samples/autoscale_font/card_00_expected.png +0 -0
  54. data/samples/backend/.gitignore +1 -0
  55. data/samples/backend/_backend-config.yml +5 -0
  56. data/samples/backend/_backend.rb +2 -9
  57. data/samples/backend/backend_00_expected.png +0 -0
  58. data/samples/backend/backend_01_expected.png +0 -0
  59. data/samples/backend/backend_vectorized_expected.pdf +0 -0
  60. data/samples/backend/backend_vectors_00_expected.svg +84 -0
  61. data/samples/backend/backend_vectors_01_expected.svg +84 -0
  62. data/samples/backend/shiny-purse.png +0 -0
  63. data/samples/backend/showcase_expected.png +0 -0
  64. data/samples/backend/spanner.svg +91 -0
  65. data/samples/build_groups/.gitignore +1 -0
  66. data/samples/build_groups/Rakefile +25 -0
  67. data/samples/colors/.gitignore +1 -0
  68. data/samples/colors/color_constants_00_expected.png +0 -0
  69. data/samples/colors/colors_00_expected.png +0 -0
  70. data/samples/colors/gradient_00_expected.png +0 -0
  71. data/samples/data/.gitignore +1 -0
  72. data/samples/data/explode_quantities.xlsx +0 -0
  73. data/samples/data/quantity_explosion.csv +3 -0
  74. data/samples/data/sample.csv +3 -0
  75. data/samples/data/sample.xlsx +0 -0
  76. data/samples/data/sample_csv_00_expected.png +0 -0
  77. data/samples/data/sample_csv_01_expected.png +0 -0
  78. data/samples/data/sample_csv_qty_00_expected.png +0 -0
  79. data/samples/data/sample_excel_00_expected.png +0 -0
  80. data/samples/data/sample_excel_01_expected.png +0 -0
  81. data/samples/data/sample_excel_02_expected.png +0 -0
  82. data/samples/data/sample_excel_resources_00_expected.png +0 -0
  83. data/samples/data/sample_excel_resources_01_expected.png +0 -0
  84. data/samples/data/sample_xlsx_qty_00_expected.png +0 -0
  85. data/samples/images/.gitignore +8 -0
  86. data/samples/images/_images_00_expected.png +0 -0
  87. data/samples/images/angler-fish.png +0 -0
  88. data/samples/images/ball.png +0 -0
  89. data/samples/images/glass-heart.svg +52 -0
  90. data/samples/images/grit.png +0 -0
  91. data/samples/images/offset.svg +85 -0
  92. data/samples/images/robot-golem.svg +1 -0
  93. data/samples/images/shiny-purse.png +0 -0
  94. data/samples/images/spanner.svg +91 -0
  95. data/samples/images/sprites.png +0 -0
  96. data/samples/images/with-alpha.png +0 -0
  97. data/samples/intro/.gitignore +2 -0
  98. data/samples/intro/auto-repair.svg +1 -0
  99. data/samples/intro/crawling.svg +1 -0
  100. data/samples/intro/data.xlsx +0 -0
  101. data/samples/intro/humans.svg +1 -0
  102. data/samples/intro/ninja-mask.svg +1 -0
  103. data/samples/intro/part1_00_expected.png +0 -0
  104. data/samples/intro/part2_00_expected.png +0 -0
  105. data/samples/intro/part3_00_expected.png +0 -0
  106. data/samples/intro/part3_layout.yml +34 -0
  107. data/samples/intro/part4_00_expected.png +0 -0
  108. data/samples/intro/part4_01_expected.png +0 -0
  109. data/samples/intro/part5_00_expected.png +0 -0
  110. data/samples/intro/part5_01_expected.png +0 -0
  111. data/samples/intro/part5_02_expected.png +0 -0
  112. data/samples/intro/part5_03_expected.png +0 -0
  113. data/samples/intro/part5_hand_expected.png +0 -0
  114. data/samples/intro/part5_showcase_expected.png +0 -0
  115. data/samples/intro/pirate-skull.svg +1 -0
  116. data/samples/intro/robot-golem.svg +1 -0
  117. data/samples/project/Gemfile +6 -0
  118. data/samples/project/Guardfile +18 -0
  119. data/samples/project/Rakefile +25 -0
  120. data/samples/project/bw/robot-golem.svg +53 -0
  121. data/samples/project/color/robot-golem.svg +1 -0
  122. data/samples/project/config.yml +2 -0
  123. data/samples/project/layouts/characters.yml +3 -0
  124. data/samples/project/layouts/skills.yml +3 -0
  125. data/samples/project/src/characters.rb +8 -0
  126. data/samples/project/src/skills.rb +7 -0
  127. data/samples/{ranges.rb → ranges/_ranges.rb} +0 -0
  128. data/samples/ranges/glass-heart.svg +52 -0
  129. data/samples/ranges/ranges_00_expected.png +0 -0
  130. data/samples/saves/.gitignore +1 -0
  131. data/samples/saves/_save_pdf.rb +18 -0
  132. data/samples/saves/hand_expected.png +0 -0
  133. data/samples/saves/hand_pretty_expected.png +0 -0
  134. data/samples/saves/save-pdf-small_expected.pdf +0 -0
  135. data/samples/saves/save-pdf_expected.pdf +0 -0
  136. data/samples/saves/save_png_00_expected.png +0 -0
  137. data/samples/saves/save_png_trimmed_00_expected.png +0 -0
  138. data/samples/saves/save_sheet_00_expected.png +0 -0
  139. data/samples/saves/save_sheet_01_expected.png +0 -0
  140. data/samples/saves/save_sheet_range_00_expected.png +0 -0
  141. data/samples/saves/save_sheet_range_01_expected.png +0 -0
  142. data/samples/saves/save_single_sheet_00_expected.png +0 -0
  143. data/samples/saves/saves_notrim_01_expected.png +0 -0
  144. data/samples/saves/showcase2_expected.png +0 -0
  145. data/samples/saves/showcase_expected.png +0 -0
  146. data/samples/saves/showcase_individual_00_expected.png +0 -0
  147. data/samples/saves/showcase_individual_01_expected.png +0 -0
  148. data/samples/saves/showcase_individual_02_expected.png +0 -0
  149. data/samples/saves/showcase_individual_03_expected.png +0 -0
  150. data/samples/saves/spanner.svg +91 -0
  151. data/samples/shapes/.gitignore +1 -0
  152. data/samples/shapes/shape_00_expected.png +0 -0
  153. data/samples/text/.gitignore +2 -0
  154. data/samples/text/README.md +1 -0
  155. data/samples/text/_text_00_expected.png +0 -0
  156. data/samples/text/config.yml +2 -0
  157. data/samples/units/_units.rb +32 -0
  158. data/samples/units/units_00_expected.png +0 -0
  159. data/samples/units/using_units.yml +10 -0
  160. data/spec/api/api_data_spec.rb +18 -18
  161. data/spec/api/api_groups_spec.rb +49 -0
  162. data/spec/args/sheet_spec.rb +24 -2
  163. data/spec/conf_spec.rb +8 -0
  164. data/spec/data/conf/basic.yml +1 -0
  165. data/spec/data/samples/autoscale_font/_autoscale_font.rb.txt +3 -0
  166. data/spec/data/samples/basic.rb.txt +3 -0
  167. data/spec/data/samples/cairo_access.rb.txt +2 -0
  168. data/spec/data/samples/colors/_gradients.rb.txt +1 -0
  169. data/spec/data/samples/config_text_markup.rb.txt +2 -0
  170. data/spec/data/samples/custom_config.rb.txt +1 -0
  171. data/spec/data/samples/data/_csv.rb.txt +6 -0
  172. data/spec/data/samples/data/_excel.rb.txt +13 -0
  173. data/spec/data/samples/embed_text.rb.txt +4 -0
  174. data/spec/data/samples/hello_world.rb.txt +2 -0
  175. data/spec/data/samples/images/_more_load_images.rb.txt +1 -0
  176. data/spec/data/samples/{ranges.rb.txt → ranges/_ranges.rb.txt} +3 -0
  177. data/spec/data/samples/saves/_hand.rb.txt +8 -0
  178. data/spec/data/samples/saves/_portrait_landscape.rb.txt +2 -0
  179. data/spec/data/samples/saves/_save_pdf.rb.txt +1505 -449
  180. data/spec/data/samples/saves/_saves.rb.txt +16 -0
  181. data/spec/data/samples/saves/_showcase.rb.txt +4 -0
  182. data/spec/data/samples/shapes/_draw_shapes.rb.txt +1 -0
  183. data/spec/data/samples/text_options.rb.txt +3 -0
  184. data/spec/data/samples/tgc_proofs.rb.txt +1 -0
  185. data/spec/data/samples/{units.rb.txt → units/_units.rb.txt} +20 -15
  186. data/spec/deck_spec.rb +7 -0
  187. data/spec/graphics/graphics_save_doc_spec.rb +2 -1
  188. data/spec/import/data_frame_spec.rb +251 -0
  189. data/spec/samples/run_samples_spec.rb +1 -1
  190. data/spec/samples/samples_regression_spec.rb +3 -2
  191. data/squib.gemspec +6 -6
  192. metadata +144 -24
  193. data/.gitmodules +0 -36
  194. data/samples/units.rb +0 -28
@@ -0,0 +1 @@
1
+ _output/*
@@ -0,0 +1,18 @@
1
+ require 'squib'
2
+
3
+ Squib::Deck.new(cards: 8) do
4
+ background color: :gray
5
+ rect x: 37.5, y: 37.5, width: 750, height: 1050,
6
+ x_radius: 37.5, y_radius: 37.5, stroke: 3.0, dash: '4 4'
7
+
8
+ # Tests for crop marks
9
+ save_pdf file: 'crops-default.pdf', crop_marks: true
10
+ save_pdf file: 'crops-gapped.pdf', crop_marks: true, trim: 37.5, gap: 20
11
+
12
+ # Test crop marks with all the bells and whistles
13
+ rect x: '0.3in', y: '0.4in', width: '2in', height: '2.5in'
14
+ save_pdf file: 'crops-custom.pdf', crop_marks: true, trim: 0, gap: 20,
15
+ crop_stroke_dash: '5 5', crop_stroke_color: :red, crop_stroke_width: 4.0,
16
+ crop_margin_left: '0.3in', crop_margin_right: '0.45in',
17
+ crop_margin_top: '0.4in', crop_margin_bottom: '0.85in'
18
+ end
@@ -0,0 +1,91 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <svg
3
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
4
+ xmlns:cc="http://creativecommons.org/ns#"
5
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
6
+ xmlns:svg="http://www.w3.org/2000/svg"
7
+ xmlns="http://www.w3.org/2000/svg"
8
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
9
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
10
+ viewBox="0 0 128 128"
11
+ id="svg2"
12
+ version="1.1"
13
+ inkscape:version="0.48.3.1 r9886"
14
+ width="100%"
15
+ height="100%"
16
+ sodipodi:docname="spanner.svg">
17
+ <metadata
18
+ id="metadata18">
19
+ <rdf:RDF>
20
+ <cc:Work
21
+ rdf:about="">
22
+ <dc:format>image/svg+xml</dc:format>
23
+ <dc:type
24
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
25
+ </cc:Work>
26
+ </rdf:RDF>
27
+ </metadata>
28
+ <defs
29
+ id="defs16" />
30
+ <sodipodi:namedview
31
+ pagecolor="#ffffff"
32
+ bordercolor="#666666"
33
+ borderopacity="1"
34
+ objecttolerance="10"
35
+ gridtolerance="10"
36
+ guidetolerance="10"
37
+ inkscape:pageopacity="0"
38
+ inkscape:pageshadow="2"
39
+ inkscape:window-width="1280"
40
+ inkscape:window-height="1002"
41
+ id="namedview14"
42
+ showgrid="false"
43
+ inkscape:zoom="2.8284271"
44
+ inkscape:cx="98.928938"
45
+ inkscape:cy="62.194589"
46
+ inkscape:window-x="1912"
47
+ inkscape:window-y="-8"
48
+ inkscape:window-maximized="1"
49
+ inkscape:current-layer="g3767"
50
+ inkscape:document-units="in"
51
+ units="px"
52
+ showguides="true"
53
+ inkscape:guide-bbox="true" />
54
+ <g
55
+ id="g3767"
56
+ transform="matrix(0.24961486,0,0,0.24961486,0.197194,96.049335)">
57
+ <rect
58
+ ry="67.108368"
59
+ y="-378.68747"
60
+ x="5.3126979"
61
+ height="501.3746"
62
+ width="501.3746"
63
+ id="backdrop"
64
+ style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:10.62539577;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
65
+ inkscape:label="#rect3765" />
66
+ <path
67
+ style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
68
+ d="M 36.267098,-7.709219 C 16.393265,5.1318032 3.2161811,27.462365 3.2161811,52.884128 c 0,39.825874 32.2852369,72.111092 72.1110909,72.111092 23.870397,0 44.964938,-11.67699 58.089488,-29.545518 -11.26063,7.275808 -24.65607,11.517748 -39.060173,11.517748 -39.825853,0 -72.11109,-32.285221 -72.11109,-72.111095 0,-15.95546 5.248882,-30.6218942 14.021601,-42.565574 z"
69
+ id="path3790"
70
+ inkscape:connector-curvature="0" />
71
+ <g
72
+ id="g6"
73
+ transform="matrix(18.68858,0,0,18.68858,-3385.6437,-2608.3849)">
74
+ <path
75
+ style="fill:#ffffff"
76
+ inkscape:connector-curvature="0"
77
+ id="path8"
78
+ d="m 192.2325,129.3203 -10,10 v 5.5625 h 5.375 l 10.0938,-10.0938 -5.4688,-5.4688 z" />
79
+ <path
80
+ style="fill:#ffffff;stroke:#000000"
81
+ inkscape:connector-curvature="0"
82
+ id="path10"
83
+ d="m 181.7796,141.8591 15.6196,-15.6178 m 3.349,3.3486 -15.8051,15.8032" />
84
+ <path
85
+ style="fill:#ffffff"
86
+ inkscape:connector-curvature="0"
87
+ id="path12"
88
+ d="m 201.2023,119.7104 c -2.8283,-0.73 -5.9623,-0.004 -8.1759,2.2097 -3.3293,3.3292 -3.3293,8.7358 -2e-5,12.065 3.32928,3.3292 8.7358,3.3292 12.065,0 2.216,-2.216 2.9436,-5.3452 2.2097,-8.1759 l -5.6348,5.6348 -4.8172,-1.2816 -1.2816,-4.8171 5.6348,-5.6348 z" />
89
+ </g>
90
+ </g>
91
+ </svg>
@@ -0,0 +1 @@
1
+ _output/*
@@ -0,0 +1,2 @@
1
+ *.png
2
+ !_text_00_expected.png
@@ -0,0 +1 @@
1
+ Using the `text` method in Squib
@@ -0,0 +1,2 @@
1
+ # Turn off warnings about ellipsization for this example
2
+ warn_ellipsize: false
@@ -0,0 +1,32 @@
1
+ require 'squib'
2
+
3
+ Squib::Deck.new(width: '1.5in', height: '1.5in') do
4
+ background color: :white
5
+
6
+ # We can use our DSL-method to use inches
7
+ # Computed using @dpi (set to 300 by default)
8
+ bleed = inches(0.125)
9
+ cut = inches(1.25)
10
+ rect x: bleed, y: bleed,
11
+ width: cut, height: cut,
12
+ dash: '0.5mm 0.5mm' # yes, units are in dashes too
13
+
14
+ # other units too
15
+ cm(2) # We can also use cm this way
16
+ cm(2) + inches(2) # We can mix units too
17
+
18
+ # Or we can use a string ending with cm or in
19
+ safe_margin = '0.25 in' #you can have a space too
20
+ safe_width = '1 in'
21
+ safe_height = '1.0 in ' # trailing space is ok too
22
+ rect x: safe_margin, y: safe_margin,
23
+ width: safe_width, height: safe_height,
24
+ radius: '2 mm '
25
+
26
+ # We can also do stuff in layout. Check out the yml file...
27
+ # (even cleaner in Yaml since we don't need quotes!)
28
+ use_layout file: 'using_units.yml'
29
+ text str: 'Hello.', layout: :example
30
+
31
+ save prefix: 'units_', format: :png
32
+ end
@@ -0,0 +1,10 @@
1
+ base:
2
+ x: .25 in
3
+ y: 0.751in
4
+
5
+ example:
6
+ extends: base
7
+ x: += 5mm # we can mix units on adding
8
+ y: -= 5mm
9
+ width: 1.25in
10
+ height: 300 # pixels
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Squib::Deck do
4
4
  context '#csv' do
5
5
  it 'loads basic csv data' do
6
- expect(Squib.csv(file: csv_file('basic.csv'))).to eq({
6
+ expect(Squib.csv(file: csv_file('basic.csv')).to_h.to_h).to eq({
7
7
  'h1' => [1, 3],
8
8
  'h2' => [2, 4]
9
9
  })
@@ -12,7 +12,7 @@ describe Squib::Deck do
12
12
  it 'collapses duplicate columns and warns' do
13
13
  expect(Squib.logger).to receive(:warn)
14
14
  .with('CSV duplicated the following column keys: h1,h1')
15
- expect(Squib.csv(file: csv_file('dup_cols.csv'))).to eq({
15
+ expect(Squib.csv(file: csv_file('dup_cols.csv')).to_h.to_h).to eq({
16
16
  'h1' => [1, 3],
17
17
  'h2' => [5, 7],
18
18
  'H2' => [6, 8],
@@ -21,7 +21,7 @@ describe Squib::Deck do
21
21
  end
22
22
 
23
23
  it 'strips spaces by default' do
24
- expect(Squib.csv(file: csv_file('with_spaces.csv'))).to eq({
24
+ expect(Squib.csv(file: csv_file('with_spaces.csv')).to_h).to eq({
25
25
  'With Spaces' => ['a b c', 3],
26
26
  'h2' => [2, 4],
27
27
  'h3' => [3, nil]
@@ -29,7 +29,7 @@ describe Squib::Deck do
29
29
  end
30
30
 
31
31
  it 'skips space stripping if told to' do
32
- expect(Squib.csv(strip: false, file: csv_file('with_spaces.csv'))).to eq({
32
+ expect(Squib.csv(strip: false, file: csv_file('with_spaces.csv')).to_h).to eq({
33
33
  ' With Spaces ' => ['a b c ', 3],
34
34
  'h2' => [2, 4],
35
35
  'h3' => [3, nil]
@@ -37,14 +37,14 @@ describe Squib::Deck do
37
37
  end
38
38
 
39
39
  it 'explodes quantities' do
40
- expect(Squib.csv(file: csv_file('qty.csv'))).to eq({
40
+ expect(Squib.csv(file: csv_file('qty.csv')).to_h).to eq({
41
41
  'Name' => %w(Ha Ha Ha Ho),
42
42
  'Qty' => [3, 3, 3, 1],
43
43
  })
44
44
  end
45
45
 
46
46
  it 'explodes quantities on specified header' do
47
- expect(Squib.csv(explode: 'Quantity', file: csv_file('qty_named.csv'))).to eq({
47
+ expect(Squib.csv(explode: 'Quantity', file: csv_file('qty_named.csv')).to_h).to eq({
48
48
  'Name' => %w(Ha Ha Ha Ho),
49
49
  'Quantity' => [3, 3, 3, 1],
50
50
  })
@@ -52,7 +52,7 @@ describe Squib::Deck do
52
52
 
53
53
  it 'loads inline data' do
54
54
  hash = Squib.csv(data: "h1,h2\n1,2\n3,4")
55
- expect(hash).to eq({
55
+ expect(hash.to_h).to eq({
56
56
  'h1' => [1, 3],
57
57
  'h2' => [2, 4]
58
58
  })
@@ -60,7 +60,7 @@ describe Squib::Deck do
60
60
 
61
61
  it 'loads csv with newlines' do
62
62
  hash = Squib.csv(file: csv_file('newline.csv'))
63
- expect(hash).to eq({
63
+ expect(hash.to_h).to eq({
64
64
  'title' => ['Foo'],
65
65
  'level' => [1],
66
66
  'notes' => ["a\nb"]
@@ -70,7 +70,7 @@ describe Squib::Deck do
70
70
  it 'loads custom CSV options' do
71
71
  hash = Squib.csv(file: csv_file('custom_opts.csv'),
72
72
  col_sep: '-', quote_char: '|')
73
- expect(hash).to eq({
73
+ expect(hash.to_h).to eq({
74
74
  'x' => ['p'],
75
75
  'y' => ['q-r']
76
76
  })
@@ -85,7 +85,7 @@ describe Squib::Deck do
85
85
  'ha'
86
86
  end
87
87
  end
88
- expect(data).to eq({
88
+ expect(data.to_h).to eq({
89
89
  'h1' => [2, 6],
90
90
  'h2' => %w(ha ha),
91
91
  })
@@ -99,7 +99,7 @@ describe Squib::Deck do
99
99
  value
100
100
  end
101
101
  end
102
- expect(data).to eq({
102
+ expect(data.to_h).to eq({
103
103
  'a' => ["foo\nbar", 1],
104
104
  'b' => [1, "blah\n"],
105
105
  })
@@ -109,7 +109,7 @@ describe Squib::Deck do
109
109
 
110
110
  context '#xlsx' do
111
111
  it 'loads basic xlsx data' do
112
- expect(Squib.xlsx(file: xlsx_file('basic.xlsx'))).to eq({
112
+ expect(Squib.xlsx(file: xlsx_file('basic.xlsx')).to_h).to eq({
113
113
  'Name' => %w(Larry Curly Mo),
114
114
  'General Number' => %w(1 2 3), # general types always get loaded as strings with no conversion
115
115
  'Actual Number' => [4.0, 5.0, 6.0], # numbers get auto-converted to integers
@@ -117,7 +117,7 @@ describe Squib::Deck do
117
117
  end
118
118
 
119
119
  it 'loads xlsx with formulas' do
120
- expect(Squib.xlsx(file: xlsx_file('formulas.xlsx'))).to eq({
120
+ expect(Squib.xlsx(file: xlsx_file('formulas.xlsx')).to_h).to eq({
121
121
  'A' => %w(1 2),
122
122
  'B' => %w(3 4),
123
123
  'Sum' => %w(4 6),
@@ -125,20 +125,20 @@ describe Squib::Deck do
125
125
  end
126
126
 
127
127
  it 'loads xlsm files with macros' do
128
- expect(Squib.xlsx(file: xlsx_file('with_macros.xlsm'))).to eq({
128
+ expect(Squib.xlsx(file: xlsx_file('with_macros.xlsm')).to_h).to eq({
129
129
  'foo' => %w(8 10),
130
130
  'bar' => %w(9 11),
131
131
  })
132
132
  end
133
133
 
134
134
  it 'strips whitespace by default' do
135
- expect(Squib.xlsx(file: xlsx_file('whitespace.xlsx'))).to eq({
135
+ expect(Squib.xlsx(file: xlsx_file('whitespace.xlsx')).to_h).to eq({
136
136
  'With Whitespace' => ['foo', 'bar', 'baz'],
137
137
  })
138
138
  end
139
139
 
140
140
  it 'does not strip whitespace when specified' do
141
- expect(Squib.xlsx(file: xlsx_file('whitespace.xlsx'), strip: false)).to eq({
141
+ expect(Squib.xlsx(file: xlsx_file('whitespace.xlsx'), strip: false).to_h).to eq({
142
142
  ' With Whitespace ' => ['foo ', ' bar', ' baz '],
143
143
  })
144
144
  end
@@ -154,7 +154,7 @@ describe Squib::Deck do
154
154
  'ha'
155
155
  end
156
156
  end
157
- expect(data).to eq({
157
+ expect(data.to_h).to eq({
158
158
  'Name' => %w(he he he),
159
159
  'General Number' => %w(ha ha ha),
160
160
  'Actual Number' => [8.0, 10.0, 12.0],
@@ -162,7 +162,7 @@ describe Squib::Deck do
162
162
  end
163
163
 
164
164
  it 'explodes quantities' do
165
- expect(Squib.xlsx(explode: 'Qty', file: xlsx_file('explode_quantities.xlsx'))).to eq({
165
+ expect(Squib.xlsx(explode: 'Qty', file: xlsx_file('explode_quantities.xlsx')).to_h).to eq({
166
166
  'Name' => ['Zergling', 'Zergling', 'Zergling', 'High Templar'],
167
167
  'Qty' => %w(3 3 3 1),
168
168
  })
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+ require 'squib'
3
+
4
+ describe :build_group do
5
+
6
+ context '#enable_build_globally' do
7
+ before(:each) { ENV['SQUIB_BUILD'] = '' }
8
+
9
+ it 'enables one group via ENV' do
10
+ Squib.enable_build_globally 'foo'
11
+ expect(ENV['SQUIB_BUILD']).to eq 'foo'
12
+ end
13
+
14
+ it 'enables two groups via ENV' do
15
+ Squib.enable_build_globally 'foo'
16
+ Squib.enable_build_globally 'bar'
17
+ expect(ENV['SQUIB_BUILD']).to eq 'foo,bar'
18
+ end
19
+
20
+ it 'uniqs the groups' do
21
+ Squib.enable_build_globally 'foo'
22
+ Squib.enable_build_globally 'bar'
23
+ Squib.enable_build_globally 'bar'
24
+ expect(ENV['SQUIB_BUILD']).to eq 'foo,bar'
25
+ end
26
+
27
+ it 'handles symbols' do
28
+ Squib.enable_build_globally :foo
29
+ expect(ENV['SQUIB_BUILD']).to eq 'foo'
30
+ end
31
+
32
+ end
33
+
34
+ context '#disable_build_globally' do
35
+ before(:each) { ENV['SQUIB_BUILD'] = 'foo,bar' }
36
+
37
+ it 'can be disabled globally via ENV' do
38
+ Squib.disable_build_globally 'bar'
39
+ expect(ENV['SQUIB_BUILD']).to eq 'foo'
40
+ end
41
+
42
+ it 'handles symbols' do
43
+ Squib.disable_build_globally :bar
44
+ expect(ENV['SQUIB_BUILD']).to eq 'foo'
45
+ end
46
+ end
47
+
48
+
49
+ end
@@ -50,9 +50,31 @@ describe Squib::Args::Sheet do
50
50
  opts = { columns: :infinite }
51
51
  expect { sheet.load!(opts) }.to raise_error('columns must be an integer')
52
52
  end
53
+ end
53
54
 
55
+ context 'crop marks' do
56
+ subject(:sheet) { Squib::Args::Sheet.new({}, {}, 4) }
54
57
 
55
-
58
+ it 'computes crop marks properly' do
59
+ opts = {
60
+ width: 1000,
61
+ height: 1100,
62
+ trim: 10,
63
+ crop_margin_top: 20,
64
+ crop_margin_left: 30,
65
+ crop_margin_right: 40,
66
+ crop_margin_bottom: 50,
67
+ }
68
+ expect(sheet.load!(opts).crop_coords(3,4, 300, 400)).to eq(
69
+ [ {:x1=>43, :y1=>0, :x2=>43, :y2=>74},
70
+ {:x1=>253, :y1=>0, :x2=>253, :y2=>74},
71
+ {:x1=>43, :y1=>1100, :x2=>43, :y2=>1026},
72
+ {:x1=>253, :y1=>1100, :x2=>253, :y2=>1026},
73
+ {:x1=>0, :y1=>34, :x2=>74, :y2=>34},
74
+ {:x1=>1000, :y1=>34, :x2=>926, :y2=>34},
75
+ {:x1=>0, :y1=>344, :x2=>74, :y2=>344},
76
+ {:x1=>1000, :y1=>344, :x2=>926, :y2=>344}]
77
+ )
78
+ end
56
79
  end
57
-
58
80
  end