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
data/docs/config.rst ADDED
@@ -0,0 +1,117 @@
1
+ Configuration Options
2
+ =====================
3
+
4
+ Squib supports various configuration properties that can be specified in an external file. By default, Squib looks for a file called ``config.yml`` in the current directory. Or, you can set the ``config:`` option in ``Deck.new`` to specify the name of the configuration file.
5
+
6
+ These properties are intended to be immutable for the life of the Deck, and intended to configure how Squib behaves.
7
+
8
+ The options include:
9
+
10
+ progress_bars
11
+ default: ``false``
12
+
13
+ When set to ``true``, long-running operations will show a progress bar in the console
14
+
15
+ hint
16
+ default: ``:off``
17
+
18
+ Text hints are used to show the boundaries of text boxes. Can be enabled/disabled for individual commands, or set globally with the `hint` method. This setting is overridden by `hint` (and subsequently individual :doc:`/dsl/text`).
19
+
20
+ custom_colors
21
+ default: ``{}``
22
+
23
+ Defines globally-available named colors available to the deck. Must be specified as a hash in yaml. For example::
24
+
25
+ # config.yml
26
+ custom_colors:
27
+ fg: '#abc'
28
+ bg: '#def'
29
+
30
+
31
+ antialias
32
+ default: ``'best'``
33
+
34
+ Set the algorithm that Cairo will use for anti-aliasing throughout its rendering. Available options are ``fast``, ``good``, ``best``, ``none``, ``gray``, ``subpixel``.
35
+
36
+ Not every option is available on every platform. 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>`_.
37
+
38
+ backend
39
+ default: ``'memory'``
40
+
41
+ Defines how Cairo will store the operations. Can be ``svg`` or ``memory``. See :doc:`/backends`.
42
+
43
+ prefix
44
+ default: ``'card_'``
45
+
46
+ When using an SVG backend, cards are auto-saved with this prefix and ``'%02d'`` numbering format.
47
+
48
+ warn_ellipsize
49
+ default: true
50
+
51
+ Show a warning on the console when text is ellipsized. Warning is issued per card.
52
+
53
+ warn_png_scale
54
+ default: true
55
+
56
+ Show a warning on the console when a PNG file is upscaled. Warning is issued per card.
57
+
58
+ lsquote
59
+ default: ``"\u2018"``
60
+
61
+ Smart quoting: change the left single quote when ``markup: true``
62
+
63
+ rsquote
64
+ default: ``"\u2019"``
65
+
66
+ Smart quoting: change the right single quote when ``markup: true``
67
+
68
+ ldquote
69
+ default: ``"\u201C"``
70
+
71
+ Smart quoting: change the left double quote when ``markup: true``
72
+
73
+ rdquote
74
+ default: ``"\u201D"``
75
+
76
+ Smart quoting: change the right double quote when ``markup: true``
77
+
78
+ em_dash
79
+ default: ``"\u2014"``
80
+
81
+ Convert the ``--`` to this character when ``markup: true``
82
+
83
+ en_dash
84
+ default: ``"\u2013"``
85
+
86
+ Convert the ``---`` to this character when ``markup: true``
87
+
88
+
89
+ ellipsis
90
+ default: ``"\u2026"``
91
+
92
+ Convert ``...`` to this character when ``markup: true``
93
+
94
+ smart_quotes
95
+ default: true
96
+
97
+ When ``markup: true``, the ``text`` method will convert quotes. With ``smart_quotes: false``, explicit replacements like em-dashes and en-dashes will be replaced but not smart quotes.
98
+
99
+
100
+ Options are available as methods
101
+ --------------------------------
102
+
103
+ For debugging/sanity purposes, if you want to make sure your configuration options are parsed correctly, the above options are also available as methods within ``Squib::Deck``, for example::
104
+
105
+ Squib::Deck.new do
106
+ puts backend # prints 'memory' by default
107
+ end
108
+
109
+
110
+ Making Squib Verbose
111
+ --------------------
112
+
113
+ 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::
114
+
115
+ Squib::logger.level = Logger::INFO
116
+
117
+ If you REALLY want to see tons of output, you can also set DEBUG, but that's not intended for general consumption.
data/docs/data.rst ADDED
@@ -0,0 +1,22 @@
1
+ Be Data-Driven with XLSX and CSV
2
+ ================================
3
+
4
+ Squib supports importing data from ExcelX (.xlsx) files and Comma-Separated Values (.csv) files. Because :doc:`/arrays`, 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 name of the column.
5
+
6
+ Hash of Arrays
7
+ --------------
8
+
9
+ In both DSL methods, Squib will return a ``Hash`` of ``Arrays`` correspoding to each row. Thus, be sure to structure your data like this:
10
+
11
+ * First row should be a header - preferably with concise naming since you'll reference it in Ruby code
12
+ * Rows should represent cards in the deck
13
+ * Columns represent data about cards (e.g. "Type", "Cost", or "Name")
14
+
15
+ Of course, you can always import your game data other ways using just Ruby (e.g. from a REST API, a JSON file, or your own custom format). There's nothing special about Squib's methods in how they relate to ``Squib::Deck`` other than their convenience.
16
+
17
+ See :doc:`/dsl/xlsx` and :doc:`/dsl/csv` for more details and examples.
18
+
19
+ Quantity Explosion
20
+ ------------------
21
+
22
+ If you want more than one copy of a card, then have a column in your data file called ``Qty`` and fill it with counts for each card. Squib's :doc:`/dsl/xlsx` and :doc:`/dsl/xlsx` 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'``). Again, see the specific methods for examples.
@@ -0,0 +1,20 @@
1
+ background
2
+ ----------
3
+
4
+ Fills the background with the given color
5
+
6
+
7
+ Options
8
+ ^^^^^^^
9
+ .. include:: /args/expansion.rst
10
+
11
+ .. include:: /args/range.rst
12
+
13
+ color
14
+ default: ``:black``
15
+
16
+ the color or gradient to fill the background with. See :doc:`/colors`.
17
+
18
+
19
+ Examples
20
+ ^^^^^^^^
@@ -0,0 +1,32 @@
1
+ build
2
+ =====
3
+
4
+ Establish a set of commands that can be enabled/disabled together to allow for customized builds. See :doc:`/build_groups` for ways to use this effectively.
5
+
6
+ Required Arguments
7
+ ------------------
8
+
9
+ .. note::
10
+
11
+ This is an argument, not an option like most DSL methods. See example below.
12
+
13
+ group
14
+ default: ``:all``
15
+
16
+ The name of the build group. Convention is to use a Ruby symbol.
17
+
18
+
19
+ &block
20
+ When this group is enabled (and only ``:all`` is enabled by default), then this block is executed. Otherwise, the block is ignored.
21
+
22
+
23
+ Examples
24
+ --------
25
+
26
+ Use group to organize your Squib code into build groups::
27
+
28
+ Squib::Deck.new do
29
+ build :pnp do
30
+ save_pdf
31
+ end
32
+ end
@@ -0,0 +1,23 @@
1
+ build_groups
2
+ ============
3
+
4
+ Returns the set of group names that have been enabled. See :doc:`/build_groups` for ways to use this effectively.
5
+
6
+ Arguments
7
+ ---------
8
+
9
+ (none)
10
+
11
+
12
+ Examples
13
+ --------
14
+
15
+ Use group to organize your Squib code into build groups::
16
+
17
+ Squib::Deck.new do
18
+ enable_build :pnp
19
+ build :pnp do
20
+ save_pdf
21
+ end
22
+ puts build_groups # outputs :all and :pnp
23
+ end
@@ -0,0 +1,27 @@
1
+ circle
2
+ ------
3
+
4
+ Draw a circle centered at the given coordinates
5
+
6
+ Options
7
+ ^^^^^^^
8
+ .. include:: /args/expansion.rst
9
+
10
+ .. include:: /args/xy.rst
11
+
12
+ radius
13
+ default: ``100``
14
+
15
+ radius of the circle. Supports :doc:`/units`.
16
+
17
+ .. include:: /args/draw.rst
18
+ .. include:: /args/range.rst
19
+ .. include:: /args/layout.rst
20
+
21
+ Examples
22
+ ^^^^^^^^
23
+
24
+ .. literalinclude:: /../samples/shapes/_draw_shapes.rb
25
+ :language: ruby
26
+ :linenos:
27
+ :caption: This snippet and others like it live `here <https://github.com/andymeneely/squib/blob/master/samples/>`_
data/docs/dsl/cm.rst ADDED
@@ -0,0 +1,19 @@
1
+ cm
2
+ --
3
+
4
+ Given centimeters, returns the number of pixels according to the deck's DPI.
5
+
6
+ Parameters
7
+ ^^^^^^^^^^
8
+
9
+ n
10
+ the number of centimeters
11
+
12
+
13
+ Examples
14
+ ^^^^^^^^
15
+
16
+ .. code-block:: ruby
17
+
18
+ cm(1) # 118.11px (for default Deck::dpi of 300)
19
+ cm(2) + cm(1) # 354.33ox (for default Deck::dpi of 300)
data/docs/dsl/csv.rst ADDED
@@ -0,0 +1,62 @@
1
+ csv
2
+ ===
3
+
4
+ Pulls CSV data from .csv files into a hash of arrays keyed by the headers. First row is assumed to be the header row.
5
+
6
+ Parsing uses Ruby's CSV, with options ``{headers: true, converters: :numeric}``
7
+ http://www.ruby-doc.org/stdlib-2.0/libdoc/csv/rdoc/CSV.html
8
+
9
+ The ``csv`` method is a member of ``Squib::Deck``, but it is also available outside of the Deck DSL with ``Squib.csv()``. This allows a construction like::
10
+
11
+ data = Squib.csv file: 'data.csv'
12
+ Squib::Deck.new(cards: data['name'].size) do
13
+ end
14
+
15
+
16
+ Options
17
+ -------
18
+
19
+ file
20
+ default: ``'deck.csv'``
21
+
22
+ the CSV-formatted file to open. Opens relative to the current directory. If ``data`` is set, this option is overridden.
23
+
24
+ data
25
+ default: ``nil``
26
+
27
+ when set, CSV will parse this data instead of reading the file.
28
+
29
+ strip
30
+ default: ``true``
31
+
32
+ When ``true``, strips leading and trailing whitespace on values and headers
33
+
34
+ explode
35
+ default: ``'qty'``
36
+
37
+ Quantity explosion will be applied to the column this name. For example, rows in the csv with a ``'qty'`` of 3 will be duplicated 3 times.
38
+
39
+ col_sep
40
+ default: ``','``
41
+
42
+ Column separator. One of the CSV custom options in Ruby. See next option below.
43
+
44
+ CSV custom options in Ruby standard lib.
45
+ All of the options in Ruby's std lib version of CSV are supported **except** ``headers`` is always ``true`` and ``converters`` is always set to ``:numeric``. See the `Ruby Docs <http://ruby-doc.org/stdlib-2.2.0/libdoc/csv/rdoc/CSV.html#method-c-new>`_ for information on the options.
46
+
47
+ Individual Pre-processing
48
+ -------------------------
49
+
50
+ The ``xlsx`` method also takes in a block that will be executed for each cell in your data. This is useful for processing individual cells, like putting a dollar sign in front of dollars, or converting from a float to an integer. The value of the block will be what is assigned to that cell. For example::
51
+
52
+ resource_data = Squib.csv(file: 'sample.xlsx') do |header, value|
53
+ case header
54
+ when 'Cost'
55
+ "$#{value}k" # e.g. "3" becomes "$3k"
56
+ else
57
+ value # always return the original value if you didn't do anything to it
58
+ end
59
+ end
60
+
61
+ Examples
62
+ --------
@@ -0,0 +1,63 @@
1
+ curve
2
+ -----
3
+
4
+ Draw a bezier curve using the given coordinates, from x1,y1 to x2,y2. The curvature is set by the control points cx1,cy2 and cx2,cy2.
5
+
6
+ Options
7
+ ^^^^^^^
8
+ .. include:: /args/expansion.rst
9
+
10
+ x1
11
+ default: ``0``
12
+
13
+ the x-coordinate of the first endpoint. Supports :doc:`/units`.
14
+
15
+
16
+ y1
17
+ default: ``0``
18
+
19
+ the y-coordinate of the first endpoint. Supports :doc:`/units`.
20
+
21
+
22
+ x2
23
+ default: ``5``
24
+
25
+ the x-coordinate of the second endpoint. Supports :doc:`/units`.
26
+
27
+
28
+ y2
29
+ default: ``5``
30
+
31
+ the y-coordinate of the second endpoint. Supports :doc:`/units`.
32
+
33
+
34
+ cx1
35
+ default: ``0``
36
+
37
+ the x-coordinate of the first control point. Supports :doc:`/units`.
38
+
39
+
40
+ cy1
41
+ default: ``0``
42
+
43
+ the y-coordinate of the first control point. Supports :doc:`/units`.
44
+
45
+
46
+ cx2
47
+ default: ``5``
48
+
49
+ the x-coordinate of the second control point. Supports :doc:`/units`.
50
+
51
+
52
+ cy2
53
+ default: ``5``
54
+
55
+ the y-coordinate of the second control point. Supports :doc:`/units`.
56
+
57
+
58
+ .. include:: /args/draw.rst
59
+ .. include:: /args/range.rst
60
+ .. include:: /args/layout.rst
61
+
62
+ Examples
63
+ ^^^^^^^^
data/docs/dsl/deck.rst ADDED
@@ -0,0 +1,45 @@
1
+ Squib::Deck.new
2
+ ===============
3
+
4
+ The main interface to Squib. Yields to a block that is used for most of Squib's operations. The majority of the :doc:`DSL methods </dsl/index>` are instance methods of ``Squib::Deck``.
5
+
6
+ Options
7
+ -------
8
+ These options set immutable properties for the life of the deck. They are not intended to be changed in the middle of Squib's operation.
9
+
10
+ width
11
+ default: ``825``
12
+
13
+ the width of each card in pixels, :doc:`including bleed </bleed>`. Supports :doc:`/units` (e.g. ``'2.5in'``).
14
+
15
+ height
16
+ default: ``1125``
17
+
18
+ the height of each card in pixels, :doc:`including bleed </bleed>`. Supports :doc:`/units` (e.g. '3.5in').
19
+
20
+ cards
21
+ default: ``1``
22
+
23
+ the number of cards in the deck
24
+
25
+ dpi
26
+ default: ``300``
27
+
28
+ the pixels per inch when rendering out to PDF, doing :doc:`/units`, or other operations that require measurement.
29
+
30
+ config
31
+ default: ``'config.yml'``
32
+
33
+ the file used for global settings of this deck, see :doc:`/config`. If the file is not found, Squib does not complain.
34
+
35
+ .. note ::
36
+
37
+ Since this option has ``config.yml`` as a default, then Squib automatically looks up a ``config.yml`` in the current working directory.
38
+
39
+ layout
40
+ default: ``nil``
41
+
42
+ load a YML file of :doc:`custom layouts </layouts>`. Multiple files in an array are merged sequentially, redefining collisons in the merge process. If no layouts are found relative to the current working directory, then Squib checks for a `built-in layout <https://github.com/andymeneely/squib/tree/master/lib/squib/layouts>`_.
43
+
44
+ Examples
45
+ --------