squib 0.9.0 → 0.10.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.
Files changed (230) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/.gitmodules +22 -0
  4. data/.travis.yml +4 -5
  5. data/CHANGELOG.md +23 -0
  6. data/CONTRIBUTING.md +40 -0
  7. data/README.md +25 -553
  8. data/RELEASE TODO.md +2 -2
  9. data/Rakefile +6 -64
  10. data/appveyor.yml +0 -4
  11. data/benchmarks/antialias_best.rb +2 -2
  12. data/benchmarks/antialias_fast.rb +2 -2
  13. data/benchmarks/{backend-memory.rb → backend_memory.rb} +2 -2
  14. data/benchmarks/{backend-svg.rb → backend_svg.rb} +2 -2
  15. data/benchmarks/tons_of_png.rb +1 -1
  16. data/benchmarks/tons_of_svg.rb +1 -1
  17. data/benchmarks/tons_of_text.rb +1 -1
  18. data/docs/Makefile +216 -0
  19. data/docs/_static/css/squibdocs.css +18 -0
  20. data/docs/args/draw.rst +36 -0
  21. data/docs/args/expansion.rst +3 -0
  22. data/docs/args/layout.rst +6 -0
  23. data/docs/args/output_dir.rst +6 -0
  24. data/docs/args/range.rst +6 -0
  25. data/docs/args/transform.rst +51 -0
  26. data/docs/args/trim.rst +11 -0
  27. data/docs/args/wh.rst +12 -0
  28. data/docs/args/xy.rst +12 -0
  29. data/docs/arrays.rst +77 -0
  30. data/docs/backends.rst +20 -0
  31. data/docs/bleed.rst +13 -0
  32. data/docs/build_groups.rst +47 -0
  33. data/docs/colors.rst +64 -0
  34. data/docs/conf.py +287 -0
  35. data/docs/config.rst +117 -0
  36. data/docs/data.rst +22 -0
  37. data/docs/dsl/background.rst +20 -0
  38. data/docs/dsl/build.rst +32 -0
  39. data/docs/dsl/build_groups.rst +23 -0
  40. data/docs/dsl/circle.rst +27 -0
  41. data/docs/dsl/cm.rst +19 -0
  42. data/docs/dsl/csv.rst +62 -0
  43. data/docs/dsl/curve.rst +63 -0
  44. data/docs/dsl/deck.rst +45 -0
  45. data/docs/dsl/disable_build.rst +28 -0
  46. data/docs/dsl/ellipse.rst +17 -0
  47. data/docs/dsl/enable_build.rst +25 -0
  48. data/docs/dsl/grid.rst +31 -0
  49. data/docs/dsl/hand.rst +40 -0
  50. data/docs/dsl/hint.rst +15 -0
  51. data/docs/dsl/inches.rst +19 -0
  52. data/docs/dsl/index.rst +9 -0
  53. data/docs/dsl/line.rst +52 -0
  54. data/docs/dsl/png.rst +49 -0
  55. data/docs/dsl/polygon.rst +28 -0
  56. data/docs/dsl/rect.rst +18 -0
  57. data/docs/dsl/save.rst +23 -0
  58. data/docs/dsl/save_pdf.rst +48 -0
  59. data/docs/dsl/save_png.rst +46 -0
  60. data/docs/dsl/save_sheet.rst +55 -0
  61. data/docs/dsl/showcase.rst +65 -0
  62. data/docs/dsl/star.rst +35 -0
  63. data/docs/dsl/svg.rst +119 -0
  64. data/docs/dsl/text.rst +294 -0
  65. data/docs/dsl/triangle.rst +38 -0
  66. data/docs/dsl/use_layout.rst +16 -0
  67. data/docs/dsl/xlsx.rst +50 -0
  68. data/docs/guides/game_icons.rst +2 -0
  69. data/docs/guides/getting-started/index.rst +5 -0
  70. data/docs/guides/getting-started/part_0_learning_ruby.rst +145 -0
  71. data/docs/guides/getting-started/part_1_zero_to_game.rst +216 -0
  72. data/docs/guides/getting-started/part_2_iconography.rst +152 -0
  73. data/docs/guides/getting-started/part_3_workflows.rst +4 -0
  74. data/docs/guides/git.rst +13 -0
  75. data/docs/guides/hello_world.rst +6 -0
  76. data/docs/help.rst +157 -0
  77. data/docs/index.rst +35 -0
  78. data/docs/install.rst +66 -0
  79. data/docs/layouts.rst +235 -0
  80. data/docs/learning.rst +10 -0
  81. data/docs/make.bat +263 -0
  82. data/docs/parameters.rst +26 -0
  83. data/docs/server.bat +1 -0
  84. data/docs/text_feature.rst +86 -0
  85. data/docs/units.rst +6 -0
  86. data/lib/squib.rb +4 -4
  87. data/lib/squib/api/background.rb +5 -10
  88. data/lib/squib/api/data.rb +30 -54
  89. data/lib/squib/api/groups.rb +47 -0
  90. data/lib/squib/api/image.rb +8 -67
  91. data/lib/squib/api/save.rb +15 -105
  92. data/lib/squib/api/settings.rb +8 -22
  93. data/lib/squib/api/shapes.rb +15 -185
  94. data/lib/squib/api/text.rb +9 -49
  95. data/lib/squib/api/text_embed.rb +12 -12
  96. data/lib/squib/api/units.rb +3 -17
  97. data/lib/squib/args/arg_loader.rb +6 -6
  98. data/lib/squib/args/box.rb +2 -2
  99. data/lib/squib/args/card_range.rb +1 -1
  100. data/lib/squib/args/color_validator.rb +2 -2
  101. data/lib/squib/args/coords.rb +2 -2
  102. data/lib/squib/args/csv_opts.rb +25 -0
  103. data/lib/squib/args/dir_validator.rb +1 -1
  104. data/lib/squib/args/draw.rb +2 -2
  105. data/lib/squib/args/embed_adjust.rb +1 -1
  106. data/lib/squib/args/embed_key.rb +1 -1
  107. data/lib/squib/args/hand_special.rb +37 -37
  108. data/lib/squib/args/import.rb +2 -2
  109. data/lib/squib/args/input_file.rb +1 -1
  110. data/lib/squib/args/paint.rb +3 -3
  111. data/lib/squib/args/paragraph.rb +2 -2
  112. data/lib/squib/args/save_batch.rb +2 -2
  113. data/lib/squib/args/scale_box.rb +1 -1
  114. data/lib/squib/args/sheet.rb +3 -3
  115. data/lib/squib/args/showcase_special.rb +2 -2
  116. data/lib/squib/args/svg_special.rb +1 -1
  117. data/lib/squib/args/transform.rb +2 -2
  118. data/lib/squib/args/typographer.rb +5 -4
  119. data/lib/squib/args/unit_conversion.rb +4 -4
  120. data/lib/squib/card.rb +8 -8
  121. data/lib/squib/conf.rb +5 -5
  122. data/lib/squib/deck.rb +20 -18
  123. data/lib/squib/graphics/cairo_context_wrapper.rb +3 -3
  124. data/lib/squib/graphics/gradient_regex.rb +1 -1
  125. data/lib/squib/graphics/hand.rb +2 -2
  126. data/lib/squib/graphics/save_doc.rb +9 -8
  127. data/lib/squib/graphics/save_images.rb +24 -11
  128. data/lib/squib/graphics/shapes.rb +16 -17
  129. data/lib/squib/graphics/showcase.rb +9 -9
  130. data/lib/squib/graphics/text.rb +21 -21
  131. data/lib/squib/layout_parser.rb +9 -9
  132. data/lib/squib/layouts/economy.yml +85 -85
  133. data/lib/squib/layouts/fantasy.yml +101 -101
  134. data/lib/squib/layouts/hand.yml +62 -62
  135. data/lib/squib/layouts/playing-card.yml +35 -35
  136. data/lib/squib/layouts/tuck_box.yml +45 -45
  137. data/lib/squib/sample_helpers.rb +1 -1
  138. data/lib/squib/version.rb +1 -1
  139. data/samples/{backend.rb → backend/_backend.rb} +2 -2
  140. data/samples/basic.rb +3 -3
  141. data/samples/bug134.rb +14 -0
  142. data/samples/build_groups/build_groups.rb +36 -0
  143. data/samples/cairo_access.rb +12 -1
  144. data/samples/{colors.rb → colors/_colors.rb} +12 -12
  145. data/samples/{gradients.rb → colors/_gradients.rb} +1 -1
  146. data/samples/config_text_markup.rb +2 -2
  147. data/samples/custom-config.yml +5 -5
  148. data/samples/custom_config.rb +18 -18
  149. data/samples/{csv_import.rb → data/_csv.rb} +8 -1
  150. data/samples/{excel.rb → data/_excel.rb} +3 -3
  151. data/samples/embed_text.rb +21 -0
  152. data/samples/hello_world.rb +1 -1
  153. data/samples/{load_images.rb → images/_more_load_images.rb} +2 -2
  154. data/samples/layouts.rb +11 -1
  155. data/samples/layouts_builtin.rb +51 -51
  156. data/samples/offset.svg +71 -71
  157. data/samples/ranges.rb +7 -7
  158. data/samples/{hand.rb → saves/_hand.rb} +1 -2
  159. data/samples/{portrait-landscape.rb → saves/_portrait_landscape.rb} +4 -4
  160. data/samples/{saves.rb → saves/_saves.rb} +0 -0
  161. data/samples/{showcase.rb → saves/_showcase.rb} +2 -2
  162. data/samples/{draw_shapes.rb → shapes/_draw_shapes.rb} +1 -1
  163. data/samples/text/_text.rb +4 -3
  164. data/samples/text_options.rb +6 -6
  165. data/samples/unicode.rb +1 -1
  166. data/spec/api/api_data_spec.rb +59 -4
  167. data/spec/api/api_settings_spec.rb +1 -1
  168. data/spec/args/box_spec.rb +7 -7
  169. data/spec/args/draw_spec.rb +19 -19
  170. data/spec/args/embed_key_spec.rb +13 -13
  171. data/spec/args/input_file_spec.rb +2 -2
  172. data/spec/args/paint_spec.rb +5 -5
  173. data/spec/args/paragraph_spec.rb +28 -28
  174. data/spec/args/range_spec.rb +1 -1
  175. data/spec/args/save_batch_spec.rb +10 -10
  176. data/spec/args/scale_box_spec.rb +9 -9
  177. data/spec/args/sheet_spec.rb +8 -8
  178. data/spec/args/showcase_special_spec.rb +15 -15
  179. data/spec/args/transform_spec.rb +4 -4
  180. data/spec/args/typographer_spec.rb +11 -11
  181. data/spec/args/unit_conversion_spec.rb +2 -2
  182. data/spec/card_spec.rb +1 -1
  183. data/spec/commands/new_spec.rb +1 -1
  184. data/spec/data/csv/custom_opts.csv +2 -0
  185. data/spec/data/csv/newline.csv +3 -0
  186. data/spec/data/csv/qty.csv +2 -2
  187. data/spec/data/csv/qty_named.csv +2 -2
  188. data/spec/data/csv/with_spaces.csv +2 -2
  189. data/spec/data/csv/yield.csv +3 -0
  190. data/spec/data/samples/{autoscale_font.rb.txt → autoscale_font/_autoscale_font.rb.txt} +55 -18
  191. data/spec/data/samples/cairo_access.rb.txt +24 -0
  192. data/spec/data/samples/{gradients.rb.txt → colors/_gradients.rb.txt} +0 -0
  193. data/spec/data/samples/config_text_markup.rb.txt +72 -72
  194. data/spec/data/samples/custom_config.rb.txt +1 -0
  195. data/spec/data/samples/{csv_import.rb.txt → data/_csv.rb.txt} +0 -0
  196. data/spec/data/samples/{excel.rb.txt → data/_excel.rb.txt} +0 -0
  197. data/spec/data/samples/embed_text.rb.txt +79 -0
  198. data/spec/data/samples/hello_world.rb.txt +36 -36
  199. data/spec/data/samples/{load_images.rb.txt → images/_more_load_images.rb.txt} +4 -4
  200. data/spec/data/samples/{hand.rb.txt → saves/_hand.rb.txt} +0 -0
  201. data/spec/data/samples/{portrait-landscape.rb.txt → saves/_portrait_landscape.rb.txt} +11 -7
  202. data/spec/data/samples/{save_pdf.rb.txt → saves/_save_pdf.rb.txt} +0 -0
  203. data/spec/data/samples/{saves.rb.txt → saves/_saves.rb.txt} +3 -4
  204. data/spec/data/samples/{showcase.rb.txt → saves/_showcase.rb.txt} +0 -0
  205. data/spec/data/samples/{draw_shapes.rb.txt → shapes/_draw_shapes.rb.txt} +0 -0
  206. data/spec/data/samples/text_options.rb.txt +1125 -1125
  207. data/spec/graphics/cairo_context_wrapper_spec.rb +10 -10
  208. data/spec/graphics/graphics_save_doc_spec.rb +11 -5
  209. data/spec/layout_parser_spec.rb +21 -9
  210. data/spec/logger_spec.rb +2 -2
  211. data/spec/samples/run_samples_spec.rb +1 -1
  212. data/spec/samples/samples_regression_spec.rb +16 -18
  213. data/spec/samples/sanity.rb +9 -9
  214. data/spec/sanity/.gitignore +1 -0
  215. data/spec/sanity/sanity.html.erb +42 -0
  216. data/spec/sanity/sanity_test.rb +42 -0
  217. data/spec/sanity/tests.yml +12 -0
  218. data/spec/spec_helper.rb +22 -20
  219. data/squib.gemspec +3 -4
  220. metadata +143 -81
  221. data/.rspec +0 -1
  222. data/.yardopts +0 -10
  223. data/samples/autoscale_font.rb +0 -27
  224. data/samples/backend-config.yml +0 -5
  225. data/samples/color_shortcuts.rb +0 -6
  226. data/samples/explode_quantities.xlsx +0 -0
  227. data/samples/quantity_explosion.csv +0 -3
  228. data/samples/sample.csv +0 -3
  229. data/samples/sample.xlsx +0 -0
  230. data/squib.sublime-project +0 -42
@@ -7,7 +7,7 @@ Squib::Deck.new(cards: 8, layout: 'playing-card.yml') do
7
7
  text str: ('A'..'Z').to_a, layout: :bonus_ul, font: 'Sans bold 100'
8
8
 
9
9
  # Defaults are sensible
10
- hand #saves to _output/hand.png
10
+ hand # saves to _output/hand.png
11
11
 
12
12
  # Here's a prettier version:
13
13
  # - Each card is trimmed with rounded corners
@@ -21,4 +21,3 @@ Squib::Deck.new(cards: 8, layout: 'playing-card.yml') do
21
21
  # Tip: you can have the top card be on the left by reversing the range
22
22
  # angle_range: (Math::PI / 4)..(Math::PI / -4)
23
23
  end
24
-
@@ -8,16 +8,16 @@ require 'squib'
8
8
  Squib::Deck.new(width: 825, height: 1125) do
9
9
  background color: '#aaa'
10
10
 
11
- text str: 'This is portrait'
11
+ text str: 'This is portrait and trimmed'
12
12
 
13
- save_png prefix: 'portrait_'
13
+ save_png prefix: 'portrait_', trim: 10, trim_radius: 15
14
14
  end
15
15
 
16
16
  # Money cards are landscape
17
17
  Squib::Deck.new(width: 1125, height: 825) do
18
18
  background color: '#aaa'
19
19
 
20
- text str: 'This is landscape'
20
+ text str: 'This is landscape and trimmed', x: 15, y: 10
21
21
 
22
- save_png prefix: 'landscape_', rotate: true
22
+ save_png prefix: 'landscape_', rotate: :clockwise, trim: 25, trim_radius: 15
23
23
  end
File without changes
@@ -9,7 +9,7 @@ Squib::Deck.new(cards: 4) do
9
9
  text str: %w(Grifter Thief Thug Kingpin),
10
10
  font: 'Helvetica,Sans weight=800 120',
11
11
  x: 78, y: 78, width: '2.25in', align: :center
12
- svg file: 'spanner.svg', x: (825-500)/2, y: 500, width: 500, height: 500
12
+ svg file: 'spanner.svg', x: (825 - 500) / 2, y: 500, width: 500, height: 500
13
13
 
14
14
  # Defaults are pretty sensible.
15
15
  showcase file: 'showcase.png'
@@ -22,4 +22,4 @@ Squib::Deck.new(cards: 4) do
22
22
  file: 'showcase2.png'
23
23
 
24
24
  save_png prefix: 'showcase_individual_' # to show that they're not trimmed
25
- end
25
+ end
@@ -36,7 +36,7 @@ Squib::Deck.new do
36
36
  star x: 300, y: 1000, n: 5, inner_radius: 15, outer_radius: 40,
37
37
  fill_color: :cyan, stroke_color: :burgundy, stroke_width: 5
38
38
 
39
- #default draw is fill-then-stroke. Can be changed to stroke-then-fill
39
+ # default draw is fill-then-stroke. Can be changed to stroke-then-fill
40
40
  star x: 375, y: 1000, n: 5, inner_radius: 15, outer_radius: 40,
41
41
  fill_color: :cyan, stroke_color: :burgundy,
42
42
  stroke_width: 5, stroke_strategy: :stroke_first
@@ -1,13 +1,14 @@
1
1
  require 'squib'
2
2
  require 'squib/sample_helpers'
3
3
 
4
- Squib::Deck.new(width: 1000, height: 2000) do
4
+ Squib::Deck.new(width: 1000, height: 1250) do
5
5
  draw_graph_paper width, height
6
6
 
7
- sample 'Font strings are quite expressive. Specify family, modifiers, then size. Font names with spaces in them should also have a backup afterward to help with parsing.' do |x, y|
7
+ sample 'Font strings are quite expressive. Specify family, modifiers, then size. Font names with spaces in them should end with a comma to help with parsing.' do |x, y|
8
8
  text font: 'Arial bold italic 32', str: 'Bold and italic!', x: x, y: y - 50
9
9
  text font: 'Arial weight=300 32', str: 'Light bold!', x: x, y: y
10
- text font: 'Times New Roman,Arial 32', str: 'Times New Roman', x: x, y: y + 50
10
+ text font: 'Times New Roman, 32', str: 'Times New Roman', x: x, y: y + 50
11
+ text font: 'NoSuchFont,Arial 32', str: 'Arial Backup', x: x, y: y + 100
11
12
  end
12
13
 
13
14
  sample 'Specify width and height to see a text box. Also: set "hint" to see the extents of your text box' do |x, y|
@@ -1,8 +1,8 @@
1
1
  # encoding: UTF-8
2
2
  require 'squib'
3
3
 
4
- data = {'name' => ['Thief', 'Grifter', 'Mastermind'],
5
- 'level' => [1,2,3]}
4
+ data = { 'name' => ['Thief', 'Grifter', 'Mastermind'],
5
+ 'level' => [1, 2, 3] }
6
6
  longtext = "This is left-justified text, with newlines.\nWhat do you know about tweetle beetles? well... When tweetle beetles fight, it's called a tweetle beetle battle. And when they battle in a puddle, it's a tweetle beetle puddle battle. AND when tweetle beetles battle with paddles in a puddle, they call it a tweetle beetle puddle paddle battle. AND... When beetles battle beetles in a puddle paddle battle and the beetle battle puddle is a puddle in a bottle... ..they call this a tweetle beetle bottle puddle paddle battle muddle."
7
7
 
8
8
  Squib::Deck.new(width: 825, height: 1125, cards: 3) do
@@ -37,7 +37,7 @@ Squib::Deck.new(width: 825, height: 1125, cards: 3) do
37
37
  # Extents come back as an array of hashes, which can get split out like this
38
38
  ws = extents.inject([]) { |arr, ext| arr << ext[:width] + 10; arr }
39
39
  hs = extents.inject([]) { |arr, ext| arr << ext[:height] + 10; arr }
40
- rect x: 65 - margin/2, y: 550 - margin/2,
40
+ rect x: 65 - margin / 2, y: 550 - margin / 2,
41
41
  width: ws, height: hs,
42
42
  radius: 10, stroke_color: :black
43
43
 
@@ -79,15 +79,15 @@ Squib::Deck.new(width: 825, height: 1125, cards: 3) do
79
79
  embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
80
80
  end
81
81
 
82
- text str: "Fill n <span fgcolor=\"\#ff0000\">stroke</span>",
82
+ text str: 'Fill n <span fgcolor="#ff0000">stroke</span>',
83
83
  color: :green, stroke_width: 2.0, stroke_color: :blue,
84
84
  x: '1.8in', y: '2.9in', width: '0.85in', font: 'Sans Bold 26', markup: true
85
85
 
86
- text str: "Stroke n <span fgcolor=\"\#ff0000\">fill</span>",
86
+ text str: 'Stroke n <span fgcolor="#ff0000">fill</span>',
87
87
  color: :green, stroke_width: 2.0, stroke_color: :blue, stroke_strategy: :stroke_first,
88
88
  x: '1.8in', y: '3.0in', width: '0.85in', font: 'Sans Bold 26', markup: true
89
89
 
90
- text str: "Dotted",
90
+ text str: 'Dotted',
91
91
  color: :white, stroke_width: 2.0, dash: '4 2', stroke_color: :black,
92
92
  x: '1.8in', y: '3.1in', width: '0.85in', font: 'Sans Bold 26', markup: true
93
93
  #
data/samples/unicode.rb CHANGED
@@ -14,7 +14,7 @@ Squib::Deck.new(height: (game_chars.size / cols + 1) * cell_height,
14
14
  text str: 'Game-related UTF8 icons. Generated by Squib, https://github.com/andymeneely/squib'
15
15
  game_chars.each_with_index do |c, i|
16
16
  rect fill_color: %w(#eeee #ffff)[i % 2],
17
- width: cell_width, height: cell_height, x: x, y: y
17
+ width: cell_width, height: cell_height, x: x, y: y
18
18
  text str: c.inspect, font: 'Sans 42', x: x, y: y
19
19
  text str: c, font: 'Sans,Segoe UI Symbol 42', x: x + 300, y: y
20
20
  x += cell_width
@@ -38,26 +38,81 @@ describe Squib::Deck do
38
38
 
39
39
  it 'explodes quantities' do
40
40
  expect(Squib.csv(file: csv_file('qty.csv'))).to eq({
41
- 'Name' => %w(Ha Ha Ha Ho),
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
47
  expect(Squib.csv(explode: 'Quantity', file: csv_file('qty_named.csv'))).to eq({
48
- 'Name' => %w(Ha Ha Ha Ho),
48
+ 'Name' => %w(Ha Ha Ha Ho),
49
49
  'Quantity' => [3, 3, 3, 1],
50
50
  })
51
51
  end
52
52
 
53
+ it 'loads inline data' do
54
+ hash = Squib.csv(data: "h1,h2\n1,2\n3,4")
55
+ expect(hash).to eq({
56
+ 'h1' => [1, 3],
57
+ 'h2' => [2, 4]
58
+ })
59
+ end
60
+
61
+ it 'loads csv with newlines' do
62
+ hash = Squib.csv(file: csv_file('newline.csv'))
63
+ expect(hash).to eq({
64
+ 'title' => ['Foo'],
65
+ 'level' => [1],
66
+ 'notes' => ["a\nb"]
67
+ })
68
+ end
69
+
70
+ it 'loads custom CSV options' do
71
+ hash = Squib.csv(file: csv_file('custom_opts.csv'),
72
+ col_sep: '-', quote_char: '|')
73
+ expect(hash).to eq({
74
+ 'x' => ['p'],
75
+ 'y' => ['q-r']
76
+ })
77
+ end
78
+
79
+ it 'yields to block when given' do
80
+ data = Squib.csv(file: csv_file('basic.csv')) do |header, value|
81
+ case header
82
+ when 'h1'
83
+ value * 2
84
+ else
85
+ 'ha'
86
+ end
87
+ end
88
+ expect(data).to eq({
89
+ 'h1' => [2, 6],
90
+ 'h2' => %w(ha ha),
91
+ })
92
+ end
93
+
94
+ it 'replaces newlines whenever its a string' do
95
+ data = Squib.csv(file: csv_file('yield.csv')) do |header, value|
96
+ if value.respond_to? :gsub
97
+ value.gsub '%n', "\n"
98
+ else
99
+ value
100
+ end
101
+ end
102
+ expect(data).to eq({
103
+ 'a' => ["foo\nbar", 1],
104
+ 'b' => [1, "blah\n"],
105
+ })
106
+ end
107
+
53
108
  end
54
109
 
55
110
  context '#xlsx' do
56
111
  it 'loads basic xlsx data' do
57
112
  expect(Squib.xlsx(file: xlsx_file('basic.xlsx'))).to eq({
58
113
  'Name' => %w(Larry Curly Mo),
59
- 'General Number' => %w(1 2 3), #general types always get loaded as strings with no conversion
60
- 'Actual Number' => [4.0, 5.0, 6.0], #numbers get auto-converted to integers
114
+ 'General Number' => %w(1 2 3), # general types always get loaded as strings with no conversion
115
+ 'Actual Number' => [4.0, 5.0, 6.0], # numbers get auto-converted to integers
61
116
  })
62
117
  end
63
118
 
@@ -35,4 +35,4 @@ describe Squib::Deck do
35
35
 
36
36
  end
37
37
 
38
- end
38
+ end
@@ -3,7 +3,7 @@ require 'squib/args/box'
3
3
 
4
4
  describe Squib::Args::Box do
5
5
  subject(:box) { Squib::Args::Box.new }
6
- let(:expected_defaults) { {x: [0], y: [0], width: [:deck], height: [:deck] } }
6
+ let(:expected_defaults) { { x: [0], y: [0], width: [:deck], height: [:deck] } }
7
7
 
8
8
  it 'intitially has no params set' do
9
9
  expect(box).not_to respond_to(:x, :y, :width, :height)
@@ -20,13 +20,13 @@ describe Squib::Args::Box do
20
20
  end
21
21
 
22
22
  it 'extracts the defaults from Box on an empty hash' do
23
- box.load!({foo: :bar})
23
+ box.load!({ foo: :bar })
24
24
  expect(box).to have_attributes(expected_defaults)
25
25
  expect(box).not_to respond_to(:foo)
26
26
  end
27
27
 
28
28
  context 'single expansion' do
29
- let(:args) { {x: [1, 2], y: 3} }
29
+ let(:args) { { x: [1, 2], y: 3 } }
30
30
  before(:each) { box.load!(args, expand_by: 2) }
31
31
  it 'expands box' do
32
32
  expect(box).to have_attributes({
@@ -81,7 +81,7 @@ describe Squib::Args::Box do
81
81
  end
82
82
 
83
83
  it 'warns on non-existent layouts' do
84
- args = { layout: :heal}
84
+ args = { layout: :heal }
85
85
  expect(Squib.logger).to receive(:warn).with('Layout "heal" does not exist in layout file - using default instead').at_least(:once)
86
86
  box.load!(args, expand_by: 2, layout: layout)
87
87
  expect(box).to have_attributes(
@@ -94,7 +94,7 @@ describe Squib::Args::Box do
94
94
  context 'unit conversion' do
95
95
 
96
96
  it 'converts units on all args' do
97
- args = {x: ['1in', '2in'], y: 300, width: '1in', height: '1in'}
97
+ args = { x: ['1in', '2in'], y: 300, width: '1in', height: '1in' }
98
98
  box.load!(args, expand_by: 2)
99
99
  expect(box).to have_attributes(
100
100
  x: [300, 600],
@@ -108,7 +108,7 @@ describe Squib::Args::Box do
108
108
 
109
109
  context 'validation' do
110
110
  it 'replaces with deck width and height' do
111
- args = {width: :deck, height: :deck}
111
+ args = { width: :deck, height: :deck }
112
112
  deck = OpenStruct.new(width: 123, height: 456)
113
113
  box = Squib::Args::Box.new(deck)
114
114
  box.load!(args, expand_by: 1)
@@ -116,7 +116,7 @@ describe Squib::Args::Box do
116
116
  end
117
117
 
118
118
  it 'has radius override x_radius and y_radius' do
119
- args = {x_radius: 1, y_radius: 2, radius: 3}
119
+ args = { x_radius: 1, y_radius: 2, radius: 3 }
120
120
  box.load!(args, expand_by: 2)
121
121
  expect(box).to have_attributes(x_radius: [3, 3], y_radius: [3, 3])
122
122
  end
@@ -2,13 +2,13 @@ require 'spec_helper'
2
2
  require 'squib/args/draw'
3
3
 
4
4
  describe Squib::Args::Draw do
5
- let(:custom_colors) { {'foo' => 'abc'} }
5
+ let(:custom_colors) { { 'foo' => 'abc' } }
6
6
  subject(:draw) {Squib::Args::Draw.new(custom_colors)}
7
7
 
8
8
  context 'unit conversion' do
9
9
 
10
10
  it 'converts units on stroke width' do
11
- args = {stroke_width: '2in'}
11
+ args = { stroke_width: '2in' }
12
12
  draw.load!(args, expand_by: 2)
13
13
  expect(draw).to have_attributes(stroke_width: [600, 600])
14
14
  end
@@ -16,11 +16,11 @@ describe Squib::Args::Draw do
16
16
  end
17
17
 
18
18
  context 'dsl overrides' do
19
- subject(:draw) {Squib::Args::Draw.new(custom_colors, {stroke_width: 0.0})}
19
+ subject(:draw) {Squib::Args::Draw.new(custom_colors, { stroke_width: 0.0 })}
20
20
 
21
21
  it 'works when specified' do
22
22
  draw.load!({}) # go right to defaults
23
- expect(draw.stroke_width).to eq( [0.0] ) #ordinarily a non-zero according
23
+ expect(draw.stroke_width).to eq([0.0]) # ordinarily a non-zero according
24
24
  end
25
25
 
26
26
  end
@@ -28,7 +28,7 @@ describe Squib::Args::Draw do
28
28
  context 'validation' do
29
29
 
30
30
  it 'converts to Cairo options' do
31
- args = {join: 'bevel', cap: 'round'}
31
+ args = { join: 'bevel', cap: 'round' }
32
32
  draw.load!(args)
33
33
  expect(draw).to have_attributes(
34
34
  join: [Cairo::LINE_JOIN_BEVEL],
@@ -37,62 +37,62 @@ describe Squib::Args::Draw do
37
37
  end
38
38
 
39
39
  it 'parses dash options' do
40
- args = {dash: '3 4 5'}
40
+ args = { dash: '3 4 5' }
41
41
  draw.load!(args)
42
42
  expect(draw).to have_attributes(dash: [[3, 4, 5]])
43
43
  end
44
44
 
45
45
  it 'parses more complex dash options' do
46
- args = {dash: '30.5, 90, 5'}
46
+ args = { dash: '30.5, 90, 5' }
47
47
  draw.load!(args)
48
48
  expect(draw).to have_attributes(dash: [[30.5, 90, 5]])
49
49
  end
50
50
 
51
51
  it 'does unit conversion on dash options' do
52
- args = {dash: '3in 4in 5in'}
52
+ args = { dash: '3in 4in 5in' }
53
53
  draw.load!(args)
54
54
  expect(draw).to have_attributes(dash: [[900, 1200, 1500]])
55
55
  end
56
56
 
57
57
  it 'converts line caps to Cairo constants' do
58
- args = {cap: :SQUARE}
58
+ args = { cap: :SQUARE }
59
59
  draw.load! args
60
- expect(draw).to have_attributes( cap: [Cairo::LINE_CAP_SQUARE] )
60
+ expect(draw).to have_attributes(cap: [Cairo::LINE_CAP_SQUARE])
61
61
  end
62
62
 
63
63
  it 'converts line join' do
64
- args = {join: 'round'}
64
+ args = { join: 'round' }
65
65
  draw.load! args
66
- expect(draw).to have_attributes( join: [Cairo::LINE_JOIN_ROUND] )
66
+ expect(draw).to have_attributes(join: [Cairo::LINE_JOIN_ROUND])
67
67
  end
68
68
 
69
69
  it 'allows fill_first stroke_strategy' do
70
- args = {stroke_strategy: :FILL_first}
70
+ args = { stroke_strategy: :FILL_first }
71
71
  draw.load! args
72
- expect(draw).to have_attributes( stroke_strategy: [:fill_first] )
72
+ expect(draw).to have_attributes(stroke_strategy: [:fill_first])
73
73
  end
74
74
 
75
75
  it 'allows stroke_first stroke_strategy' do
76
- args = {stroke_strategy: ' stroke_FIRST '}
76
+ args = { stroke_strategy: ' stroke_FIRST ' }
77
77
  draw.load! args
78
- expect(draw).to have_attributes( stroke_strategy: [:stroke_first] )
78
+ expect(draw).to have_attributes(stroke_strategy: [:stroke_first])
79
79
  end
80
80
 
81
81
  it 'disallows anything not stroke_first and fill_first' do
82
- args = {stroke_strategy: 'foo'}
82
+ args = { stroke_strategy: 'foo' }
83
83
  expect { draw.load! args }.to raise_error("Only 'stroke_first' or 'fill_first' allowed")
84
84
  end
85
85
 
86
86
  context 'custom colors' do
87
87
 
88
88
  it 'looks up custom colors in the config' do
89
- draw.load!({color: 'foo'})
89
+ draw.load!({ color: 'foo' })
90
90
  expect(draw.color).to eq ['abc']
91
91
  end
92
92
 
93
93
  it 'passes on through for non-custom color' do
94
94
  draw = Squib::Args::Draw.new(custom_colors)
95
- draw.load!({color: 'bar'})
95
+ draw.load!({ color: 'bar' })
96
96
  expect(draw.color).to eq ['bar']
97
97
  end
98
98
 
@@ -1,13 +1,13 @@
1
- require 'spec_helper'
2
- require 'squib/args/embed_key'
3
-
4
- describe Squib::Args::EmbedKey do
5
-
6
- context '#validate_key' do
7
-
8
- it 'converts to string' do
9
- expect(subject.validate_key(2.5)).to eq ('2.5')
10
- end
11
-
12
- end
13
- end
1
+ require 'spec_helper'
2
+ require 'squib/args/embed_key'
3
+
4
+ describe Squib::Args::EmbedKey do
5
+
6
+ context '#validate_key' do
7
+
8
+ it 'converts to string' do
9
+ expect(subject.validate_key(2.5)).to eq ('2.5')
10
+ end
11
+
12
+ end
13
+ end
@@ -7,13 +7,13 @@ describe Squib::Args::InputFile do
7
7
  context 'validate_file' do
8
8
 
9
9
  it 'allows a file if it exists' do
10
- args = {file: __FILE__} # I code therefore I am.
10
+ args = { file: __FILE__ } # I code therefore I am.
11
11
  ifile.load!(args, expand_by: 1)
12
12
  expect(ifile).to have_attributes(file: [File.expand_path(__FILE__)])
13
13
  end
14
14
 
15
15
  it 'raises on non-existent file' do
16
- args = {file: 'foo.rb'}
16
+ args = { file: 'foo.rb' }
17
17
  expect { ifile.load!(args, expand_by: 1) }.to raise_error("File #{File.expand_path('foo.rb')} does not exist!")
18
18
  end
19
19
 
@@ -2,21 +2,21 @@ require 'spec_helper'
2
2
  require 'squib/args/paint'
3
3
 
4
4
  describe Squib::Args::Draw do
5
- let(:custom_colors) { {'foo' => 'abc'} }
6
- subject(:paint) {Squib::Args::Paint.new(custom_colors)}
5
+ let(:custom_colors) { { 'foo' => 'abc' } }
6
+ subject(:paint) {Squib::Args::Paint.new(custom_colors)}
7
7
 
8
8
  context 'alpha' do
9
9
 
10
10
  it 'can be a float' do
11
- args = {alpha: 0.6}
11
+ args = { alpha: 0.6 }
12
12
  paint.load!(args)
13
13
  expect(paint.alpha).to eq [0.6]
14
14
  end
15
15
 
16
16
  it 'raises exception when not a float' do
17
- args = {alpha: /6/}
17
+ args = { alpha: /6/ }
18
18
  expect { paint.load!(args) }.to raise_error('alpha must respond to to_f')
19
19
  end
20
20
 
21
21
  end
22
- end
22
+ end