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
data/docs/learning.rst ADDED
@@ -0,0 +1,10 @@
1
+ Learning Squib
2
+ ==============
3
+
4
+ .. toctree::
5
+ :maxdepth: 1
6
+
7
+ guides/hello_world
8
+ guides/getting-started/index
9
+ guides/git
10
+ guides/game_icons
data/docs/make.bat ADDED
@@ -0,0 +1,263 @@
1
+ @ECHO OFF
2
+
3
+ REM Command file for Sphinx documentation
4
+
5
+ if "%SPHINXBUILD%" == "" (
6
+ set SPHINXBUILD=sphinx-build
7
+ )
8
+ set BUILDDIR=_build
9
+ set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
10
+ set I18NSPHINXOPTS=%SPHINXOPTS% .
11
+ if NOT "%PAPER%" == "" (
12
+ set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
13
+ set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
14
+ )
15
+
16
+ if "%1" == "" goto help
17
+
18
+ if "%1" == "help" (
19
+ :help
20
+ echo.Please use `make ^<target^>` where ^<target^> is one of
21
+ echo. html to make standalone HTML files
22
+ echo. dirhtml to make HTML files named index.html in directories
23
+ echo. singlehtml to make a single large HTML file
24
+ echo. pickle to make pickle files
25
+ echo. json to make JSON files
26
+ echo. htmlhelp to make HTML files and a HTML help project
27
+ echo. qthelp to make HTML files and a qthelp project
28
+ echo. devhelp to make HTML files and a Devhelp project
29
+ echo. epub to make an epub
30
+ echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
31
+ echo. text to make text files
32
+ echo. man to make manual pages
33
+ echo. texinfo to make Texinfo files
34
+ echo. gettext to make PO message catalogs
35
+ echo. changes to make an overview over all changed/added/deprecated items
36
+ echo. xml to make Docutils-native XML files
37
+ echo. pseudoxml to make pseudoxml-XML files for display purposes
38
+ echo. linkcheck to check all external links for integrity
39
+ echo. doctest to run all doctests embedded in the documentation if enabled
40
+ echo. coverage to run coverage check of the documentation if enabled
41
+ goto end
42
+ )
43
+
44
+ if "%1" == "clean" (
45
+ for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
46
+ del /q /s %BUILDDIR%\*
47
+ goto end
48
+ )
49
+
50
+
51
+ REM Check if sphinx-build is available and fallback to Python version if any
52
+ %SPHINXBUILD% 1>NUL 2>NUL
53
+ if errorlevel 9009 goto sphinx_python
54
+ goto sphinx_ok
55
+
56
+ :sphinx_python
57
+
58
+ set SPHINXBUILD=python -m sphinx.__init__
59
+ %SPHINXBUILD% 2> nul
60
+ if errorlevel 9009 (
61
+ echo.
62
+ echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
63
+ echo.installed, then set the SPHINXBUILD environment variable to point
64
+ echo.to the full path of the 'sphinx-build' executable. Alternatively you
65
+ echo.may add the Sphinx directory to PATH.
66
+ echo.
67
+ echo.If you don't have Sphinx installed, grab it from
68
+ echo.http://sphinx-doc.org/
69
+ exit /b 1
70
+ )
71
+
72
+ :sphinx_ok
73
+
74
+
75
+ if "%1" == "html" (
76
+ %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
77
+ if errorlevel 1 exit /b 1
78
+ echo.
79
+ echo.Build finished. The HTML pages are in %BUILDDIR%/html.
80
+ goto end
81
+ )
82
+
83
+ if "%1" == "dirhtml" (
84
+ %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
85
+ if errorlevel 1 exit /b 1
86
+ echo.
87
+ echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
88
+ goto end
89
+ )
90
+
91
+ if "%1" == "singlehtml" (
92
+ %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
93
+ if errorlevel 1 exit /b 1
94
+ echo.
95
+ echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
96
+ goto end
97
+ )
98
+
99
+ if "%1" == "pickle" (
100
+ %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
101
+ if errorlevel 1 exit /b 1
102
+ echo.
103
+ echo.Build finished; now you can process the pickle files.
104
+ goto end
105
+ )
106
+
107
+ if "%1" == "json" (
108
+ %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
109
+ if errorlevel 1 exit /b 1
110
+ echo.
111
+ echo.Build finished; now you can process the JSON files.
112
+ goto end
113
+ )
114
+
115
+ if "%1" == "htmlhelp" (
116
+ %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
117
+ if errorlevel 1 exit /b 1
118
+ echo.
119
+ echo.Build finished; now you can run HTML Help Workshop with the ^
120
+ .hhp project file in %BUILDDIR%/htmlhelp.
121
+ goto end
122
+ )
123
+
124
+ if "%1" == "qthelp" (
125
+ %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
126
+ if errorlevel 1 exit /b 1
127
+ echo.
128
+ echo.Build finished; now you can run "qcollectiongenerator" with the ^
129
+ .qhcp project file in %BUILDDIR%/qthelp, like this:
130
+ echo.^> qcollectiongenerator %BUILDDIR%\qthelp\Squib.qhcp
131
+ echo.To view the help file:
132
+ echo.^> assistant -collectionFile %BUILDDIR%\qthelp\Squib.ghc
133
+ goto end
134
+ )
135
+
136
+ if "%1" == "devhelp" (
137
+ %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
138
+ if errorlevel 1 exit /b 1
139
+ echo.
140
+ echo.Build finished.
141
+ goto end
142
+ )
143
+
144
+ if "%1" == "epub" (
145
+ %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
146
+ if errorlevel 1 exit /b 1
147
+ echo.
148
+ echo.Build finished. The epub file is in %BUILDDIR%/epub.
149
+ goto end
150
+ )
151
+
152
+ if "%1" == "latex" (
153
+ %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
154
+ if errorlevel 1 exit /b 1
155
+ echo.
156
+ echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
157
+ goto end
158
+ )
159
+
160
+ if "%1" == "latexpdf" (
161
+ %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
162
+ cd %BUILDDIR%/latex
163
+ make all-pdf
164
+ cd %~dp0
165
+ echo.
166
+ echo.Build finished; the PDF files are in %BUILDDIR%/latex.
167
+ goto end
168
+ )
169
+
170
+ if "%1" == "latexpdfja" (
171
+ %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
172
+ cd %BUILDDIR%/latex
173
+ make all-pdf-ja
174
+ cd %~dp0
175
+ echo.
176
+ echo.Build finished; the PDF files are in %BUILDDIR%/latex.
177
+ goto end
178
+ )
179
+
180
+ if "%1" == "text" (
181
+ %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
182
+ if errorlevel 1 exit /b 1
183
+ echo.
184
+ echo.Build finished. The text files are in %BUILDDIR%/text.
185
+ goto end
186
+ )
187
+
188
+ if "%1" == "man" (
189
+ %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
190
+ if errorlevel 1 exit /b 1
191
+ echo.
192
+ echo.Build finished. The manual pages are in %BUILDDIR%/man.
193
+ goto end
194
+ )
195
+
196
+ if "%1" == "texinfo" (
197
+ %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
198
+ if errorlevel 1 exit /b 1
199
+ echo.
200
+ echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
201
+ goto end
202
+ )
203
+
204
+ if "%1" == "gettext" (
205
+ %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
206
+ if errorlevel 1 exit /b 1
207
+ echo.
208
+ echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
209
+ goto end
210
+ )
211
+
212
+ if "%1" == "changes" (
213
+ %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
214
+ if errorlevel 1 exit /b 1
215
+ echo.
216
+ echo.The overview file is in %BUILDDIR%/changes.
217
+ goto end
218
+ )
219
+
220
+ if "%1" == "linkcheck" (
221
+ %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
222
+ if errorlevel 1 exit /b 1
223
+ echo.
224
+ echo.Link check complete; look for any errors in the above output ^
225
+ or in %BUILDDIR%/linkcheck/output.txt.
226
+ goto end
227
+ )
228
+
229
+ if "%1" == "doctest" (
230
+ %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
231
+ if errorlevel 1 exit /b 1
232
+ echo.
233
+ echo.Testing of doctests in the sources finished, look at the ^
234
+ results in %BUILDDIR%/doctest/output.txt.
235
+ goto end
236
+ )
237
+
238
+ if "%1" == "coverage" (
239
+ %SPHINXBUILD% -b coverage %ALLSPHINXOPTS% %BUILDDIR%/coverage
240
+ if errorlevel 1 exit /b 1
241
+ echo.
242
+ echo.Testing of coverage in the sources finished, look at the ^
243
+ results in %BUILDDIR%/coverage/python.txt.
244
+ goto end
245
+ )
246
+
247
+ if "%1" == "xml" (
248
+ %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml
249
+ if errorlevel 1 exit /b 1
250
+ echo.
251
+ echo.Build finished. The XML files are in %BUILDDIR%/xml.
252
+ goto end
253
+ )
254
+
255
+ if "%1" == "pseudoxml" (
256
+ %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml
257
+ if errorlevel 1 exit /b 1
258
+ echo.
259
+ echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml.
260
+ goto end
261
+ )
262
+
263
+ :end
@@ -0,0 +1,26 @@
1
+ Parameters are Optional
2
+ =======================
3
+
4
+ Squib is all about sane defaults and shorthand specification. Arguments to DSL methods 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.
5
+
6
+ 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.
7
+
8
+ .. highlight:: none
9
+
10
+ Note: you MUST use named parameters rather than positional parameters. For example: ``save :png`` will lead to an error like this::
11
+
12
+ 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)
13
+ from deck.rb:22:in `block in <main>'
14
+ from C:/Ruby200/lib/ruby/gems/2.0.0/gems/squib-0.0.3/lib/squib/deck.rb:60:in `instance_eval'
15
+ from C:/Ruby200/lib/ruby/gems/2.0.0/gems/squib-0.0.3/lib/squib/deck.rb:60:in `initialize'
16
+ from deck.rb:18:in `new'
17
+ from deck.rb:18:in `<main>'
18
+
19
+ Instead, you must name the parameters: `save format: :png`
20
+
21
+ .. warning::
22
+
23
+ If you provide an option to a DSL method that the DSL method does not recognize, Squib ignores the extraenous option without warning. For example, these two calls have identical behavior::
24
+
25
+ save_png prefix: 'front_'
26
+ save_png prefix: 'front_', narf: true
data/docs/server.bat ADDED
@@ -0,0 +1 @@
1
+ sphinx-autobuild . _build/html
@@ -0,0 +1,86 @@
1
+ The Mighty text Method
2
+ ======================
3
+
4
+
5
+ The :doc:`/dsl/text` method is a particularly powerful method with a ton of options. Be sure to check the option-by-option details in the DSL reference, but here are the highlights.
6
+
7
+ Fonts
8
+ -----
9
+
10
+ To set the font, your ``text`` method call will look something like this::
11
+
12
+ text str: "Hello", font: 'MyFont Bold 32'
13
+
14
+
15
+ 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 :doc:`/dsl/text` calls with different Pango font strings::
16
+
17
+ text str: "Hello", font: 'Sans 18'
18
+ text str: "Hello", font: 'Arial,Verdana weight=900 style=oblique 36'
19
+ text str: "Hello", font: 'Times New Roman,Sans 25'
20
+
21
+
22
+ Finally, 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 (see :doc:`/layouts`).
23
+
24
+ .. note::
25
+
26
+ 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. In some operating systems, you'll want to simply end with a comma::
27
+
28
+ text str: "Hello", font: 'Times New Roman, 25'
29
+
30
+ .. note::
31
+
32
+ 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.
33
+
34
+ Width and Height
35
+ ------------------
36
+
37
+ 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``.
38
+
39
+ Hints
40
+ -----
41
+
42
+ 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 :doc:`/dsl/hint` 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.
43
+
44
+ Extents
45
+ ------
46
+
47
+ 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::
48
+
49
+ Squib::Deck.new(cards: 2) do
50
+ extents = text(str: ['Hello', 'World!'])
51
+ puts extents
52
+ end
53
+
54
+ will output::
55
+
56
+ [{:width=>109, :height=>55}, {:width=>142, :height=>55}] # Hello was 109 pixels wide, World 142 pixels
57
+
58
+ Embedding Images
59
+ ------------------
60
+
61
+ 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``, which supports PNG and SVG. Here's a minimal example::
62
+
63
+ text(str: 'Gain 1 :health:') do |embed|
64
+ embed.svg key: ':health:', file: 'heart.svg'
65
+ end
66
+
67
+ Markup
68
+ ------
69
+
70
+ See :ref:`Markup <text-markup>` in :doc:`/dsl/text`.
71
+
72
+ Examples
73
+ --------
74
+
75
+ * 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>`_
76
+ * 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>`_
77
+ * 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>`_
78
+
79
+ And this one too:
80
+
81
+ .. raw:: html
82
+
83
+ <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
84
+ <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/gist-embed/2.4/gist-embed.min.js"></script>
85
+ <code data-gist-id="52d7b8e332194946bc69" data-gist-file="_text.rb"></code>
86
+ <code data-gist-id="52d7b8e332194946bc69" data-gist-file="_text_00_expected.png"></code>
data/docs/units.rst ADDED
@@ -0,0 +1,6 @@
1
+ Unit Conversion
2
+ ===============
3
+
4
+ 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`).
5
+
6
+ Example is in `samples/units.rb` found [here](https://github.com/andymeneely/squib/tree/master/samples/units.rb)
data/lib/squib.rb CHANGED
@@ -2,10 +2,10 @@ require 'logger'
2
2
  require 'cairo'
3
3
  require 'pango'
4
4
  require 'rsvg2'
5
- require 'squib/version'
6
- require 'squib/commands/new'
7
- require 'squib/deck'
8
- require 'squib/card'
5
+ require_relative 'squib/version'
6
+ require_relative 'squib/commands/new'
7
+ require_relative 'squib/deck'
8
+ require_relative 'squib/card'
9
9
 
10
10
  module Squib
11
11
 
@@ -1,15 +1,10 @@
1
+ require_relative '../args/card_range'
2
+ require_relative '../args/draw'
3
+
1
4
  module Squib
2
5
  class Deck
3
- # Fills the background with the given color
4
- # @example
5
- # background color: :white
6
- #
7
- # Options support Arrays, see {file:README.md#Arrays_and_Singleton_Expansion Arrays and Singleon Expansion}
8
- #
9
- # @option opts range [Enumerable] (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
10
- # @option opts color [String] (:black) the color the font will render to. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}.
11
- # @return [nil] nothing
12
- # @api public
6
+
7
+ # DSL method. See http://squib.readthedocs.org
13
8
  def background(opts = {})
14
9
  range = Args::CardRange.new(opts[:range], deck_size: size)
15
10
  draw = Args::Draw.new(custom_colors).load!(opts, expand_by: size, layout: layout, dpi: dpi)
@@ -1,30 +1,12 @@
1
1
  require 'roo'
2
2
  require 'csv'
3
- require 'squib/args/input_file'
4
- require 'squib/args/import'
3
+ require_relative '../args/input_file'
4
+ require_relative '../args/import'
5
+ require_relative '../args/csv_opts'
5
6
 
6
7
  module Squib
7
8
 
8
- # Pulls Excel data from `.xlsx` files into a column-based hash
9
- #
10
- # Pulls the data into a Hash of arrays based on the columns. First row is assumed to be the header row.
11
- # See the example `samples/excel.rb` in the [source repository](https://github.com/andymeneely/squib/tree/master/samples)
12
- #
13
- # @example
14
- # # Excel file looks like this:
15
- # # | h1 | h2 |
16
- # # ------------
17
- # # | 1 | 2 |
18
- # # | 3 | 4 |
19
- # data = xlsx file: 'data.xlsx', sheet: 0
20
- # => {'h1' => [1,3], 'h2' => [2,4]}
21
- #
22
- # @option opts file [String] the file to open. Must end in `.xlsx`. Opens relative to the current directory.
23
- # @option opts sheet [Integer] (0) The zero-based index of the sheet from which to read.
24
- # @option opts strip [Boolean] (true) When true, strips leading and trailing whitespace on values and headers
25
- # @option opts explode [String] ('qty') Quantity explosion will be applied to the column this name. See README for example.
26
- # @return [Hash] a hash of arrays based on columns in the spreadsheet
27
- # @api public
9
+ # DSL method. See http://squib.readthedocs.org
28
10
  def xlsx(opts = {})
29
11
  input = Args::InputFile.new(file: 'deck.xlsx').load!(opts)
30
12
  import = Args::Import.new.load!(opts)
@@ -32,47 +14,30 @@ module Squib
32
14
  s.default_sheet = s.sheets[input.sheet[0]]
33
15
  data = {}
34
16
  s.first_column.upto(s.last_column) do |col|
35
- header = s.cell(s.first_row,col).to_s
17
+ header = s.cell(s.first_row, col).to_s
36
18
  header.strip! if import.strip?
37
19
  data[header] = []
38
20
  (s.first_row + 1).upto(s.last_row) do |row|
39
- cell = s.cell(row,col)
21
+ cell = s.cell(row, col)
40
22
  # Roo hack for avoiding unnecessary .0's on whole integers (https://github.com/roo-rb/roo/issues/139)
41
- cell = s.excelx_value(row,col) if s.excelx_type(row,col) == [:numeric_or_formula, 'General']
23
+ cell = s.excelx_value(row, col) if s.excelx_type(row, col) == [:numeric_or_formula, 'General']
42
24
  cell.strip! if cell.respond_to?(:strip) && import.strip?
43
25
  cell = yield(header, cell) if block_given?
44
26
  data[header] << cell
45
- end#row
46
- end#col
27
+ end# row
28
+ end# col
47
29
  explode_quantities(data, import.explode)
48
- end#xlsx
30
+ end# xlsx
49
31
  module_function :xlsx
50
32
 
51
- # Pulls CSV data from `.csv` files into a column-based hash
52
- #
53
- # Pulls the data into a Hash of arrays based on the columns. First row is assumed to be the header row.
54
- # See the example `samples/csv.rb` in the [source repository](https://github.com/andymeneely/squib/tree/master/samples)
55
- #
56
- # @example
57
- # # File data.csv looks like this (without the comment symbols)
58
- # # h1,h2
59
- # # 1,2
60
- # # 3,4
61
- # data = csv file: 'data.csv'
62
- # => {'h1' => [1,3], 'h2' => [2,4]}
63
- #
64
- # Parsing uses Ruby's CSV, with options `{headers: true, converters: :numeric}`
65
- # http://www.ruby-doc.org/stdlib-2.0/libdoc/csv/rdoc/CSV.html
66
- #
67
- # @option opts file [String] the CSV-formatted file to open. Opens relative to the current directory.
68
- # @option opts strip [Boolean] (true) When true, strips leading and trailing whitespace on values and headers
69
- # @option opts explode [String] ('qty') Quantity explosion will be applied to the column this name. See README for example.
70
- # @return [Hash] a hash of arrays based on columns in the table
71
- # @api public
33
+ # DSL method. See http://squib.readthedocs.org
72
34
  def csv(opts = {})
73
- file = Args::InputFile.new(file: 'deck.csv').load!(opts).file[0]
35
+ # TODO refactor all this out to separate methods, and its own class
74
36
  import = Args::Import.new.load!(opts)
75
- table = CSV.read(file, headers: true, converters: :numeric)
37
+ file = Args::InputFile.new(file: 'deck.csv').load!(opts).file[0]
38
+ data = opts.key?(:data) ? opts[:data] : File.read(file)
39
+ csv_opts = Args::CSV_Opts.new(opts)
40
+ table = CSV.parse(data, csv_opts.to_hash)
76
41
  check_duplicate_csv_headers(table)
77
42
  hash = Hash.new
78
43
  table.headers.each do |header|
@@ -83,10 +48,20 @@ module Squib
83
48
  if import.strip?
84
49
  new_hash = Hash.new
85
50
  hash.each do |header, col|
86
- new_hash[header] = col.map { |str| str = str.strip if str.respond_to?(:strip); str }
51
+ new_hash[header] = col.map do |str|
52
+ str = str.strip if str.respond_to?(:strip)
53
+ str
54
+ end
87
55
  end
88
56
  hash = new_hash
89
57
  end
58
+ if block_given?
59
+ hash.each do |header, col|
60
+ col.map! do |val|
61
+ yield(header, val)
62
+ end
63
+ end
64
+ end
90
65
  return explode_quantities(hash, import.explode)
91
66
  end
92
67
  module_function :csv
@@ -101,6 +76,7 @@ module Squib
101
76
  end
102
77
  module_function :check_duplicate_csv_headers
103
78
 
79
+ # @api private
104
80
  def explode_quantities(data, qty)
105
81
  return data unless data.key? qty.to_s.strip
106
82
  qtys = data[qty]
@@ -117,12 +93,12 @@ module Squib
117
93
 
118
94
  class Deck
119
95
 
120
- # Convenience call on deck goes to the module function
96
+ # DSL method. See http://squib.readthedocs.org
121
97
  def xlsx(opts = {})
122
98
  Squib.xlsx(opts)
123
99
  end
124
100
 
125
- # Convenience call on deck goes to the module function
101
+ # DSL method. See http://squib.readthedocs.org
126
102
  def csv(opts = {})
127
103
  Squib.csv(opts)
128
104
  end