squib 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rspec +1 -0
- data/CHANGELOG.md +62 -14
- data/Gemfile +1 -1
- data/README.md +16 -10
- data/RELEASE TODO.md +2 -1
- data/Rakefile +11 -0
- data/lib/squib/api/data.rb +3 -3
- data/lib/squib/api/image.rb +7 -5
- data/lib/squib/api/save.rb +31 -2
- data/lib/squib/api/settings.rb +1 -1
- data/lib/squib/api/shapes.rb +86 -0
- data/lib/squib/api/text.rb +6 -2
- data/lib/squib/api/text_embed.rb +7 -5
- data/lib/squib/args/typographer.rb +22 -16
- data/lib/squib/card.rb +5 -5
- data/lib/squib/conf.rb +111 -0
- data/lib/squib/constants.rb +11 -31
- data/lib/squib/deck.rb +15 -48
- data/lib/squib/graphics/cairo_context_wrapper.rb +3 -1
- data/lib/squib/graphics/gradient_regex.rb +1 -0
- data/lib/squib/graphics/hand.rb +43 -0
- data/lib/squib/graphics/image.rb +5 -3
- data/lib/squib/graphics/save_doc.rb +1 -1
- data/lib/squib/graphics/shapes.rb +74 -0
- data/lib/squib/graphics/showcase.rb +5 -2
- data/lib/squib/graphics/text.rb +18 -7
- data/lib/squib/input_helpers.rb +2 -2
- data/lib/squib/version.rb +1 -1
- data/samples/csv_import.rb +3 -5
- data/samples/custom-config.yml +0 -1
- data/samples/custom_config.rb +1 -1
- data/samples/draw_shapes.rb +11 -0
- data/samples/embed_text.rb +1 -1
- data/samples/hand.rb +24 -0
- data/samples/load_images.rb +14 -0
- data/samples/sample.csv +3 -3
- data/samples/text_options.rb +4 -0
- data/spec/api/api_data_spec.rb +19 -0
- data/spec/api/api_image_spec.rb +1 -1
- data/spec/api/api_settings_spec.rb +18 -0
- data/spec/api/api_text_spec.rb +3 -3
- data/spec/conf_spec.rb +29 -0
- data/spec/data/conf/basic.yml +0 -0
- data/spec/data/conf/empty.yml +1 -0
- data/spec/data/samples/csv_import.rb.txt +4 -38
- data/spec/data/samples/custom_config.rb.txt +4 -0
- data/spec/data/samples/draw_shapes.rb.txt +57 -0
- data/spec/data/samples/hand.rb.txt +514 -0
- data/spec/data/samples/load_images.rb.txt +6 -0
- data/spec/data/samples/text_options.rb.txt +81 -0
- data/spec/data/xlsx/basic.xlsx +0 -0
- data/spec/data/xlsx/formulas.xlsx +0 -0
- data/spec/graphics/graphics_images_spec.rb +49 -48
- data/spec/graphics/graphics_shapes_spec.rb +43 -41
- data/spec/graphics/graphics_text_spec.rb +25 -11
- data/spec/samples/_diffs/gitkeep.txt +0 -0
- data/spec/samples/expected/autoscale_00.png +0 -0
- data/spec/samples/expected/autoscale_01.png +0 -0
- data/spec/samples/expected/autoscale_02.png +0 -0
- data/spec/samples/expected/backend_00.png +0 -0
- data/spec/samples/expected/backend_00.svg +78 -0
- data/spec/samples/expected/backend_01.png +0 -0
- data/spec/samples/expected/backend_01.svg +78 -0
- data/spec/samples/expected/basic_00.png +0 -0
- data/spec/samples/expected/basic_01.png +0 -0
- data/spec/samples/expected/basic_02.png +0 -0
- data/spec/samples/expected/cairo_access_00.png +0 -0
- data/spec/samples/expected/cairo_access_01.png +0 -0
- data/spec/samples/expected/card_00.png +0 -0
- data/spec/samples/expected/card_01.png +0 -0
- data/spec/samples/expected/colors_00.png +0 -0
- data/spec/samples/expected/config_disable_text_00.png +0 -0
- data/spec/samples/expected/config_text_00.png +0 -0
- data/spec/samples/expected/custom-config_00.png +0 -0
- data/spec/samples/expected/embed_00.png +0 -0
- data/spec/samples/expected/embed_multi_00.png +0 -0
- data/spec/samples/expected/embed_multi_01.png +0 -0
- data/spec/samples/expected/embed_multi_02.png +0 -0
- data/spec/samples/expected/embed_multisheet_00.png +0 -0
- data/spec/samples/expected/gitkeep.txt +0 -0
- data/spec/samples/expected/gradient_00.png +0 -0
- data/spec/samples/expected/hand.png +0 -0
- data/spec/samples/expected/hand_pretty.png +0 -0
- data/spec/samples/expected/landscape_00.png +0 -0
- data/spec/samples/expected/layout2_00.png +0 -0
- data/spec/samples/expected/layout_00.png +0 -0
- data/spec/samples/expected/layout_builtin_hand_00.png +0 -0
- data/spec/samples/expected/layout_builtin_playing_card_00.png +0 -0
- data/spec/samples/expected/load_images_00.png +0 -0
- data/spec/samples/expected/portrait_00.png +0 -0
- data/spec/samples/expected/ranges_00.png +0 -0
- data/spec/samples/expected/ranges_01.png +0 -0
- data/spec/samples/expected/ranges_02.png +0 -0
- data/spec/samples/expected/sample_csv_00.png +0 -0
- data/spec/samples/expected/sample_csv_01.png +0 -0
- data/spec/samples/expected/sample_excel_00.png +0 -0
- data/spec/samples/expected/sample_excel_01.png +0 -0
- data/spec/samples/expected/sample_excel_02.png +0 -0
- data/spec/samples/expected/save_sheet_00.png +0 -0
- data/spec/samples/expected/save_sheet_01.png +0 -0
- data/spec/samples/expected/save_sheet_range_00.png +0 -0
- data/spec/samples/expected/save_sheet_range_01.png +0 -0
- data/spec/samples/expected/save_single_sheet_00.png +0 -0
- data/spec/samples/expected/saves_notrim_01.png +0 -0
- data/spec/samples/expected/shape_00.png +0 -0
- data/spec/samples/expected/showcase.png +0 -0
- data/spec/samples/expected/showcase2.png +0 -0
- data/spec/samples/expected/showcase_individual_00.png +0 -0
- data/spec/samples/expected/showcase_individual_01.png +0 -0
- data/spec/samples/expected/showcase_individual_02.png +0 -0
- data/spec/samples/expected/showcase_individual_03.png +0 -0
- data/spec/samples/expected/text_00.png +0 -0
- data/spec/samples/expected/text_01.png +0 -0
- data/spec/samples/expected/text_02.png +0 -0
- data/spec/samples/expected/tgc_sample_00.png +0 -0
- data/spec/samples/expected/units_00.png +0 -0
- data/spec/samples/samples_regression_spec.rb +7 -5
- data/spec/samples/sanity.html.erb +28 -0
- data/spec/samples/sanity.rb +70 -0
- data/spec/spec_helper.rb +15 -1
- data/squib.gemspec +3 -1
- data/squib.sublime-project +27 -40
- metadata +177 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e26629b35f921713b8003d6ece20b788c5789645
|
4
|
+
data.tar.gz: 06b9837f88b86f6e4ddde9f9a2c603b6992a26e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c003650e034993f12f72a7a58dc781b8e64aea6989081d5cd09683cf49179adac35e7887bb4b3274c9829eb70f08c4912b615d5495fa18fd28cacf49cc319809
|
7
|
+
data.tar.gz: 4d308545d618bb3f2d56481eade0d27e60985c169444007d255079b74344e38d050facab2aa905c4786a2b9950171e6ef95b83b512c502c89dc3e144aa558347
|
data/.gitignore
CHANGED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/CHANGELOG.md
CHANGED
@@ -1,31 +1,69 @@
|
|
1
1
|
# Squib CHANGELOG
|
2
|
+
Squib follows [semantic versioning](http://semver.org).
|
2
3
|
|
3
|
-
## v0.
|
4
|
-
|
4
|
+
## v0.6.0 / Unreleased
|
5
|
+
|
6
|
+
Features:
|
7
|
+
* Added `data` field to `svg` to allow for manipulating SVG XML data directly. Works nicely with my new `game_icons` [gem](https://github.com/andymeneely/game_icons) (#65)
|
8
|
+
* Added `stroke_width` and `stroke_color` to the `text` method to outlines text. (#51)
|
9
|
+
* Added `hand` method that draws cards around a circle. See hand.rb samples (#64)
|
10
|
+
* Added an `ellipse` method to (you guessed it) draw ellipses. See the draw_shapes.rb sample (#66)
|
11
|
+
* Added a `star` method to (you guessed it) draw stars. See the draw_shapes.rb sample (#72)
|
12
|
+
* Added a `polygon` method to (you guessed it) draw polygons. See the draw_shapes.rb sample (#67)
|
13
|
+
* Upgraded roo (Excel parsing) to 2.0.0. Nothing major for Squib users, just keeping up with the times.
|
14
|
+
|
15
|
+
Bugs:
|
16
|
+
* Text embed svg and png commands default to integer so the README example works (#73).
|
17
|
+
* Fixed global text hinting (#63)
|
18
|
+
* Fixed a broken promise about fill_color in `showcase` (#71)
|
19
|
+
|
20
|
+
Compatbility:
|
21
|
+
* rsvg2 and pango updated to v2.2.5. Squib follows 2.2.x of both of those. If you run `bundle` you will automatically be upgraded. They appear to be mostly bugfix releases.
|
22
|
+
* dpi is currently removed from `config.yml` and is ONLY available in `Squib::Deck.new`. This may change in the future, however.
|
23
|
+
|
24
|
+
Chores:
|
25
|
+
* Massive internal redesigning of the way configuration options are parsed, stored, handled. No real changes are visible to the user, but this code will be more maintainable and open up the door for more flexible configuration options in the future.
|
26
|
+
* Added `rake sanity` as a visual regression test to ensure the samples don't break
|
27
|
+
* Lots of automated test refactoring
|
28
|
+
|
29
|
+
Thanks to [pickfifteen](https://github.com/pickfifteen), and [Brian Cronin](http://www.boardgamegeek.com/user/MurphyIdiot) for the bug reports!
|
30
|
+
|
31
|
+
## v0.5.1 / 2015-04-13
|
32
|
+
|
33
|
+
Bugs:
|
34
|
+
* Fixed a PDF scaling issue, so now page width and height is properly calculated from DPI (#62)
|
5
35
|
|
6
36
|
Thanks to [Brian Cronin](http://www.boardgamegeek.com/user/MurphyIdiot) for the bug report.
|
7
37
|
|
8
|
-
## v0.5.0
|
38
|
+
## v0.5.0 / 2015-04-13
|
39
|
+
Features:
|
9
40
|
* Embedding of SVGs and PNGs into text! See README, `text_options.rb`, and `embed_text.rb`, and API documentation. This was a finnicky feature, so feedback and bug reports are welcome. (#30)
|
10
41
|
* Curves! We can now do Bezier curves. Documented, and added to the sample `draw_shapes.rb` (#37).
|
11
42
|
* Smart Quotes! The `text` rule now has a `quotes: 'smart'` option where straight quotes get converted to curly quotes. Assumes UTF-8, or you can specify your own quote characters if you're not in UTF-8. (#50)
|
43
|
+
* Font-level antialiasing is inherited from global antialiasing setting (workaround until we get a better solution for #59).
|
12
44
|
|
13
45
|
Known issues
|
14
46
|
* OSX Yosemite will show this warning: `<Error>: The function ‘CGFontGetGlyphPath’ is obsolete and will be removed in an upcoming update. Unfortunately, this application, or a library it uses, is using this obsolete function, and is thereby contributing to an overall degradation of system performance.` This warning will go away when the Ruby Cairo bindings upgrades from 1.14.1 to 1.14.2.
|
15
47
|
|
16
48
|
Special thanks to [pickfifteen](https://github.com/pickfifteen) for testing, feedback, and pull requests!!
|
17
49
|
|
18
|
-
## v0.4.0
|
50
|
+
## v0.4.0 / 2015-04-28
|
51
|
+
|
52
|
+
Features:
|
19
53
|
* SVG backend support! You can now set the deck's back end to work with SVGs instead of images, making the resulting PDFs vectorized. (You can still save to PNGs too.) This was a big change for Squib, and it's got at least one known issue and probably a few more here and there. See discussion on the README for more details.
|
20
54
|
* Added config option for antialiasing method. My benchmarks showed that 'best' is only 10% slower than 'fast' on extremely alias-intensive tasks, so 'best' is the Squib default now.
|
21
|
-
|
22
|
-
|
55
|
+
|
56
|
+
Bugs:
|
57
|
+
* Stray stroke on circles after text (#35)
|
58
|
+
* Progress bar increment error (#34)
|
23
59
|
|
24
60
|
Known issues
|
25
61
|
* Masking SVGs onto an SVG backend will rasterize as an intermediate step. (#43)
|
26
62
|
* Compatibility change: gradient coordinates for the `mask` option in `svg` and `png` commands are relative to the given x,y - NOT to card as it was before.
|
27
63
|
|
28
|
-
## v0.3.0
|
64
|
+
## v0.3.0 / 2015-02-02
|
65
|
+
|
66
|
+
Features:
|
29
67
|
* Masks! The `png` and `svg` commands can be used as if they are a mask, so you can color the icon with any color you like. Can be handy for switching to black-and-white, or for reusing the same image but different colors across cards.
|
30
68
|
* Gradients! Can now specify linear or radial gradients anywhere you specify colors. See README and `samples/gradients.rb` for more details.
|
31
69
|
* Number padding! `save_png` will now pad zeros on the filenames for friendlier sorting. You can also specify your own with `count_format` using the classical format string from Ruby's `Kernel::sprintf` (mostly just C-style format strings). Default: `'%02d'. The `prefix:` option is still there too.
|
@@ -35,29 +73,39 @@ Known issues
|
|
35
73
|
|
36
74
|
Special thanks to [Shalom Craimer](https://github.com/scraimer) for the idea and proof-of-concept on gradient and mask features!
|
37
75
|
|
38
|
-
## v0.2.0
|
76
|
+
## v0.2.0 / 2015-01-12
|
77
|
+
|
78
|
+
Features:
|
39
79
|
* Added `showcase` feature to create a fancy-looking 3D reflection to showcase your cards. Documented, tested, and added a sample for it.
|
40
80
|
* Added a basic Rakefile, documented in README.
|
41
81
|
* Some internal refactoring, better testing, and more documentation with layouts
|
42
82
|
|
43
|
-
## v0.1.0
|
83
|
+
## v0.1.0 / 2014-12-31
|
84
|
+
|
85
|
+
Features:
|
44
86
|
* Added `save_sheet` command that saves a range into PNG sheets, complete with trim, gap, margin, columns, and sometimes automagically computed rows. See samples/saves.rb.
|
45
87
|
* Unit conversion! Now you can write "2in" and it will convert based on the current dpi. `save_pdf` not supported (yet).
|
46
88
|
* `png` now supports resizing, but warns you about it since it's non-ideal. Documented in yard, tested.
|
47
89
|
* Added sample `unicode.rb` to show lots of game-related unicode characters
|
90
|
+
|
91
|
+
Chores:
|
48
92
|
* More obsessive automated testing and continuous integration work.
|
49
93
|
|
50
|
-
## v0.0.6
|
94
|
+
## v0.0.6 / 2014-12-08
|
95
|
+
|
96
|
+
Features:
|
51
97
|
* Added a `csv` command that works just like `xslx`. Uses Ruby's CSV inside, with some extra checking and warnings.
|
52
98
|
* Custom layouts now support loading & merging multiple Yaml files! Updated README, docs, and sample to document it.
|
53
99
|
* Built-in layouts! Currently we support `hand.yml` and `playing-card.yml`. Documented in the `layouts.rb` sample.
|
54
100
|
* `text` now returns the ink extent rectangle of the rendered text. Updated docs and sample to document it.
|
55
101
|
* Samples now show that you can use text instead of symbols for things like `center`
|
102
|
+
|
103
|
+
Chores:
|
56
104
|
* Improved logging, and documentation on increasing logger verboseness
|
57
105
|
* Better regression testing technique that tracks when a sample has changed.
|
58
106
|
* Bumped version of Cairo to ~> 1.14
|
59
107
|
|
60
|
-
## v0.0.5
|
108
|
+
## v0.0.5 / 2014-11-03
|
61
109
|
* Image rotation for png and svg via `angle`
|
62
110
|
* New sample for demonstrating direct cairo access
|
63
111
|
* README now includes a snazzy screencast of the Sublime snippets
|
@@ -66,7 +114,7 @@ Special thanks to [Shalom Craimer](https://github.com/scraimer) for the idea and
|
|
66
114
|
* Better unit testing, now with mocking!
|
67
115
|
* Various version bumps: rspec, yard
|
68
116
|
|
69
|
-
## v0.0.4
|
117
|
+
## v0.0.4 / 2014-10-17
|
70
118
|
* Added a font size override so you can vary the font size with the same style across strings more easily
|
71
119
|
* Added text autoscale sample
|
72
120
|
* Added `extends` to custom layouts, allowing ways to modify parent data instead of just overriding it.
|
@@ -75,11 +123,11 @@ Special thanks to [Shalom Craimer](https://github.com/scraimer) for the idea and
|
|
75
123
|
* Fixed a mapping problem with triangles (thanks novalis!)
|
76
124
|
* Fixed global hint togglability
|
77
125
|
|
78
|
-
## v0.0.3
|
126
|
+
## v0.0.3 / 2014-08-30
|
79
127
|
* Redesigned the dynamic options system to make adding new commands much easier
|
80
128
|
* Singleton expansion
|
81
129
|
* Better documentation in README and throughout
|
82
130
|
* Implemented Junk Land in this version
|
83
131
|
|
84
|
-
## v0.0.1-v0.0.2
|
132
|
+
## v0.0.1-v0.0.2 / 2014-07-29
|
85
133
|
* Primordial era - base functionality
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -88,7 +88,8 @@ About the other files:
|
|
88
88
|
In addition to this README, be sure to also check out the following resources for more details:
|
89
89
|
|
90
90
|
* The `samples` directory in the [source repository](https://github.com/andymeneely/squib) has lots of examples.
|
91
|
-
* [
|
91
|
+
* [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.
|
92
|
+
* [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.
|
92
93
|
|
93
94
|
## Viewing this README
|
94
95
|
|
@@ -151,12 +152,10 @@ Most public `Deck` methods allow a `range` to be specified as a first parameter.
|
|
151
152
|
|
152
153
|
## Units
|
153
154
|
|
154
|
-
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. Example is in `samples/units.rb` found [here](https://github.com/andymeneely/squib/tree/master/samples/units.rb)
|
155
|
+
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)
|
155
156
|
|
156
157
|
{include:file:samples/units.rb}
|
157
158
|
|
158
|
-
Note: we do not support unit conversion on `save_pdf` and `Squib::Deck.new()`, [yet](https://github.com/andymeneely/squib/issues/21). We are also working on support for unit conversion within layout parsing, so using it as a part of `extends` is not yet supported.
|
159
|
-
|
160
159
|
## Specifying Colors & Gradients
|
161
160
|
|
162
161
|
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)
|
@@ -439,16 +438,21 @@ Fortunately, switching backends in Squib should be as trivial as changing the se
|
|
439
438
|
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:
|
440
439
|
|
441
440
|
* `progress_bars` (Boolean, default: false). When set to `true`, long-running operations will show a progress bar on the command line.
|
442
|
-
* `dpi` (Integer, default: 300). Used in calculations when units are used (e.g. for PDF rendering and unit conversion).
|
443
441
|
* `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.
|
444
442
|
* `custom_colors` (Hash of Colors, default: {}). Defines globally-available colors available to the deck that can be specified in commands.
|
445
443
|
* `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).
|
446
444
|
* `backend` (`svg` or `memory`, default: `memory`). Defines how Cairo will store the operations. Memory is recommended for higher quality rendering.
|
447
445
|
* `prefix` (default: `card_`). When using an SVG backend, cards are auto-saved with this prefix and `"%02d"` numbering format.
|
448
446
|
|
449
|
-
|
447
|
+
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:
|
448
|
+
|
449
|
+
```ruby
|
450
|
+
Squib::Deck.new do
|
451
|
+
puts backend # prints 'memory' by default
|
452
|
+
end
|
453
|
+
```
|
450
454
|
|
451
|
-
|
455
|
+
The following sample demonstrates the config file, found [here](https://github.com/andymeneely/squib/tree/master/samples/)
|
452
456
|
|
453
457
|
{include:file:samples/custom_config.rb}
|
454
458
|
|
@@ -519,11 +523,11 @@ Feel free to [file a bug or feature request](https://github.com/andymeneely/squi
|
|
519
523
|
|
520
524
|
If you want to test new features as I develop them, you can always point your Gemfile to the repository. Your Gemfile specification looks like this:
|
521
525
|
|
522
|
-
```
|
523
|
-
gem 'squib', :
|
526
|
+
```ruby
|
527
|
+
gem 'squib', git: 'git://github.com/andymeneely/squib', branch: 'dev'
|
524
528
|
```
|
525
529
|
* 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.
|
526
|
-
* The `master` branch is where I consider features that are done and tested, but not released yet.
|
530
|
+
* The `master` branch is where I consider features and bug that are done and tested, but not released yet.
|
527
531
|
|
528
532
|
## Contributing
|
529
533
|
|
@@ -535,6 +539,8 @@ If you want your code integrated:
|
|
535
539
|
4. Push to the branch (`git push origin my-new-feature`)
|
536
540
|
5. Create a new Pull Request
|
537
541
|
|
542
|
+
Be sure to run the unit tests and packaging with just `rake`. Also, you can check that the samples render properly with `rake sanity`.
|
543
|
+
|
538
544
|
# What's up the with the name?
|
539
545
|
|
540
546
|
Truthfully, I just thought it was a cool, simple word that was not used much in the Ruby community nor the board game community. But, now that I've committed to the name, I've realized that:
|
data/RELEASE TODO.md
CHANGED
@@ -4,9 +4,10 @@ Be sure to remember to do the following for releases. (Copy into a GitHub issue)
|
|
4
4
|
- [ ] README is updated
|
5
5
|
- [ ] Samples are updated
|
6
6
|
- [ ] `rake doc`
|
7
|
-
- [ ] Check
|
7
|
+
- [ ] Check `sample_regression_spec.rb` regression tests are all enabled (i.e. `overwrite_sample` is commented out)
|
8
8
|
- [ ] Bump version.rb
|
9
9
|
- [ ] Do a full rake locally
|
10
|
+
- [ ] `rake sanity`, and check visually
|
10
11
|
- [ ] Travis is passing on dev branch
|
11
12
|
- [ ] Merge master branch
|
12
13
|
- [ ] Create GitHub release tag
|
data/Rakefile
CHANGED
@@ -20,6 +20,10 @@ end
|
|
20
20
|
|
21
21
|
RSpec::Core::RakeTask.new(:spec)
|
22
22
|
|
23
|
+
RSpec::Core::RakeTask.new(:spec_fastonly) do |t|
|
24
|
+
t.rspec_opts = "--tag ~slow"
|
25
|
+
end
|
26
|
+
|
23
27
|
task doc: [:yarddoc, :apply_google_analytics]
|
24
28
|
|
25
29
|
YARD::Rake::YardocTask.new(:yarddoc) do |t|
|
@@ -40,6 +44,13 @@ task benchmark: [:install] do
|
|
40
44
|
end
|
41
45
|
end
|
42
46
|
|
47
|
+
task :sanity do
|
48
|
+
require_relative 'spec/samples/sanity.rb'
|
49
|
+
Sanity.new.run
|
50
|
+
end
|
51
|
+
|
52
|
+
task sanity_clean: [:install, :spec, :sanity]
|
53
|
+
|
43
54
|
task :apply_google_analytics do
|
44
55
|
# The string to replace in the html document. This is chosen to be the end
|
45
56
|
# body </body> tag. So the script can be injected as the last thing in the
|
data/lib/squib/api/data.rb
CHANGED
@@ -24,15 +24,15 @@ module Squib
|
|
24
24
|
def xlsx(opts = {})
|
25
25
|
opts = Squib::SYSTEM_DEFAULTS.merge(opts)
|
26
26
|
opts = Squib::InputHelpers.fileify(opts)
|
27
|
-
s
|
27
|
+
s = Roo::Excelx.new(opts[:file])
|
28
28
|
s.default_sheet = s.sheets[opts[:sheet]]
|
29
29
|
data = {}
|
30
30
|
s.first_column.upto(s.last_column) do |col|
|
31
31
|
header = s.cell(s.first_row,col).to_s
|
32
32
|
data[header] = []
|
33
|
-
(s.first_row+1).upto(s.last_row) do |row|
|
33
|
+
(s.first_row + 1).upto(s.last_row) do |row|
|
34
34
|
cell = s.cell(row,col)
|
35
|
-
# Roo hack for avoiding unnecessary .0's on whole integers
|
35
|
+
# Roo hack for avoiding unnecessary .0's on whole integers (https://github.com/roo-rb/roo/issues/139)
|
36
36
|
cell = s.excelx_value(row,col) if s.excelx_type(row,col) == [:numeric_or_formula, 'General']
|
37
37
|
data[header] << cell
|
38
38
|
end#row
|
data/lib/squib/api/image.rb
CHANGED
@@ -22,7 +22,7 @@ module Squib
|
|
22
22
|
# @api public
|
23
23
|
def png(opts = {})
|
24
24
|
opts = needs(opts, [:range, :files, :x, :y, :width, :height, :alpha, :layout, :blend, :angle, :mask])
|
25
|
-
Dir.chdir(
|
25
|
+
Dir.chdir(img_dir) do
|
26
26
|
@progress_bar.start('Loading PNG(s)', opts[:range].size) do |bar|
|
27
27
|
opts[:range].each do |i|
|
28
28
|
@cards[i].png(opts[:file][i],
|
@@ -34,7 +34,7 @@ module Squib
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
# Renders an entire svg file at the given location. Uses the SVG-specified units and DPI to determine the pixel width and height.
|
37
|
+
# Renders an entire svg file at the given location. Uses the SVG-specified units and DPI to determine the pixel width and height. If neither data nor file are specified for a given card, this method does nothing.
|
38
38
|
#
|
39
39
|
# See {file:samples/load-images.rb samples/load-images.rb} and {file:samples/tgc-overlay.rb samples/tgc-overlay.rb} as examples.
|
40
40
|
# @example
|
@@ -42,6 +42,7 @@ module Squib
|
|
42
42
|
#
|
43
43
|
# @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
|
44
44
|
# @option opts file [String] ('') file(s) to read in. If it's a single file, then it's use for every card in range. If the parameter is an Array of files, then each file is looked up for each card. If any of them are nil or '', nothing is done. See {file:README.md#Specifying_Files Specifying Files}. Supports Arrays, see {file:README.md#Arrays_and_Singleton_Expansion Arrays and Singleon Expansion}
|
45
|
+
# @option opts data [String] (nil) render from an SVG XML string. Overrides file if both are specified (a warning is shown) . If it's a single file, then it's use for every card in range. If the parameter is an Array of files, then each file is looked up for each card. If any of them are nil or '', nothing is done. See {file:README.md#Specifying_Files Specifying Files}. Supports Arrays, see {file:README.md#Arrays_and_Singleton_Expansion Arrays and Singleon Expansion}.
|
45
46
|
# @option opts id [String] (nil) if set, then only render the SVG element with the given id. Prefix '#' is optional. Note: the x-y coordinates are still relative to the SVG document's page. Supports Arrays, see {file:README.md#Arrays_and_Singleton_Expansion Arrays and Singleon Expansion}
|
46
47
|
# @option opts force_id [Boolean] (false) if set, then this svg will not be rendered at all if the id is empty or nil. If not set, the entire SVG is rendered. Supports Arrays, see {file:README.md#Arrays_and_Singleton_Expansion Arrays and Singleon Expansion}
|
47
48
|
# @option opts x [Integer] (0) the x-coordinate to place. Supports Arrays, see {file:README.md#Arrays_and_Singleton_Expansion Arrays and Singleon Expansion}. Supports Unit Conversion, see {file:README.md#Units Units}.
|
@@ -56,12 +57,13 @@ module Squib
|
|
56
57
|
# @return [nil] Returns nil
|
57
58
|
# @api public
|
58
59
|
def svg(opts = {})
|
59
|
-
p = needs(opts,[:range, :files, :svgid, :force_svgid, :x, :y, :width, :height,
|
60
|
-
|
60
|
+
p = needs(opts,[:range, :files, :svgdata, :svgid, :force_svgid, :x, :y, :width, :height,
|
61
|
+
:layout, :alpha, :blend, :angle, :mask])
|
62
|
+
Dir.chdir(img_dir) do
|
61
63
|
@progress_bar.start('Loading SVG(s)', p[:range].size) do |bar|
|
62
64
|
p[:range].each do |i|
|
63
65
|
unless p[:force_id][i] && p[:id][i].to_s.empty?
|
64
|
-
@cards[i].svg(p[:file][i], p[:id][i], p[:x][i], p[:y][i],
|
66
|
+
@cards[i].svg(p[:file][i], p[:data][i], p[:id][i], p[:x][i], p[:y][i],
|
65
67
|
p[:width][i], p[:height][i], p[:alpha][i], p[:blend][i], p[:angle][i],p[:mask][i])
|
66
68
|
end
|
67
69
|
bar.increment
|
data/lib/squib/api/save.rb
CHANGED
@@ -39,7 +39,7 @@ module Squib
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
# Renders a range of
|
42
|
+
# Renders a range of cards in a showcase as if they are sitting in 3D on a reflective surface
|
43
43
|
# See {file:samples/showcase.rb} for full example
|
44
44
|
#
|
45
45
|
# @example
|
@@ -51,7 +51,7 @@ module Squib
|
|
51
51
|
# @option opts [Fixnum] margin (75) the margin around the entire showcase
|
52
52
|
# @option opts [Fixnum] scale (0.8) percentage of original width of each (trimmed) card to scale to. Must be between 0.0 and 1.0, but starts looking bad around 0.6.
|
53
53
|
# @option opts [Fixnum] offset (1.1) percentage of the scaled width of each card to shift each offset. e.g. 1.1 is a 10% shift, and 0.95 is overlapping by 5%
|
54
|
-
# @option opts [String, Color] fill_color (:white) backdrop color. Usually black or white.
|
54
|
+
# @option opts [String, Color] fill_color (:white) backdrop color. Usually black or white. Supports gradients.
|
55
55
|
# @option opts [Fixnum] reflect_offset (15) the number of pixels between the bottom of the card and the reflection
|
56
56
|
# @option opts [Fixnum] reflect_strength (0.2) the starting alpha transparency of the reflection (at the top of the card). Percentage between 0 and 1. Looks more realistic at low values since even shiny surfaces lose a lot of light.
|
57
57
|
# @option opts [Fixnum] reflect_percent (0.25) the length of the reflection in percentage of the card. Larger values tend to make the reflection draw just as much attention as the card, which is not good.
|
@@ -70,5 +70,34 @@ module Squib
|
|
70
70
|
opts[:dir], opts[:file])
|
71
71
|
end
|
72
72
|
|
73
|
+
# Renders a range of cards fanned out as if in a hand. Saves as PNG.
|
74
|
+
# See {file:samples/hand.rb} for full example
|
75
|
+
#
|
76
|
+
# @example
|
77
|
+
# hand range: :all, radius: :auto, margin: 20, fill_color: :white,
|
78
|
+
# angle_range: (Math::PI / -4.0)..(Math::PI / 2),
|
79
|
+
# dir: '_output', file: 'hand1.png'
|
80
|
+
#
|
81
|
+
# @option opts [Enumerable, :all] range (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
|
82
|
+
# @option opts [Fixnum] radius (:auto) the distance from the bottom of each card to the center of the fan. If set to `:auto`, then it is computed as 30% of the card's height.
|
83
|
+
# @option opts [Range] angle_range: ((Math::PI / -4.0)..(Math::PI / 2)). The overall width of the fan, in radians. Angle of zero is a vertical card. Further negative angles widen the fan counter-clockwise and positive angles widen the fan clockwise.
|
84
|
+
# @option opts [Fixnum] trim (0) the margin around the card to trim before putting into the image
|
85
|
+
# @option opts [Fixnum] trim_radius (0) the rounded rectangle radius around the card to trim before putting into the showcase
|
86
|
+
# @option opts [Fixnum] margin (75) the margin around the entire image
|
87
|
+
# @option opts [String, Color] fill_color (:white) backdrop color. Usually black or white. Supports gradients.
|
88
|
+
# @option opts [String] dir (_output) the directory for the output to be sent to. Will be created if it doesn't exist.
|
89
|
+
# @option opts [String] file ('hand.png') the file to save in dir. Will be overwritten.
|
90
|
+
# @return [nil] Returns nothing.
|
91
|
+
# @api public
|
92
|
+
def hand(opts = {})
|
93
|
+
opts = {file: 'hand.png', fill_color: :white, radius: :auto, trim_radius: 0}
|
94
|
+
.merge(opts)
|
95
|
+
opts = needs(opts,[:range, :margin, :trim, :trim_radius, :creatable_dir, :file_to_save])
|
96
|
+
opts[:radius] = 0.3 * height if opts[:radius] == :auto
|
97
|
+
render_hand(opts[:range], opts[:radius], opts[:angle_range],
|
98
|
+
opts[:trim], opts[:trim_radius], opts[:margin],
|
99
|
+
opts[:fill_color], opts[:dir], opts[:file])
|
100
|
+
end
|
101
|
+
|
73
102
|
end
|
74
103
|
end
|
data/lib/squib/api/settings.rb
CHANGED
@@ -13,7 +13,7 @@ module Squib
|
|
13
13
|
# @return [nil] Returns nothing
|
14
14
|
# @api public
|
15
15
|
def hint(text: :off)
|
16
|
-
|
16
|
+
conf.text_hint = text
|
17
17
|
end
|
18
18
|
|
19
19
|
# Sets various defaults for this deck. Defaults can be overriden by the commands themselves when that command supports it.
|
data/lib/squib/api/shapes.rb
CHANGED
@@ -47,6 +47,7 @@ module Squib
|
|
47
47
|
# @option opts fill_color [String] ('#0000') the color with which to fill the rectangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}.
|
48
48
|
# @option opts stroke_color [String] (:black) the color with which to stroke the outside of the rectangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}.
|
49
49
|
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
50
|
+
# @option opts layout [String, Symbol] (nil) entry in the layout to use as defaults for this command. See {file:README.md#Custom_Layouts Custom Layouts}
|
50
51
|
# @return [nil] intended to be void
|
51
52
|
# @api public
|
52
53
|
def circle(opts = {})
|
@@ -59,6 +60,34 @@ module Squib
|
|
59
60
|
end
|
60
61
|
end
|
61
62
|
|
63
|
+
# Draw an ellipse
|
64
|
+
#
|
65
|
+
# @example
|
66
|
+
# ellipse x: 0, y: 0, width: 825, height: 1125
|
67
|
+
#
|
68
|
+
# Options support Arrays, see {file:README.md#Arrays_and_Singleton_Expansion Arrays and Singleon Expansion}
|
69
|
+
#
|
70
|
+
# @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
|
71
|
+
# @option opts x [Integer] (0) the x-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
|
72
|
+
# @option opts y [Integer] (0) the y-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
|
73
|
+
# @option opts width [Integer] the width of the rectangle. Supports Unit Conversion, see {file:README.md#Units Units}.
|
74
|
+
# @option opts height [Integer] the height of the rectangle. Supports Unit Conversion, see {file:README.md#Units Units}.
|
75
|
+
# @option opts fill_color [String] ('#0000') the color with which to fill the rectangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
76
|
+
# @option opts stroke_color [String] (:black) the color with which to stroke the outside of the rectangle. {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
77
|
+
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
78
|
+
# @option opts layout [String, Symbol] (nil) entry in the layout to use as defaults for this command. See {file:README.md#Custom_Layouts Custom Layouts}
|
79
|
+
# @return [nil] intended to be void
|
80
|
+
# @api public
|
81
|
+
def ellipse(opts = {})
|
82
|
+
opts = needs(opts, [:range, :x, :y, :width, :height,
|
83
|
+
:fill_color, :stroke_color, :stroke_width, :layout])
|
84
|
+
opts[:range].each do |i|
|
85
|
+
@cards[i].ellipse(opts[:x][i], opts[:y][i], opts[:width][i], opts[:height][i],
|
86
|
+
opts[:fill_color][i], opts[:stroke_color][i],
|
87
|
+
opts[:stroke_width][i])
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
62
91
|
# Draw a triangle using the given coordinates
|
63
92
|
#
|
64
93
|
# @example
|
@@ -76,6 +105,7 @@ module Squib
|
|
76
105
|
# @option opts fill_color [String] ('#0000') the color with which to fill the triangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
77
106
|
# @option opts stroke_color [String] (:black) the color with which to stroke the outside of the triangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
78
107
|
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
108
|
+
# @option opts layout [String, Symbol] (nil) entry in the layout to use as defaults for this command. See {file:README.md#Custom_Layouts Custom Layouts}
|
79
109
|
# @return [nil] intended to be void
|
80
110
|
# @api public
|
81
111
|
def triangle(opts = {})
|
@@ -102,6 +132,7 @@ module Squib
|
|
102
132
|
# @option opts y2 [Integer] (50) the y-coordinate to place. Supports Unit Conversion, see {file:README.md#Units Units}.
|
103
133
|
# @option opts stroke_color [String] (:black) the color with which to stroke the line. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}.
|
104
134
|
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
135
|
+
# @option opts layout [String, Symbol] (nil) entry in the layout to use as defaults for this command. See {file:README.md#Custom_Layouts Custom Layouts}
|
105
136
|
# @return [nil] intended to be void
|
106
137
|
# @api public
|
107
138
|
def line(opts = {})
|
@@ -126,6 +157,8 @@ module Squib
|
|
126
157
|
# @option opts cy2 [Integer] (50) the y-coordinate of the second control point. Supports Unit Conversion, see {file:README.md#Units Units}.
|
127
158
|
# @option opts stroke_color [String] (:black) the color with which to stroke the line. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}.
|
128
159
|
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
160
|
+
# @option opts fill_color [String] ('#0000') the color with which to fill the triangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
161
|
+
# @option opts layout [String, Symbol] (nil) entry in the layout to use as defaults for this command. See {file:README.md#Custom_Layouts Custom Layouts}
|
129
162
|
# @return [nil] intended to be void
|
130
163
|
# @api public
|
131
164
|
def curve(opts = {})
|
@@ -138,5 +171,58 @@ module Squib
|
|
138
171
|
end
|
139
172
|
end
|
140
173
|
|
174
|
+
# Draw a star at the given x,y
|
175
|
+
# @example
|
176
|
+
# star x: 10, y: 10, n: 5, angle: Math::PI / 4, inner_radius: 50, outer_radius: 100,
|
177
|
+
# fill_color: :green, stroke_color: :burgundy, :stroke_width: 3
|
178
|
+
#
|
179
|
+
# @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
|
180
|
+
# @option opts x [Fixnum] (0) the x-coordinate of the center. Supports Unit Conversion, see {file:README.md#Units Units}.
|
181
|
+
# @option opts y [Fixnum] (0) the y-coordinate of the center. Supports Unit Conversion, see {file:README.md#Units Units}.
|
182
|
+
# @option opts n [Integer] (5) the number of points on the star
|
183
|
+
# @option opts angle [Fixnum] (0) the angle at which to rotate
|
184
|
+
# @option opts inner_radius [Fixnum] (0) the inner radius. Supports Unit conversion.
|
185
|
+
# @option opts stroke_color [String] (:black) the color with which to stroke the line. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}.
|
186
|
+
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
187
|
+
# @option opts fill_color [String] ('#0000') the color with which to fill the triangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
188
|
+
# @option opts layout [String, Symbol] (nil) entry in the layout to use as defaults for this command. See {file:README.md#Custom_Layouts Custom Layouts}
|
189
|
+
# @return [nil] intended to be void
|
190
|
+
# @api public
|
191
|
+
def star(opts = {})
|
192
|
+
opts = needs(opts, [:range, :x, :y, :n, :angle, :inner_radius, :outer_radius,
|
193
|
+
:layout, :fill_color, :stroke_color, :stroke_width])
|
194
|
+
opts[:range].each do |i|
|
195
|
+
@cards[i].star(opts[:x][i], opts[:y][i], opts[:n][i], opts[:angle][i],
|
196
|
+
opts[:inner_radius][i], opts[:outer_radius][i],
|
197
|
+
opts[:fill_color][i], opts[:stroke_color][i],
|
198
|
+
opts[:stroke_width][i])
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
# Draw a regular polygon at the given x,y
|
203
|
+
# @example
|
204
|
+
# polygon x: 10, y: 10, n: 5, angle: Math::PI / 4, radius: 50,
|
205
|
+
# fill_color: :green, stroke_color: :burgundy, :stroke_width: 3
|
206
|
+
#
|
207
|
+
# @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
|
208
|
+
# @option opts x [Fixnum] (0) the x-coordinate of the center. Supports Unit Conversion, see {file:README.md#Units Units}.
|
209
|
+
# @option opts y [Fixnum] (0) the y-coordinate of the center. Supports Unit Conversion, see {file:README.md#Units Units}.
|
210
|
+
# @option opts n [Integer] (5) the number of points on the star
|
211
|
+
# @option opts angle [Fixnum] (0) the angle at which to rotate
|
212
|
+
# @option opts stroke_color [String] (:black) the color with which to stroke the line. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}.
|
213
|
+
# @option opts stroke_width [Decimal] (2.0) the width of the outside stroke. Supports Unit Conversion, see {file:README.md#Units Units}.
|
214
|
+
# @option opts fill_color [String] ('#0000') the color with which to fill the triangle. See {file:README.md#Specifying_Colors___Gradients Specifying Colors & Gradients}
|
215
|
+
# @option opts layout [String, Symbol] (nil) entry in the layout to use as defaults for this command. See {file:README.md#Custom_Layouts Custom Layouts}
|
216
|
+
# @return [nil] intended to be void
|
217
|
+
# @api public
|
218
|
+
def polygon(opts = {})
|
219
|
+
opts = needs(opts, [:range, :x, :y, :n, :circle_radius, :angle, :layout, :fill_color, :stroke_color, :stroke_width])
|
220
|
+
opts[:range].each do |i|
|
221
|
+
@cards[i].polygon(opts[:x][i], opts[:y][i], opts[:n][i], opts[:angle][i], opts[:radius][i],
|
222
|
+
opts[:fill_color][i], opts[:stroke_color][i],
|
223
|
+
opts[:stroke_width][i])
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
141
227
|
end
|
142
228
|
end
|