squib 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: adaeb3ca2f3b20094dacf000a6e584966fce017a
4
- data.tar.gz: f1def218de468cbcb268253d8d6b60ccb74b4dec
3
+ metadata.gz: 7d352d3f397797d5323516d286625b34e36854b5
4
+ data.tar.gz: ec3b155d2e22a1d286322ac7d780d08a10fd7ac7
5
5
  SHA512:
6
- metadata.gz: c66f623177f31a1d51974fa9e51ccc53f90186a98de5500235d297d0bab120a187e251a7f029a2b7cc018df276ca07022c9846c85b3612f10c929d8cef2ae06b
7
- data.tar.gz: 4367598eeb9c8e77b79254194308d36e135f992ac65aa8d46e1f001660e408266fb4a1ae451b4e404bba2c1aeed2a1b57267b8a6ca6323d77a55a9832ce36641
6
+ metadata.gz: a5159194a72709ebe44fb510b63834384c0a10b6201404b0d3b04af2f27b37ed4b6ebcc3b9a9c8bcb13e80f5928e7db4b4f2208cb4c75614fc8535ccf9650cc9
7
+ data.tar.gz: 14453ebabd751dc7c2a8f2fcaae46fcdeb07bc496c784cb0165b46da466722256ce6f35db23a9a25b97241910683e5772369ec9eda59c0f1e900b5c806a145d3
data/.gitignore CHANGED
@@ -9,6 +9,7 @@ Gemfile.lock
9
9
  InstalledFiles
10
10
  _yardoc
11
11
  coverage
12
+ docs/_build*
12
13
  doc/
13
14
  lib/bundler/man
14
15
  pkg
@@ -34,4 +35,4 @@ benchmarks/_output/
34
35
  samples/_output/*.svg
35
36
  *.sublime-workspace
36
37
  spec/samples/sanity.html
37
- spec/samples/_diffs/*.png
38
+ spec/samples/_diffs/*.png
data/.gitmodules CHANGED
@@ -12,3 +12,25 @@
12
12
  [submodule "samples/autoscale_font"]
13
13
  path = samples/autoscale_font
14
14
  url = https://gist.github.com/andymeneely/a4536fff0f3dc5d59c66
15
+ [submodule "samples/build_groups"]
16
+ path = samples/build_groups
17
+ url = https://gist.github.com/andymeneely/bda48487e3b8c9d15edb
18
+
19
+ [submodule "samples/backend"]
20
+ path = samples/backend
21
+ url = https://gist.github.com/7b4a3acd0e758aedf87ba549e2025a11.git
22
+
23
+ [submodule "samples/shapes"]
24
+ path = samples/shapes
25
+ url = https://gist.github.com/59089c972b8b0e5d7e76598010e69291.git
26
+
27
+ [submodule "samples/saves"]
28
+ path = samples/saves
29
+ url = https://gist.github.com/3c60c13b25f525abd037db4055abf35c.git
30
+
31
+ [submodule "samples/data"]
32
+ path = samples/data
33
+ url = https://gist.github.com/6f89115805e205c647a779b7b4866151.git
34
+ [submodule "samples/colors"]
35
+ path = samples/colors
36
+ url = https://gist.github.com/fac2f4a16a23c2bada126e93d6523971.git
data/.travis.yml CHANGED
@@ -1,11 +1,10 @@
1
+ dist: trusty
1
2
  language: ruby
2
3
  sudo: false # taking advantage of container-based infrastructure
3
- cache: bundler # maybe someday they'll add support for us freeloaders...
4
+ cache: bundler # cache bundled gems from build to build
4
5
  rvm:
5
- - 2.0
6
- - 2.1
7
6
  - 2.2
8
- - 2.3
7
+ - 2.3.0
9
8
  matrix:
10
9
  allow_failures:
11
- - rvm: 2.3
10
+ - rvm: 2.3.0
data/CHANGELOG.md CHANGED
@@ -1,6 +1,27 @@
1
1
  # Squib CHANGELOG
2
2
  Squib follows [semantic versioning](http://semver.org).
3
3
 
4
+ ## v0.10.0 / Unreleased
5
+
6
+ Features:
7
+ * Build groups! Simplify the process of building your deck different ways (e.g. one for color, one for PNP). Can be enabled explicitly or via command line. [See our shiny new docs for how these work](http://squib.readthedocs.org/en/latest/build_groups.html).
8
+ * New `use_layout` method will allow you to load a layout file as a DSL method instead of in the constructor. Useful in conjunction with build groups! (#141)
9
+ * The `csv` method now supports a `data` option to read CSV data directly. When set, it overrides the `file` option.
10
+ * The `csv` method now supports all of the Ruby CSV options (e.g. `col_sep`, `quote_char`). These options simply get passed through to Ruby, so as they change in Ruby, so the support changes in Squib (#149). Special thanks to Qgel's initial pull request (#146).
11
+ * The `csv` method now supports a block that it yields to for each element for pre-processing data (#145). Oh and `xlsx` has had that functionality for a while now, and now it's actually documented (#151).
12
+ * Rewrote the entire API doc and placed it on [squib.readthedocs.org](http://squib.readthedocs.org). :tada:
13
+
14
+ Bugs:
15
+ * The `save_pdf` method will flush to file upon exit so that the PDF is available immediately. (#150, thanks for the bug report Qgel!)
16
+ * The `text` embedding now supports both stroke-n-fill operations AND embedded images (#103 - aka "andy's nemesis"). Also: no more bizzare zero-sized fonts that made your OS secretly cry in the corner every time you embedded an image (#153).
17
+
18
+ Chores:
19
+ * Switched to `require_relative` internally throughout the codebase to be more pry-friendly (#130)
20
+ * Bumped dependency ruby-progressbar to 1.8.
21
+
22
+ Compatibility:
23
+ * Upgraded Cairo from 1.14.3 to 1.15.2. With this change, Squib no longer supports Ruby <= 2.1.
24
+
4
25
  ## v0.9.0 / 2016-01-10
5
26
 
6
27
  Features:
@@ -27,6 +48,8 @@ Docs:
27
48
  Community:
28
49
  * Beta testers needed!! Want to test pre-release of Squib? Join the mailing list for announcements. Go ahead and join our Google Group: https://groups.google.com/forum/#!forum/squib-testers
29
50
 
51
+ Special thanks to testing and bug reporting from programmingisgoo and bcompter!
52
+
30
53
  ## v0.8.0 / 2015-10-26
31
54
  Features
32
55
  * The `xlsx` and `csv` support quantity explosion! Just use the column name 'Qty' and put integers in your sheet and you'll produce copies of the entire row. See README and the csv sample for more info. (#78)
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,40 @@
1
+ # Contributing to Squib
2
+
3
+ Please use GitHub issues for bugs and feature requests.
4
+
5
+ ## Need Help?
6
+
7
+ There are lots of people using Squib already. If you've gone through the [samples](https://github.com/andymeneely/squib/tree/master/samples) and still have questions, here are some other places to get help.
8
+
9
+ * [StackOverflow](http://stackoverflow.com/questions/ask?tags=ruby squib) with the tag "ruby" and "squib" will get you answers quickly and a great way to document questions for future Squibbers.
10
+ * Our [thread on BoardGameGeek](http://boardgamegeek.com/thread/1293453) is quite active and informal (if a bit unstructured).
11
+
12
+ If you email me directly I'll probably ask you to post your question publicly so we can document answers for future Googling Squibbers.
13
+
14
+ ## Pull Requests
15
+
16
+ If you are contributing a new feature:
17
+ * Keep your change small and atomic. Do significant refactoring in a separate pull request.
18
+ * Please write a sample demonstrating your new feature. Place it in the samples/ directory
19
+ * While your pull request is open, please keep it up to date with the `dev` branch so it can be easily integrated
20
+ * We (sort of) follow [these Ruby style guidelines](https://github.com/bbatsov/ruby-style-guide)
21
+
22
+ ## Get Involved in the Community
23
+
24
+ Let's help each other out! Even if you're relatively new, there's probably some question out there that you can help answer. Here's how to help:
25
+
26
+ * Subscribe to our thread on BoardGameGeek (see above for link)
27
+ * Subscribe to alerts from Stackoverflow for the tags "squib" and "ruby"
28
+ * Post snippets of your code using GitHub gists
29
+ * Write a how-to tutorial and post it on [our wiki](https://github.com/andymeneely/squib/wiki)
30
+
31
+ ## Testing Pre-Builds
32
+
33
+ Testers needed!! If you want to test new features as I develop them, or make sure I didn't break your code, you can always point your Gemfile to the repository and follow what I'm doing there. Your Gemfile specification looks like this:
34
+
35
+ ```ruby
36
+ gem 'squib', git: 'git://github.com/andymeneely/squib', branch: 'dev'
37
+ ```
38
+ * The `dev` branch is where I am working on features in-process. I have not done much regression testing at this point, but would love testing feedback nonetheless.
39
+ * The `master` branch is where I consider features and bug that are done and tested, but not released yet.
40
+ * Use `bundle exec` to execute your code (e.g. `bundle exec rake` or `bundle exec ruby deck.rb`). See [Bundler](http://bundler.io) for more info.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Squib [![Gem Version](https://badge.fury.io/rb/squib.svg)](https://rubygems.org/gems/squib) [![Build Status](https://secure.travis-ci.org/andymeneely/squib.svg?branch=master)](https://travis-ci.org/andymeneely/squib) [![Vey][vey]][vey_url] [![Dependency Status](https://gemnasium.com/andymeneely/squib.svg)](https://gemnasium.com/andymeneely/squib) [![Coverage Status](https://img.shields.io/coveralls/andymeneely/squib.svg)](https://coveralls.io/r/andymeneely/squib) [![Inline docs](http://inch-ci.org/github/andymeneely/squib.png?branch=master)](http://inch-ci.org/github/andymeneely/squib)
1
+ # Squib [![Gem Version](https://badge.fury.io/rb/squib.svg)](https://rubygems.org/gems/squib) [![Build Status](https://secure.travis-ci.org/andymeneely/squib.svg?branch=master)](https://travis-ci.org/andymeneely/squib) [![Vey][vey]][vey_url] [![Dependency Status](https://gemnasium.com/andymeneely/squib.svg)](https://gemnasium.com/andymeneely/squib) [![Coverage Status](https://img.shields.io/coveralls/andymeneely/squib.svg)](https://coveralls.io/r/andymeneely/squib) [![ReadTheDocs](https://readthedocs.org/projects/squib/badge/?version=latest)](http://squib.readthedocs.org) [![BoardGameGeek](https://cdn.rawgit.com/andymeneely/squib/gh-pages/images/microbadge.png)](https://boardgamegeek.com/guild/2601)
2
2
  Squib is a Ruby [DSL](http://en.wikipedia.org/wiki/Domain-specific_language) for prototyping card and board games. Write a little bit of Ruby, define your deck's stats, then compile your game into a series of images ready for print-and-play or even print-on-demand. Squib is very data-driven and built on the principle of Don't Repeat Yourself. Think of it like [nanDeck](http://www.nand.it/nandeck/) done "the Ruby way". Squib supports:
3
3
 
4
4
  [vey]: https://ci.appveyor.com/api/projects/status/github/andymeneely/squib?svg=true
@@ -29,6 +29,8 @@ end
29
29
 
30
30
  We just created a 2-card deck with "Hello" on the first card, and "World" on the second, and saved them out to PNGs.
31
31
 
32
+ Wanna see more? Check out the website: http://andymeneely.github.io/squib/
33
+
32
34
  ## Installation
33
35
 
34
36
  Squib requires Ruby 2.0 or later.
@@ -45,11 +47,8 @@ And then execute:
45
47
 
46
48
  $ bundle
47
49
 
48
- Note: Squib has some native dependencies, such as [Cairo](https://github.com/rcairo/rcairo), [Pango](http://ruby-gnome2.sourceforge.jp/hiki.cgi?Pango%3A%3ALayout), and [Nokogiri](http://nokogiri.org/), which may require compiling C code to install. This is usually not painful at all, and is automated through Bundler/RubyGems, but can cause headaches on some setups.
49
- * Windows: I recommend using the *non-64 bit* RubyInstaller at http://rubyinstaller.org. Some installations will also need DevKit. Currently, Ruby 2.2 on Windows conflicts with one of Squib's dependencies called Nokogiri (read the WTF-y issue here: https://github.com/sparklemotion/nokogiri/issues/1256) UPDATE: their pre-releases have fixed this exact issue - just install nokogiri-1.6.7.rc3-x64-mingw32 (or higher). Or, as a last resort, use 2.1 or 2.0 for Windows users.
50
- * Mac: I recommend using [rvm](https://rvm.io). Some users have reported that Ruby 2.1 will not work with Mac OSX 10.10.4 (#88) - Ruby 2.0 and 2.2 are confirmed to work however (this is an rcairo issue, not a Squib issue).
51
- * Cywgin is not supported, but could theoretically work with extra installation steps. See [this thread](http://boardgamegeek.com/article/18508113#18508113). Contributions in this area are welcome.
52
- * Linux. No known installation issues. Happy installing!
50
+ More info: http://squib.readthedocs.org/en/latest/install.html
51
+
53
52
 
54
53
  ## Getting Started
55
54
 
@@ -64,448 +63,33 @@ $ ruby deck.rb
64
63
  The `squib new` command will generate files and folders like this:
65
64
 
66
65
  ```
67
- _output/gitkeep.txt
68
- .gitignore
69
- ABOUT.md
70
- config.yml
71
- deck.rb
72
- Gemfile
73
- layout.yml
74
- PNP NOTES.md
75
- ```
76
-
77
- The central file here is `deck.rb`. Here's a [basic example](https://github.com/andymeneely/squib/tree/master/samples/basic.rb) of a deck to work from:
66
+ ├── .gitignore
67
+ ├── ABOUT.md
68
+ ├── Gemfile
69
+ ├── IDEAS.md
70
+ ├── PLAYTESTING.md
71
+ ├── PNP NOTES.md
72
+ ├── RULES.md
73
+ ├── Rakefile
74
+ ├── _output
75
+ │   └── gitkeep.txt
76
+ ├── config.yml
77
+ ├── deck.rb
78
+ └── layout.yml
78
79
 
79
- {include:file:samples/basic.rb basic.rb}
80
+ 12 files
81
+ ```
80
82
 
81
- About the other files:
82
- * `Gemfile` is for adding in other gems if you are using `bundler`
83
- * `config.yml` is a skeleton config file with various options commented out. See {file:README.md#Configuration_File Configuration File}.
84
- * `layout.yml` is a skeleton layout file if you want to use it. See {file:README.md#Custom_Layouts Custom Layouts}.
85
- * `_output` is the directory where your built files will go. Can easily be changed, of course.
86
- * `.gitignore` and `gitkeep.txt` are for if you are using Git. See {file:README.md#Source_control Source control}. (Feel free to remove these if you are not using Git.)
87
- * `ABOUT.md` and `PHP NOTES.md` are Markdown files for posting. Not used by Squib, but there by convention.
88
- * `Rakefile` is a basic build file. Not required but handy - see {file:README.md#Rakefile Rakefile}
89
83
 
90
84
  # Learning Squib
91
85
 
92
- In addition to this README, be sure to also check out the following resources for more details:
86
+ Go [read the docs!](http://squib.readthedocs.org/)
93
87
 
88
+ Also:
94
89
  * The `samples` directory in the [source repository](https://github.com/andymeneely/squib) has lots of examples.
95
- * [Iconoclast](https://github.com/andymeneely/iconoclast) is a basic set collection game I'm developing from scratch with Squib. Be sure to read the [commit history](https://github.com/andymeneely/iconoclast/commits/master) to see how the game has developed from scratch.
96
90
  * [Junk Land](https://github.com/andymeneely/junk-land) is my own creation that's uses Squib for full-color rendering, and makes use of Ruby in a lot of interesting ways.
91
+ * [Project Spider Monkey](https://github.com/andymeneely/project-spider-monkey) is another of my own creations. This one was started from scratch with Squib.
97
92
 
98
- ## Viewing this README
99
-
100
- The best place to read this documentation is on [our website](http://andymeneely.github.io/squib/doc). Be sure to check out the method-by-method documentation, particularly for the [Deck](Squib/Deck.html) class.
101
-
102
- If you want to view it offline, you can do the following
103
-
104
- ```sh
105
- $ gem install yard
106
- $ yard server --gems
107
- ```
108
- Then go to [http://localhost:8808/docs/squib/file/README.md](http://localhost:8808/docs/squib/file/README.md)
109
-
110
- If you're viewing this on Github, you might see some confusing tags like `{include:file:...}` - these are directives for YARD to show the embedded examples. Github doesn't render those and you might find them helpful.
111
-
112
- Also, RubyDoc.info linked from RubyGems appears to be perpetually broken and doesn't support `{include:file...}` directive properly, so the embedded samples will also not show up there, either.
113
-
114
- ## Squib Decks and Cards
115
-
116
- The Squib DSL is based on a collection of methods provided to the `Squib::Deck` class. The general philosophy of Squib is to specify as little as possible with layers of defaults, highly flexible input, and good ol' Ruby duck-typing. Ruby does a lot to make Squib useful.
117
-
118
- Squib essentially has two main classes: `Deck` and `Card`. `Deck` is the front-end, and `Card` is the back-end. The contract of `Deck` is to do the various manipulations of options and then delegate the operation to `Card` to do the low-level graphical operations.
119
-
120
- For most users, I recommending solely using `Deck` methods. If you want to roll up your sleeves and get your hands messy, you can access the Cairo or Pango contexts the directly via the `Card` class. The API documentation doesn't really cover these, however, so you're on your own there.
121
-
122
- ## Specifying Parameters
123
-
124
- Squib is all about sane defaults and shorthand specification. Arguments are almost always using hashes, which look a lot like [Ruby 2.0's named parameters](http://www.ruby-doc.org/core-2.0.0/doc/syntax/calling_methods_rdoc.html#label-Keyword+Arguments). This means you can specify your parameters in any order you please. All parameters are optional. For example `x` and `y` default to 0 (i.e. the upper-left corner of the card). Any parameter that is specified in the command overrides any Squib defaults, `config.yml` settings, or layout rules.
125
-
126
- Note: you MUST use named parameters rather than positional parameters. For example: `save :png` will lead to an error like this:
127
-
128
- C:/Ruby200/lib/ruby/gems/2.0.0/gems/squib-0.0.3/lib/squib/api/save.rb:12:in `save': wrong number of arguments (2 for 0..1) (ArgumentError)
129
- from deck.rb:22:in `block in <main>'
130
- from C:/Ruby200/lib/ruby/gems/2.0.0/gems/squib-0.0.3/lib/squib/deck.rb:60:in `instance_eval'
131
- from C:/Ruby200/lib/ruby/gems/2.0.0/gems/squib-0.0.3/lib/squib/deck.rb:60:in `initialize'
132
- from deck.rb:18:in `new'
133
- from deck.rb:18:in `<main>'
134
-
135
- Instead, you must name the parameters: `save format: :png`
136
-
137
- ## Arrays and Singleton Expansion
138
-
139
- Many inputs to Squib can accept `Arrays`, which correspond to the entire deck. In fact, under the hood, if Squib is _not_ given an array, it expands it out to an array before rendering. This allows for different styles to apply to different cards. This example comes from the [ranges.rb example](https://github.com/andymeneely/squib/tree/master/samples/ranges.rb)
140
-
141
- ```ruby
142
- # This renders three cards, with three strings that had three different colors at three different locations.
143
- text str: %w(red green blue),
144
- color: [:red, :green, :blue],
145
- x: [40, 80, 120],
146
- y: [700, 750, 800]
147
- ```
148
-
149
- Under the hood, Squib actually views every argument as applied each card individually. If a single argument is given to the command, it's considered a singleton that gets expanded into a deck-sized array. Supplying the array bypasses that expansion - which means that any array you supply instead of a singleton ought to be the same size as the deck and align the same way the indexes in the supplied `range` are. If you don't, Ruby will fill that up with nils and not apply the rule across those cards.
150
-
151
- ## Specifying Ranges
152
-
153
- Most public `Deck` methods allow a `range` to be specified as a first parameter. This parameter is used to access an internal `Array` of `Squib::Cards`. This can be an actual Ruby range, or anything that implements `#each` (thus can be an `Enumerable`). Integers are also supported for changing one card only. Negatives work from the back of the deck. Here are some examples from `samples/ranges.rb` found [here](https://github.com/andymeneely/squib/tree/master/samples/ranges.rb)
154
-
155
- {include:file:samples/ranges.rb}
156
-
157
- ## Units
158
-
159
- By default, Squib thinks in pixels. This decision was made so that we can have pixel-perfect layouts without automatically scaling everything, even though working in units is sometimes easier. We provide some conversion methods, including looking for strings that end in "in" and "cm" and computing based on the current DPI. The dpi is set on `Squib::Deck.new` (not `config.yml`). Example is in `samples/units.rb` found [here](https://github.com/andymeneely/squib/tree/master/samples/units.rb)
160
-
161
- {include:file:samples/units.rb}
162
-
163
- ## Specifying Colors & Gradients
164
-
165
- Colors can be specified in a wide variety of ways, mostly in a hex-string. Take a look at the examples from `samples/colors.rb`, found [here](https://github.com/andymeneely/squib/tree/master/samples/colors.rb)
166
-
167
- {include:file:samples/colors.rb}
168
-
169
- Under the hood, Squib uses the `rcairo` [color parser](https://github.com/rcairo/rcairo/blob/master/lib/cairo/color.rb) to accept a variety of color specifications, along with over [300 pre-defined constants](https://github.com/rcairo/rcairo/blob/master/lib/cairo/colors.rb). The above sample will generate a table of such constants.
170
-
171
- Additionally, in most places where colors are allowed, you may also supply a string that defines a gradient. Squib supports two flavors of gradients: linear and radial. Gradients are specified by supplying some xy coordinates, which are relative to the card (not the command). Each stop must be between 0.0 and 1.0, and you can supply as many as you like. Colors can be specified as above (in any of the hex notations or built-in constant). If you add two (or more) colors at the same stop, then the gradient keeps the colors in the in order specified and treats it like sharp transition.
172
-
173
- The format for gradient strings look like this:
174
-
175
- Linear:
176
- ```
177
- (x1,y1)(x2,y2) color1@stop1 color2@stop2
178
- ```
179
- The xy coordinates define the angle of the gradient.
180
-
181
- Radial:
182
- ```
183
- (x1,y1,radius1)(x2,y2,radius2) color1@stop1 color2@stop2
184
- ```
185
- The coordinates specify an inner circle first, then an outer circle.
186
-
187
- Check out the following sample from `samples/gradients.rb`, found [here](https://github.com/andymeneely/squib/tree/master/samples/colors.rb)
188
-
189
- {include:file:samples/gradients.rb}
190
-
191
- ## Specifying Files
192
-
193
- All files opened for reading or writing (e.g. for `png` and `xlsx`) are opened relative to the current directory. Files opened for writing (e.g. for `save_png`) will be overwritten without warning.
194
-
195
- If you find that you `cd` a lot while working on the command line, your `_output` folder might get generated in multiple places. An easy way to fix this is to use a `Rakefile`, [see below](#Rakefile)
196
-
197
- ## Working with Text
198
- The `text` method is a particularly powerful method with a ton of options. Be sure to check the [API docs](/squib/doc/Squib/Deck#text-instance_method) on an option-by-option discussion, but here are the highlights.
199
-
200
- ###Fonts.
201
-
202
- To set the font, your `text` method call will look something like this:
203
-
204
- ```ruby
205
- text str: "Hello", font: 'MyFont Bold 32'
206
- ```
207
-
208
- The `'MyFont Bold 32'` is specified as a "Pango font string", which can involve [a lot of options](http://ruby-gnome2.osdn.jp/hiki.cgi?Pango%3A%3AFontDescription#Pango%3A%3AFontDescription.new) including backup font families, size, all-caps, stretch, oblique, italic, and degree of boldness. (These options are only available if the underlying font supports them, however.) Here's are some `text` calls with different Pango font strings:
209
-
210
- ```
211
- text str: "Hello", font: 'Sans 18'
212
- text str: "Hello", font: 'Arial,Verdana weight=900 style=oblique 36'
213
- text str: "Hello", font: 'Times New Roman,Sans 25'
214
- ```
215
-
216
- Note: When the font has a space in the name (e.g. Times New Roman), you'll need to put a backup to get Pango's parsing to work.
217
-
218
- It's also important to note that most of the font rendering is done by a combination of your installed fonts, your OS, and your graphics card. Thus, different systems will render text slightly differently.
219
-
220
- Fonts can also be set globally using the `set` method. For example:
221
-
222
- ```
223
- set font: 'Arial 26'
224
- text str: 'blah' # in Arial 26
225
- ```
226
-
227
- Furthermore, Squib's `text` method has options such as `font_size` that allow you to override the font string. This means that you can set a blanket font for the whole deck, then adjust sizes from there. This is useful with layouts and `extends` too.
228
-
229
- ### Width and Height
230
-
231
- By default, Pango text boxes will scale the text box to whatever you need, hence the `:native` default. However, for most of the other customizations to work (e.g. center-aligned) you'll need to specify the width. If both the width and the height are specified and the text overflows, then the `ellipsize` option is consulted to figure out what to do with the overflow. Also, the `valign` will only work if `height` is also set to something other than `:native`.
232
-
233
- ###Hints
234
-
235
- Laying out text by typing in numbers can be confusing. What Squib calls "hints" is merely a rectangle around the text box. Hints can be turned on globally in the config file, using the `set` method, or in an individual text method. These are there merely for prototyping and are not intended for production. Additionally, these are not to be conflated with "rendering hints" that Pango and Cairo mention in their documentation.
236
-
237
- ###Extents
238
-
239
- Sometimes you want size things based on the size of your rendered text. For example, drawing a rectangle around card's title such that the rectangle perfectly fits. Squib returns the final rendered size of the text so you can work with it afterward. It's an array of hashes that correspond to each card. The output looks like this:
240
-
241
- ```ruby
242
- Squib::Deck.new(cards: 2) do
243
- extents = text(str: ['Hello', 'World!'])
244
- p extents
245
- end
246
- ```
247
- Will output:
248
- ```
249
- [{:width=>109, :height=>55}, {:width=>142, :height=>55}] # Hello was 109 pixels wide, World 142 pixels
250
- ```
251
-
252
- ###Embedding Images
253
-
254
- Squib can embed icons into the flow of text. To do this, you need to define text keys for Squib to look for, and then the corresponding files. The object given to the block is a [TextEmbed](docs/Squib/TextEmbed), which supports PNG and SVG. Here's a minimal example:
255
-
256
- ```ruby
257
- text(str: 'Gain 1 :health:') do |embed|
258
- embed.svg key: ':health:', file: 'heart.svg'
259
- end
260
- ```
261
-
262
- ###Markup
263
-
264
- If you want to do specialized formatting within a given string, Squib has lots of options. By setting `markup: true`, you enable tons of text processing. This includes:
265
-
266
- * Pango Markup. This is an HTML-like formatting language that specifies formatting inside your string. Pango Markup essentially supports any formatting option, but on a letter-by-letter basis. Such as: font options, letter spacing, gravity, color, etc. See the [Pango docs](https://developer.gnome.org/pango/stable/PangoMarkupFormat.html) for details.
267
- * Quotes are converted to their curly counterparts where appropriate (i.e. &ldquo;smart quotes&rdquo; instead of "straight quotes").
268
- * Apostraphes are converted to curly as well.
269
- * LaTeX-style quotes are explicitly converted (<tt>``like this''</tt>)
270
- * Em-dash and en-dash are converted with triple and double-dashes respectively (<tt>--</tt> is an en-dash, and <tt>---</tt> becomes an em-dash.)
271
- * Ellipses can be specified with <tt>...</tt>. Note that this is entirely different from the `ellipsize` option (which determines what to do with overflowing text).
272
-
273
- A few notes:
274
- * Smart quoting assumes the UTF-8 character set.
275
- * Pango markup uses an XML/HTML-ish processor. Some characters require HTML-entity escaping (e.g. `&amp;` for `&')
276
-
277
- ### Text Sample
278
- ```yaml
279
- lsquote: "\u2018" #note that Yaml wants double quotes here to use escape chars
280
- rsquote: "\u2019"
281
- ldquote: "\u201C"
282
- rdquote: "\u201D"
283
- em_dash: "\u2014"
284
- en_dash: "\u2013"
285
- ellipsis: "\u2026"
286
- ```
287
-
288
- You can also disable the auto-quoting mechanism by setting `smart_quotes: false` in your config. Explicit replacements will still be performed.
289
-
290
- ### Text Samples
291
-
292
- Examples of all of the above are crammed into the `text_options.rb` sample [found here](https://github.com/andymeneely/squib/tree/master/samples/text_options.rb).
293
-
294
- {include:file:samples/text_options.rb}
295
-
296
- The `embed_text.rb` sample has more examples of embedding text, which can be [found here](https://github.com/andymeneely/squib/tree/master/samples/embed_text.rb).
297
-
298
- {include:file:samples/embed_text.rb}
299
-
300
- The `config_text_markup.rb` sample demonstrates how quoting can be configured, [found here](https://github.com/andymeneely/squib/tree/master/samples/config_text_markup.rb)
301
-
302
- {include:file:samples/config_text_markup.rb}
303
-
304
-
305
- ## Custom Layouts
306
-
307
- Working with x-y coordinates all the time can be tiresome, and ideally everything in a game prototype should be data-driven and easily changed. For this, many Squib methods allow for a `layout` to be set. In essence, layouts are a way of setting default values for any argument given to the command.
308
-
309
- To use a layout, set the `layout:` option on a `Deck.new` command to point to a YAML file. Any command that allows a `layout` option can be set with a Ruby symbol or String, and the command will then load the specified `x`, `y`, `width`, and `height`. The individual command can also override these options.
310
-
311
- Instead of this:
312
- ```ruby
313
- # deck.rb
314
- Squib::Deck.new(layout: 'custom-layout.yml') do
315
- rect x: 75, y: 75, width: 675, height: 975
316
- end
317
- ```
318
-
319
- You can put your logic in the layout file and reference them:
320
- ```yaml
321
- # custom-layout.yml
322
- frame:
323
- x: 75
324
- y: 75
325
- width: 975
326
- height: 675
327
- ```
328
- Then your script looks like this:
329
- ```ruby
330
- # deck.rb
331
- Squib::Deck.new(layout: 'custom-layout.yml') do
332
- rect layout: 'frame'
333
- end
334
- ```
335
- The goal is to make your Ruby code more separate data from logic, which in turn makes your code more readable and maintainable. With `extends` (see below), layouts become even more powerful in keeping you from repeating yourself.
336
-
337
- Note: YAML is very finnicky about not allowing tab characters. Use two spaces for indentation instead. If you get a `Psych` syntax error, this is likely the culprit. Indendation is also strongly enforced in Yaml too. See the [Yaml docs](http://www.yaml.org/YAML_for_ruby.html).
338
-
339
- ### Order of Precedence
340
-
341
- Layouts will override Squib's system defaults, but are overriden by anything specified in the command itself. Thus, the order of precedence looks like this:
342
-
343
- * Use what the command specified
344
- * If anything was not yet specified, use what was given in a layout (if a layout was specified in the command and the file was given to the Deck)
345
- * If still anything was not yet specified, use what was given in Squib's defaults.
346
-
347
- ### Special key: `extends`
348
-
349
- Squib provides a way of reusing layouts with the special `extends` key. When defining an `extends` key, we can merge in another key and modify data coming in if we want to. This allows us to do things like place text next to an icon and be able to move them with each other. Like this:
350
-
351
- ```yaml
352
- # If we change the xy of attack, we move defend too!
353
- attack:
354
- x: 100
355
- y: 100
356
- radius: 100
357
- defend:
358
- extends: attack
359
- x: += 50
360
- #defend now is {:x => 150, :y => 100}
361
- ```
362
-
363
- If you want to extend multiple parents, it looks like this:
364
-
365
- ```yaml
366
- socrates:
367
- x: 100
368
- plato:
369
- y: 200
370
- aristotle:
371
- extends:
372
- - socrates
373
- - plato
374
- x: += 50
375
- ```
376
- If multiple keys override the same keys in a parent, the later ("younger") child takes precedent.
377
-
378
- Note that extends keys are similar to Yaml's ["merge keys"](http://www.yaml.org/YAML_for_ruby.html#merge_key). With merge keys, you can define base styles in one entry, then include those keys elsewhere. For example:
379
-
380
- ```yaml
381
- icon: &icon
382
- width: 50
383
- height: 50
384
- icon_left
385
- <<: *icon
386
- x: 100
387
- # The layout for icon_left will have the width/height from icon!
388
- ```
389
-
390
- If you use both `extends` and Yaml merge keys, the Yaml merge keys are processed first, then extends. For clarity, however, you're probably just better off using `extends` exclusively.
391
-
392
- ### Multiple layout files
393
-
394
- Squib also supports the combination of multiple layout files. If you provide an `Array` of files then Squib will merge them sequentially. Colliding keys will be completely re-defined by the later file. Extends is processed after _each file_. Here's a complex example:
395
-
396
- ```yaml
397
- # load order: a.yml, b.yml
398
-
399
- ##############
400
- # file a.yml #
401
- ##############
402
- grandparent:
403
- x: 100
404
- parent_a:
405
- extends: grandparent
406
- x: += 10 # evaluates to 110
407
- parent_b:
408
- extends: grandparent
409
- x: += 20 # evaluates to 120
410
-
411
- ##############
412
- # file b.yml #
413
- ##############
414
- child_a:
415
- extends: parent_a # i.e. extends a layout in a separate file
416
- x: += 3 # evaluates to 113 (i.e 110 + 3)
417
- parent_b: # redefined
418
- extends: grandparent
419
- x: += 30 # evaluates to 130 (i.e. 100 + 30)
420
- child_b:
421
- extends: parent_b
422
- x: += 3 # evaluates to 133 (i.e. 130 + 3)
423
- ```
424
-
425
- This can be helpful for:
426
- * Creating a base layout for structure, and one for color (for easier color/black-and-white switching)
427
- * Sharing base layouts with other designers
428
-
429
- YAML merge keys are NOT supported across multiple files - use `extends` instead.
430
-
431
- ### Built-in Layout Files
432
-
433
- Why mess with x-y coordinates when you're first prototyping your game?!?!? Just use a built-in layout to get your game to the table as quickly as possible.
434
-
435
- If your layout file is not found in the current directory, Squib will search for its own set of layout files. The latest the development version of these can be found [on GitHub](https://github.com/andymeneely/squib/tree/master/lib/squib/layouts). The `layouts_builtin.rb` sample (found [here](https://github.com/andymeneely/squib/tree/master/samples/)) demonstrate built-in layouts based on popular games (e.g. `fantasy.yml` and `economy.yml`)
436
-
437
- Contributions in this area are particularly welcome!
438
-
439
- ### Layout Sample
440
- This sample demonstrates many different ways of using and combining layouts. This is the `layouts.rb` sample found [here](https://github.com/andymeneely/squib/tree/master/samples/)
441
-
442
- {include:file:samples/layouts.rb}
443
-
444
- ## Backends: Raster vs. Vector
445
- Under the hood, Cairo has the ability to support a variety of surfaces to draw on, including both raster images stored in memory and vectors stored in SVG files. Thus, Squib supports the ability to handle both. They are options in the configuration file `backend: memory` or `backend: svg`.
446
-
447
- If you save to a PDF then the backend will determine how your cards are saved too. For `memory`, the PDF will be filled with compressed raster images and be a larger file (yet it will still print at high quality... see discussion below). For SVG backends, PDFs will be smaller. If you have your deck backed by SVG, then the cards are auto-saved, so there is no `save_svg` in Squib. (Technically, the operations are stored and then flushed to the SVG file at the very end.)
448
-
449
- There are trade-offs that one should consider here.
450
-
451
- * _Print quality is **higher** for raster images_. This seems counterintuitive at first, but consider where Squib sits in your workflow. It's the final assembly line for your cards before they get printed. Cairo puts _a ton_ of work into rendering each pixel perfectly when it works with raster images. Printers, on the other hand, don't think in vectors and will render your paths in their own memory with their own embedded libraries without putting a lot of work into antialiasing and various other graphical esoterica. You may notice that print-on-demand companies such as The Game Crafter [only accept raster file types](https://www.thegamecrafter.com/help/supported-file-types), because they don't want their customers complaining about printers not rendering vectors with enough care.
452
- * _PDFs are **smaller** for SVG back ends_. If file size is a limitation for you, and it can be for some printers or internet forums, then an SVG back end for vectorized PDFs is the way to go.
453
- * _Squib is **greedy** with memory_. While I've tested Squib with big decks on older computers, the `memory` backend is quite greedy with RAM. If memory is at a premium for you, switching to SVG might help.
454
-
455
- Note: you can still load PNGs into an SVG-backed deck and load SVGs into a memory-backed deck. To me, the sweet spot is to keep all of my icons, text, and other stuff in vector form for infinite scaling and then render them all to pixels with Squib.
456
-
457
- Fortunately, switching backends in Squib should be as trivial as changing the setting in the config file. So go ahead and experiment with both and see what works for you. See below for how the configuration options work.
458
-
459
- ## Configuration File
460
-
461
- Squib supports various configuration properties that can be specified in an external file. The `config:` option in `Deck.new` can specify an optional configuration file in YML format. The properties there are intended to be immutable for the life of the Deck. The options include:
462
-
463
- * `progress_bars` (Boolean, default: false). When set to `true`, long-running operations will show a progress bar on the command line.
464
- * `hint` (ColorString, default: off). Text hints are used to show the boundaries of text boxes. Can be enabled/disabled for individual commands, or set globally with the `set` command. This setting is overriden by `set` and individual commands.
465
- * `custom_colors` (Hash of Colors, default: {}). Defines globally-available colors available to the deck that can be specified in commands.
466
- * `antialias` (`fast, good, best, none, gray, subpixel`, default: best). Set the algorithm that Cairo will use for antialiasing. Using our benchmarks on large decks, `best` is only ~10% slower anyway. For more info see the [Cairo docs](http://www.cairographics.org/manual/cairo-cairo-t.html#cairo-antialias-t).
467
- * `backend` (`svg` or `memory`, default: `memory`). Defines how Cairo will store the operations. Memory is recommended for higher quality rendering.
468
- * `prefix` (default: `card_`). When using an SVG backend, cards are auto-saved with this prefix and `"%02d"` numbering format.
469
- * `warn_ellipsize` (default: true). Warn when text is ellipsized
470
- * `warn_png_scale` (default: true). Warn when a PNG file is upscaled
471
-
472
- For debugging/sanity purposes, if you want to make sure your configuration options are parsed correclty, the above options are also available as methods within Squib::Deck, for example:
473
-
474
- ```ruby
475
- Squib::Deck.new do
476
- puts backend # prints 'memory' by default
477
- end
478
- ```
479
-
480
- The following sample demonstrates the config file, found [here](https://github.com/andymeneely/squib/tree/master/samples/)
481
-
482
- {include:file:samples/custom_config.rb}
483
-
484
- ## Importing from Excel and CSV
485
-
486
- Squib supports importing data from `xlsx` files and `csv` files. These methods are column-based, which means that they assume you have a header row in your table, and that header row will define the column. Squib will return a `Hash` of `Arrays` correspoding to each row. Warnings are thrown on things like duplicate columns. See the `excel.rb` and the `csv_import.rb` sample found [here](https://github.com/andymeneely/squib/tree/master/samples/).
487
-
488
- {include:file:samples/excel.rb}
489
-
490
- Of course, you can always import your game data other ways using just Ruby. There's nothing special about Squib's methods other than their convenience.
491
-
492
- ###Quantity Explosion
493
-
494
- If you want more than one copy of a card, then have a column called `Qty` and fill it with counts. Squib's `xlsx` and `csv` methods will automatically expand those rows according to those counts. You can also customize that "Qty" to anything you like by setting the `explode` option (e.g. `explode: 'Quantity'`). See the `excel.rb` and the `csv_import.rb` samples found [here](https://github.com/andymeneely/squib/tree/master/samples/) for an example.
495
-
496
- ## Making Squib Verbose
497
-
498
- By default, Squib's logger is set to WARN, but more fine-grained logging is embedded in the code. To set the logger, just put this at the top of your script:
499
-
500
- ```ruby
501
- Squib::logger.level = Logger::INFO
502
- ```
503
-
504
- If you REALLY want to see tons of output, you can also set DEBUG, but that's not intended for general consumption.
505
-
506
- # "Best" Practices
507
-
508
- Here's a collection of workflow tips and code snippets that will hopefully improve your Squibbing. Contributions are welcome!
509
93
 
510
94
  ## Staying DRY
511
95
 
@@ -516,130 +100,18 @@ Squib tries to keep you DRY (Don't Repeat Yourself) with the following features:
516
100
  * Custom colors keep you from hardcoding magic color strings everywhere. Custom colors go into `config.yml` file.
517
101
  * Plus, you know, Ruby.
518
102
 
519
- ## Get to know Ruby's Array and Enumerable
520
-
521
- Don't know Ruby? Welcome! We are so happy that Squib is your excuse to learn Ruby.
522
-
523
- Ruby has a *very* rich library for all of its built-in data types, especially [Array](http://ruby-doc.org/core-2.2.0/Array.html), and it's broader module [Enumerable](http://ruby-doc.org/core-2.2.0/Enumerable.html). Since Squib primarily takes in arrays into most of its fields, getting to know these methods will help you out enormously:
524
-
525
- * [Array#each](http://ruby-doc.org/core-2.2.0/Array.html#method-i-each) - do something on each element of the array (Ruby folks seldom use for-loops)
526
- * [Array#map](http://ruby-doc.org/core-2.2.0/Array.html#method-i-map) - do something on each element of an array and put it into a new array
527
- * [Array#select](http://ruby-doc.org/core-2.2.0/Array.html#method-i-select) - select a subset of an array
528
- * [Enumerable#each_with_index](http://ruby-doc.org/core-2.2.0/Enumerable.html#method-i-each_with_index) - do something to each element, also being aware of the index
529
- * [Array#zip](http://ruby-doc.org/core-2.2.0/Enumerable.html#method-i-zip) - combine two arrays, element by element
530
-
531
- ## Source control
532
-
533
- You are using source control, right??
534
-
535
- By default, Squib assumes Git. But it's not dogmatic about it. Tracking your progress, backing up, sharing data, topic branches, release management, and reverting into history are just some of the many, many useful things you can do with source control. For me, I tend to ignore any auto-generated files in my output folder, but version control everything else. I also try to keep my graphics vector files, so the files stay small. Version control is intended for source code, so large binary files that change often probably should not get checked in unless absolutely necessary. I tend to keep big raster graphics files (e.g. from Gimp) in cloud storage or elsewhere.
536
-
537
103
  ## SublimeText
538
104
 
539
105
  Using SublimeText? I like you already. I've written up some Squib snippets to ease remembering Squib commands. It's called `Squib Snippets` on Package Control. Compatible with SublimeText 3. Source code is also [on Github](https://github.com/andymeneely/sublime-squib) (contributions welcome!). Check it out:
540
106
 
541
107
  ![Sublime Squib Snippets](https://raw.githubusercontent.com/andymeneely/squib/screencasts/sublime-squib-snippets.gif)
542
108
 
543
- ## Decks with multiple orientations or sizes
544
-
545
- If you want to make a deck that has some portrait and some landscape cards, I recommend you use multiple `Squib::Deck`s. The pixel size of a given card is designed to not change thorughout the life of a `Squib::Deck`. To work with landscape cards, there is a `rotate` option on `save_png` so you can render your print-on-demand PNGs in portrait but keep everything else oriented toward landscape. The following example demonstrates how to do this, found [here](https://github.com/andymeneely/squib/tree/master/samples/portrait-landscape.rb).
546
-
547
- {include:file:samples/portrait-landscape.rb}
548
-
549
- ## Rakefile
550
-
551
- When you run `squib new`, you are given a basic Rakefile. At this stage of Squib, it's basically just a shortcut for `ruby deck.rb`. But, even in this simple form this Rakefile has some advantages:
552
-
553
- * If you're in a subdirectory at the time, `rake` will simply traverse up and `cd` to the proper directory so you don't get rogue `_output` directories
554
- * If you find yourself building multiple decks, you can make your own tasks for each one individually, or all (e.g. `rake marketing`)
555
- * Don't need the `require squib` at the top of your code (although that breaks `ruby deck.rb`, so that's probably a bad idea)
556
-
557
- ## Using Google Sheets
558
-
559
- We don't officially support Google Sheets ([yet](https://github.com/andymeneely/squib/issues/49)), but [this Gist](https://gist.github.com/pickfifteen/aeee73ec2ce162b0aee8) might be helpful in automatically exporting the CSV.
560
-
561
- ## Combining Multiple Columns
562
-
563
- Say you have multiple columns in your Excel sheet that need to be combined into one text field on your card. Consider using `zip` in conjunction with `map`.
564
-
565
- ```ruby
566
- data['BuyText'] = data['BuyAmount'].zip(data['BuyType']).map do |amt, type|
567
- "You may purchase #{amt} #{type}" #e.g. You may purchase 1 Wood.
568
- end
569
-
570
- data['Cost'] = data['Action Cost'].zip(data['Card Cost']).map do |ac, cc|
571
- ':action:' * ac.to_i + ":card#{cc}:"
572
- end
573
- ```
574
-
575
- Second example adapted from [this conversation](https://github.com/andymeneely/squib/issues/90)
576
-
577
- # Get Involved
578
-
579
- Squib is an open source tool, so I welcome participation. Squib is currently in pre-release alpha, so the API is still maturing. I do change my mind about the names and meaning of things at this stage. I will document these changes as best as I can.
580
-
581
- I also highly recommend upgrading to new versions of Squib every chance you get (using Bundler). You can watch for new upgrades by following the RubyGems [RSS](https://rubygems.org/gems/squib/versions.atom), or by watching the project on GitHub.
582
-
583
- For bugs and feature requests, feel free to [file a bug or feature request](https://github.com/andymeneely/squib/issues). A minimal code example along with your OS and Ruby details would be ideal.
584
-
585
- ## New to Programming?
586
-
587
- I often hear statements like "I'm not a programmer, but I want to use Squib." If you want to use Squib, then maybe you really were a programmer all along :)
588
-
589
- Squib is a Ruby library. To learn Squib, you will need to learn Ruby. There is no getting around that fact. Don't fight it, embrace it.
590
-
591
- Fortunately, Ruby is wonderfully rich in features and very expressive in its syntax. Ruby has a vibrant, friendly community (much like tabletop game designers!). Ruby is the language of choice for many new programmers, including many universities. Plus, learning how to code is ubiquitous on the Internet.
592
-
593
- Doubly fortunately, Squib doesn't require tons of Ruby-fu to get going either. The main things you'll need to know are:
594
- * Working on the command line
595
- * Ruby Arrays, so that the `range` parameter makes more sense
596
- * Strings, variables, and symbols
597
- * If you are using Excel or CSV, then Ruby hashes are worth a glance.
598
- * Working iteratively: making small edits and run your code frequently (every few minutes)
599
-
600
- Anything related to Ruby on Rails is not necessary to learn for Squib. Rails is a heavyweight framework for web development (awesome in its own way, but not relevant to learning Ruby). Squib is about scripting.
601
-
602
- ## Get Help
603
-
604
- There are lots of people using Squib already. If you've gone through the [samples](https://github.com/andymeneely/squib/tree/master/samples) and still have questions, here are some other places to get help.
605
-
606
- * Our [thread on BoardGameGeek](http://boardgamegeek.com/thread/1293453) is quite active and informal (if a bit unstructured).
607
- * [StackOverflow](http://stackoverflow.com/questions/ask?tags=ruby squib) with the tag "ruby" and "squib" will get you answers quickly and a great way to document questions for future Squibbers.
608
-
609
- If you email me directly I'll probably ask you to post your question publicly so we can document answers for future Googling Squibbers.
610
-
611
- Please use GitHub issues for bugs and feature requests.
612
-
613
- ## Give Help
614
-
615
- Let's help each other out! Even if you're relatively new, there's probably some question out there that you can help answer. Here's how to help:
616
-
617
- * Subscribe to our thread on BoardGameGeek (see above for link)
618
- * Subscribe to alerts from Stackoverflow for the tags "squib" and "ruby"
619
- * Post snippets of your code using GitHub gists
620
- * Write a how-to tutorial and post it on [our wiki](https://github.com/andymeneely/squib/wiki)
621
-
622
- ## Testing Pre-Builds
623
-
624
- Testers needed!! If you want to test new features as I develop them, or make sure I didn't break your code, you can always point your Gemfile to the repository and follow what I'm doing there. Your Gemfile specification looks like this:
625
-
626
- ```ruby
627
- gem 'squib', git: 'git://github.com/andymeneely/squib', branch: 'dev'
628
- ```
629
- * The `dev` branch is where I am working on features in-process. I have not done much regression testing at this point, but would love testing feedback nonetheless.
630
- * The `master` branch is where I consider features and bug that are done and tested, but not released yet.
631
109
 
632
- ## Contributing
633
110
 
634
- If you want your code integrated:
111
+ # Get Help and Give Help
635
112
 
636
- 1. Fork the git repository ( https://github.com/[my-github-username]/squib/fork )
637
- 2. Create your feature branch (`git checkout -b my-new-feature`)
638
- 3. Commit your changes (`git commit -am 'Add some feature'`)
639
- 4. Push to the branch (`git push origin my-new-feature`)
640
- 5. Create a new Pull Request
113
+ See [this page](http://squib.readthedocs.org/en/latest/help.html)
641
114
 
642
- Be sure to run the unit tests and packaging with just `rake`. Also, you can check that the samples render properly with `rake sanity`.
643
115
 
644
116
  # What's up the with the name?
645
117