squib 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +9 -0
  4. data/README.md +38 -33
  5. data/Rakefile +1 -1
  6. data/bin/squib +6 -6
  7. data/lib/squib.rb +8 -8
  8. data/lib/squib/api/background.rb +3 -3
  9. data/lib/squib/api/data.rb +5 -6
  10. data/lib/squib/api/image.rb +13 -10
  11. data/lib/squib/api/save.rb +4 -5
  12. data/lib/squib/api/settings.rb +4 -4
  13. data/lib/squib/api/shapes.rb +20 -20
  14. data/lib/squib/api/text.rb +11 -11
  15. data/lib/squib/api/units.rb +4 -4
  16. data/lib/squib/card.rb +5 -5
  17. data/lib/squib/commands/new.rb +5 -5
  18. data/lib/squib/constants.rb +10 -10
  19. data/lib/squib/deck.rb +24 -22
  20. data/lib/squib/graphics/background.rb +3 -3
  21. data/lib/squib/graphics/image.rb +13 -6
  22. data/lib/squib/graphics/save_doc.rb +13 -11
  23. data/lib/squib/graphics/save_images.rb +3 -3
  24. data/lib/squib/graphics/shapes.rb +9 -8
  25. data/lib/squib/graphics/text.rb +61 -59
  26. data/lib/squib/input_helpers.rb +13 -13
  27. data/lib/squib/progress.rb +4 -4
  28. data/lib/squib/project_template/Gemfile +1 -1
  29. data/lib/squib/project_template/deck.rb +3 -3
  30. data/lib/squib/version.rb +6 -2
  31. data/samples/autoscale_font.rb +4 -4
  32. data/samples/basic.rb +6 -7
  33. data/samples/cairo_access.rb +27 -0
  34. data/samples/colors.rb +2 -2
  35. data/samples/custom-layout.yml +5 -5
  36. data/samples/custom_config.rb +4 -4
  37. data/samples/draw_shapes.rb +8 -8
  38. data/samples/hello_world.rb +2 -3
  39. data/samples/load_images.rb +6 -1
  40. data/samples/portrait-landscape.rb +7 -7
  41. data/samples/ranges.rb +13 -14
  42. data/samples/save_pdf.rb +2 -2
  43. data/samples/text_options.rb +17 -17
  44. data/samples/tgc_proofs.rb +3 -3
  45. data/samples/use_layout.rb +3 -3
  46. data/spec/api/api_text_spec.rb +11 -17
  47. data/spec/commands/new_spec.rb +10 -10
  48. data/spec/data/easy-circular-extends.yml +1 -1
  49. data/spec/data/hard-circular-extends.yml +2 -2
  50. data/spec/data/multi-extends-single-entry.yml +3 -3
  51. data/spec/data/multi-level-extends.yml +1 -1
  52. data/spec/data/no-extends.yml +2 -2
  53. data/spec/data/pre-extends.yml +1 -1
  54. data/spec/data/self-circular-extends.yml +1 -1
  55. data/spec/data/single-extends.yml +1 -1
  56. data/spec/data/single-level-multi-extends.yml +1 -1
  57. data/spec/deck_spec.rb +62 -62
  58. data/spec/graphics/graphics_images_spec.rb +79 -0
  59. data/spec/graphics/graphics_save_doc_spec.rb +66 -0
  60. data/spec/graphics/graphics_shapes_spec.rb +74 -0
  61. data/spec/graphics/graphics_text_spec.rb +135 -0
  62. data/spec/input_helpers_spec.rb +61 -40
  63. data/spec/samples_run_spec.rb +6 -6
  64. data/spec/spec_helper.rb +32 -1
  65. data/squib.gemspec +21 -21
  66. metadata +22 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1eaf4fffac6ef2713fd716e57d2162ccbdae7bf1
4
- data.tar.gz: 6b4356a3d3eed20f2ca31afc9c2c0d793d99f56d
3
+ metadata.gz: 88dc6fa44ed331fbc2a3985342f8643411150ccf
4
+ data.tar.gz: 53688a6d02c0f26ab0f80a0e6cad0c801e101305
5
5
  SHA512:
6
- metadata.gz: 529ff608835a86dd65af5ff327d494ec26940077253d9f3d543fe1cff952f5f6cc7263879ab4a0e3a8dfd271c1803f61be54eef6ee9c8c55ac4eeba46a98e087
7
- data.tar.gz: fc032c6d63a16ca605084793c8e44e10eae6973d239cf694e46f0e27e2df239a77ccd46cb2f45892a8f260a97d4acd65a3201ec0345b770a79d56aa88a96156c
6
+ metadata.gz: 45d3440c0f8e28a459d12a89a650ec30e0c6d3d8b1c22b1ca558927af336d4f9f0be562ce7b50c3e52a1bfd3c08cfd0973b7e8e15b405fee66727fd3c1f6002b
7
+ data.tar.gz: d2d258e94fdaf3be396de46dc3ffccd8ce55c87735b714657a2d60c42f063ca1a6ac0c7ad4cc8bb8fce1ac10c76865d266d656f91f0707c13d1aece99ad3a869
data/.gitignore CHANGED
@@ -27,3 +27,4 @@ samples/_img
27
27
  samples/_output/*.png
28
28
  samples/_output/*.pdf
29
29
  samples/_output/foo
30
+ rubocop.txt
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Squib CHANGELOG
2
2
 
3
+ ## v0.0.5
4
+ * Image rotation for png and svg via `angle`
5
+ * New sample for demonstrating direct cairo access
6
+ * README now includes a snazzy screencast of the Sublime snippets
7
+ * Rotation of text works more conventionally now, and works with text hints
8
+ * Better code styles thanks to RuboCop
9
+ * Better unit testing, now with mocking!
10
+ * Various version bumps: rspec, yard
11
+
3
12
  ## v0.0.4
4
13
  * Added a font size override so you can vary the font size with the same style across strings more easily
5
14
  * Added text autoscale sample
data/README.md CHANGED
@@ -9,20 +9,20 @@ Squib is a Ruby [DSL](http://en.wikipedia.org/wiki/Domain-specific_language) for
9
9
  * Rendering decks to PNGs and PDFs
10
10
  * Data-driven layouts
11
11
  * Unit conversion
12
- * Plus the full power of Ruby!
12
+ * Plus the full power of Ruby!
13
13
 
14
- Check this out.
14
+ Check this out.
15
15
 
16
16
  ```ruby
17
17
  require 'squib'
18
18
 
19
- Squib::Deck.new do
20
- text str: 'Hello, World!'
19
+ Squib::Deck.new(cards: 2) do
20
+ text str: %w(Hello World!)
21
21
  save_png
22
22
  end
23
23
  ```
24
24
 
25
- We just created a deck with 1 card, 825x1125 pixels, with the string "Hello, World" in the upper-left corner, saved to a PNG.
25
+ We just created a 2-card deck with "Hello" on the first card, and "World" on the second, and saved them out to PNGs.
26
26
 
27
27
  ## Installation
28
28
 
@@ -38,7 +38,7 @@ And then execute:
38
38
 
39
39
  $ bundle
40
40
 
41
- Note: Squib has some native dependencies, such as [Cairo](https://github.com/rcairo/rcairo), [Pango](http://ruby-gnome2.sourceforge.jp/hiki.cgi?Pango%3A%3ALayout), and [Nokogiri](http://nokogiri.org/), which all require DevKit to compile C code. This is usually not painful, but can cause headaches on some setups. For Windows users, I *strongly* recommend using the *non-64 bit* RubyInstaller at http://rubyinstaller.org. For Mac, I recommend using [rvm](https://rvm.io).
41
+ Note: Squib has some native dependencies, such as [Cairo](https://github.com/rcairo/rcairo), [Pango](http://ruby-gnome2.sourceforge.jp/hiki.cgi?Pango%3A%3ALayout), and [Nokogiri](http://nokogiri.org/), which all require DevKit to compile C code. This is usually not painful, but can cause headaches on some setups. For Windows users, I *strongly* recommend using the *non-64 bit* RubyInstaller at http://rubyinstaller.org. For Mac, I recommend using [rvm](https://rvm.io).
42
42
 
43
43
  Note: Squib requires Ruby 2.0 or later.
44
44
 
@@ -75,38 +75,36 @@ The central file here is `deck.rb`. Here's a [basic example](https://github.com/
75
75
  After going over this README, here are some other places to go learn Squib:
76
76
 
77
77
  * The YARD-generated API documentation [for the latest Squib gem](http://rubydoc.info/gems/squib/) is a method-by-method reference. The `Deck` class is the main class to look at. If you are following Squib master, see [the latest version](http://rubydoc.info/github/andymeneely/squib)
78
- * The `samples` directory in the [source repository](https://github.com/andymeneely/squib) has lots of examples. To run them, you will need to clone the repository and run them with Squib installed.
78
+ * The `samples` directory in the [source repository](https://github.com/andymeneely/squib) has lots of examples. To run them, you will need to clone the repository and run them with Squib installed.
79
79
  * [Junk Land](https://github.com/andymeneely/junk-land) is my own creation that's uses Squib for both black-and-white print-and-play and full color.
80
80
 
81
81
  ## Viewing this README
82
82
 
83
- If you're viewing this on Github, you might see some confusing tags like `{include:file:...}` - these are directives for YARD to show the embedded examples. The samples can be found on this repository, and are quite helpful. If you want to see this documentation in YARD,
83
+ The best place to read this documentation is on [our website](http://andymeneely.github.io/squib/doc).
84
84
 
85
- Sadly, RubyDoc.info is buggy and doesn't support `{include:file...}` directive properly, so these online links will still not show the samples inline:
86
-
87
- * The [latest Gem release](http://rubydoc.info/gems/squib/)
88
- * The [master branch](http://rubydoc.info/github/andymeneely/squib) of this repository
89
-
90
- To view this locally, you can do the following
85
+ If you want to view it offline, you can do the following
91
86
 
92
87
  ```sh
93
88
  $ gem install yard
94
89
  $ yard server --gems
95
90
  ```
96
-
97
91
  Then go to [http://localhost:8808/docs/squib/file/README.md](http://localhost:8808/docs/squib/file/README.md)
98
92
 
93
+ If you're viewing this on Github, you might see some confusing tags like `{include:file:...}` - these are directives for YARD to show the embedded examples. Github doesn't render those and you might find them helpful.
94
+
95
+ Also, RubyDoc.info linked from RubyGems is buggy and doesn't support `{include:file...}` directive properly, so the embedded samples will also not show up there.
96
+
99
97
  ## Squib API
100
98
 
101
99
  The Squib DSL is based on a collection of methods provided to the `Squib::Deck` class. The general philosophy of Squib is to specify as little as possible with layers of defaults, highly flexible input, and good ol' Ruby duck-typing. Ruby does a lot to make Squib useful.
102
100
 
103
- Squib essentially has two main classes: `Deck` and `Card`. `Deck` is the front-end, and `Card` is the back-end. The contract of `Deck` is to do the various manipulations of options and then delegate the operation to `Card` to do the low-level graphical operations.
101
+ Squib essentially has two main classes: `Deck` and `Card`. `Deck` is the front-end, and `Card` is the back-end. The contract of `Deck` is to do the various manipulations of options and then delegate the operation to `Card` to do the low-level graphical operations.
104
102
 
105
103
  For most users, I recommending solely using `Deck` methods. If you want to roll up your sleeves and get your hands messy, you can access the Cairo or Pango contexts the directly via the `Card` class. The API documentation doesn't really cover these, however, so you're on your own there.
106
104
 
107
105
  ## Specifying Parameters
108
106
 
109
- Squib is all about sane defaults and shorthand specification. Arguments are almost always using hashes, which look a lot like [Ruby 2.0's named parameters](http://www.ruby-doc.org/core-2.0.0/doc/syntax/calling_methods_rdoc.html#label-Keyword+Arguments). This means you can specify your parameters in any order you please. All parameters are optional. For example `x` and `y` default to 0 (i.e. the upper-left corner of the card). Any parameter that is specified in the command overrides any Squib defaults, `config.yml` settings, or layout rules.
107
+ Squib is all about sane defaults and shorthand specification. Arguments are almost always using hashes, which look a lot like [Ruby 2.0's named parameters](http://www.ruby-doc.org/core-2.0.0/doc/syntax/calling_methods_rdoc.html#label-Keyword+Arguments). This means you can specify your parameters in any order you please. All parameters are optional. For example `x` and `y` default to 0 (i.e. the upper-left corner of the card). Any parameter that is specified in the command overrides any Squib defaults, `config.yml` settings, or layout rules.
110
108
 
111
109
  Note: you MUST use named parameters rather than positional parameters. For example: `save :png` will lead to an error like this:
112
110
 
@@ -151,17 +149,17 @@ Colors can be specified in a wide variety of ways, mostly in a hex-string. Take
151
149
 
152
150
  {include:file:samples/colors.rb}
153
151
 
154
- Under the hood, Squib uses the `rcairo` [color parser](https://github.com/rcairo/rcairo/blob/master/lib/cairo/color.rb) to accept a variety of color specifications, along with over [300 pre-defined constants](https://github.com/rcairo/rcairo/blob/master/lib/cairo/colors.rb).
152
+ Under the hood, Squib uses the `rcairo` [color parser](https://github.com/rcairo/rcairo/blob/master/lib/cairo/color.rb) to accept a variety of color specifications, along with over [300 pre-defined constants](https://github.com/rcairo/rcairo/blob/master/lib/cairo/colors.rb).
155
153
 
156
154
  ## Specifying Files
157
155
 
158
- All files opened for reading or writing (e.g. for `png` and `xlsx`) are opened relative to the current directory. Files opened for writing (e.g. for `save_png`) will be overwritten without warning.
156
+ All files opened for reading or writing (e.g. for `png` and `xlsx`) are opened relative to the current directory. Files opened for writing (e.g. for `save_png`) will be overwritten without warning.
159
157
 
160
158
  ## Custom Layouts
161
159
 
162
- Working with x-y coordinates all the time can be tiresome, and ideally everything in a game prototype should be data-driven and easily changed. For this, many Squib methods allow for a `layout` to be set. In essence, layouts are a way of setting default values for any argument given to the command.
160
+ Working with x-y coordinates all the time can be tiresome, and ideally everything in a game prototype should be data-driven and easily changed. For this, many Squib methods allow for a `layout` to be set. In essence, layouts are a way of setting default values for any argument given to the command.
163
161
 
164
- To use a layout, set the `layout:` option on a `Deck.new` command to point to a YAML file. Any command that allows a `layout` option can be set with a Ruby symbol or String, and the command will then load the specified `x`, `y`, `width`, and `height`. The individual command can also override these options.
162
+ To use a layout, set the `layout:` option on a `Deck.new` command to point to a YAML file. Any command that allows a `layout` option can be set with a Ruby symbol or String, and the command will then load the specified `x`, `y`, `width`, and `height`. The individual command can also override these options.
165
163
 
166
164
  Note: YAML is very finnicky about having not allowing tabs. Use two spaces for indentation instead. If you get a `Psych` syntax error, this is likely the culprit. Indendation is also strongly enforced in Yaml too. See the [Yaml docs](http://www.yaml.org/YAML_for_ruby.html).
167
165
 
@@ -183,14 +181,14 @@ icon_left
183
181
  # The layout for icon_left will have the width/height from icon!
184
182
  ```
185
183
 
186
- Also!! Squib provides a more feature-rich way of merging: the `extends` key in layouts. When defining an extends key, we can merge in another key and modify data coming in if we want to. This allows us to do things like set an inner object that changes its location based on its parent.
184
+ Also!! Squib provides a more feature-rich way of merging: the `extends` key in layouts. When defining an extends key, we can merge in another key and modify data coming in if we want to. This allows us to do things like set an inner object that changes its location based on its parent.
187
185
 
188
186
  ```yaml
189
- yin:
187
+ yin:
190
188
  x: 100
191
189
  y: 100
192
190
  radius: 100
193
- yang:
191
+ yang:
194
192
  extends: yin
195
193
  x: += 50
196
194
  ```
@@ -203,7 +201,7 @@ See the `use_layout` sample found [here](https://github.com/andymeneely/squib/tr
203
201
 
204
202
  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:
205
203
 
206
- * `progress_bars` (Boolean, default: false). When set to `true`, long-running operations will show a progress bar on the command line.
204
+ * `progress_bars` (Boolean, default: false). When set to `true`, long-running operations will show a progress bar on the command line.
207
205
  * `dpi` (Integer, default: 300). Used in calculations when units are used (e.g. for PDF rendering and unit conversion).
208
206
  * `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.
209
207
  * `custom_colors` (Hash of Colors, default: {}). Defines globally-available colors available to the deck that can be specified in commands.
@@ -214,29 +212,36 @@ See the `custom_config` sample found [here](https://github.com/andymeneely/squib
214
212
 
215
213
  {include:file:samples/custom_config.rb}
216
214
 
217
- ## Staying DRY (Don't Repeat Yourself)
215
+ ## Staying DRY
218
216
 
219
- Squib tries to keep you DRY with the following features:
217
+ Squib tries to keep you DRY (Don't Repeat Yourself) with the following features:
220
218
 
221
- * Custom layouts allow you to specify various arguments in a separate file. This is great for x-y coordinates and alignment properties that would otherwise clutter up perfectly readable code. Yaml's "merge keys" takes this a step further and lets you specify base styles that can then be extended by other styles.
219
+ * Custom layouts allow you to specify various arguments in a separate file. This is great for x-y coordinates and alignment properties that would otherwise clutter up perfectly readable code. Yaml's "merge keys" takes this a step further and lets you specify base styles that can then be extended by other styles. Squib goes even further and has a special "extends" that works especially well for grouped-together styles.
222
220
  * Flexible ranges and array handling: the `range` parameter in Squib is very flexible, meaning that one `text` command can specify different text in different fonts, styles, colors, etc. for each card. If you find yourself doing multiple `text` command for the same field across different ranges of cards, there's probably a better way to condense.
223
- * Custom colors keep you from hardcoding magic color strings everywhere. Custom colors are entered into the `config.yml` file.
221
+ * Custom colors keep you from hardcoding magic color strings everywhere. Custom colors go into `config.yml` file.
222
+ * Plus, you know, Ruby.
224
223
 
225
224
  ## Source control
226
225
 
227
- You are using source control, right??
226
+ You are using source control, right??
228
227
 
229
228
  By default, Squib assumes Git. But it's not dogmatic about it. Tracking your progress, backing up, sharing data, topic branches, release management, and reverting into history are just some of the many, many useful things you can do with source control. For me, I tend to ignore any auto-generated files in my output folder, but version control everything else. I also try to keep my graphics vector files, so the files stay small. Version control is intended for source code, so large binary files don't usually get checked in unless absolutely necessary. For big binaries with graphics I tend to keep those
230
229
 
230
+ ## SublimeText
231
+
232
+ Using SublimeText? I like you already. I've written up some Squib snippets to ease remembering Squib commands. It's called `Squib Snippets` on Package Control. Compatible with SublimeText 3. Source code is also [on Github](https://github.com/andymeneely/sublime-squib) (contributions welcome!). Check it out:
233
+
234
+ ![Sublime Squib Snippets](https://raw.githubusercontent.com/andymeneely/squib/screencasts/sublime-squib-snippets.gif)
235
+
231
236
  ## Decks with multiple orientations or sizes
232
237
 
233
- If you want to make a deck that has some portrait and some landscape cards, I recommend you use multiple `Squib::Deck`s. The pixel size of a given card is designed to not change thorughout the life of a `Squib::Deck`. To work with landscape cards, there is a `rotate` option on `save_png` so you can render your print-on-demand PNGs in portrait but keep everything ekse oriented toward landscape. The following example demonstrates how to do this, found [here](https://github.com/andymeneely/squib/tree/master/samples/portrait-landscape.rb).
238
+ If you want to make a deck that has some portrait and some landscape cards, I recommend you use multiple `Squib::Deck`s. The pixel size of a given card is designed to not change thorughout the life of a `Squib::Deck`. To work with landscape cards, there is a `rotate` option on `save_png` so you can render your print-on-demand PNGs in portrait but keep everything else oriented toward landscape. The following example demonstrates how to do this, found [here](https://github.com/andymeneely/squib/tree/master/samples/portrait-landscape.rb).
234
239
 
235
240
  {include:file:samples/portrait-landscape.rb}
236
241
 
237
242
  # Development
238
243
 
239
- Squib is currently in pre-release alpha, so the API is still maturing. If you are using Squib, however, I'd love to hear about it! Feel free to [file a bug or feature request](https://github.com/andymeneely/squib/issues).
244
+ Squib is currently in pre-release alpha, so the API is still maturing. I do change my mind about the names and meaning of things at this stage. If you are using Squib, however, I'd love to hear about it! Feel free to [file a bug or feature request](https://github.com/andymeneely/squib/issues).
240
245
 
241
246
  # Contributing
242
247
 
@@ -254,4 +259,4 @@ Truthfully, I just thought it was a cool, simple word that was not used much in
254
259
 
255
260
  * Squibs are small explosive devices, much like Squib "explodes" your rules into a playable game
256
261
  * Squibs are often used in heist movies, leading to a sudden plot twist that often resembles the twists of good tabletop game
257
- * Squibs are also part of the Harry Potter world - they are people who are non-magical but wizard-born. Squib is aware of wizarding magic and comes from that heritage, but it's not magical itself.
262
+ * Squibs are also part of the Harry Potter world - they are people who are non-magical but wizard-born. Squib is aware of wizarding magic and comes from that heritage, but it's not magical itself.
data/Rakefile CHANGED
@@ -3,7 +3,7 @@ require 'rspec/core/rake_task'
3
3
  require 'yard'
4
4
 
5
5
  RSpec::Core::RakeTask.new(:spec)
6
- task :default => [:install, :spec]
6
+ task default: [:install, :spec]
7
7
 
8
8
  YARD::Rake::YardocTask.new(:doc) do |t|
9
9
  t.files = ['lib/**/*.rb', 'samples/**/*.rb'] # optional
data/bin/squib CHANGED
@@ -4,16 +4,16 @@ require 'mercenary'
4
4
 
5
5
  Mercenary.program(:squib) do |p|
6
6
  p.version Squib::VERSION
7
- p.description "A Ruby DSL for prototyping card games"
8
- p.syntax "squib <subcommand> [options]"
7
+ p.description 'A Ruby DSL for prototyping card games'
8
+ p.syntax 'squib <subcommand> [options]'
9
9
 
10
10
  p.command(:new) do |c|
11
- c.syntax "new PATH"
12
- c.description "Creates a new Squib project scaffolding in PATH. Must be a new directory or already empty."
11
+ c.syntax 'new PATH'
12
+ c.description 'Creates a new Squib project scaffolding in PATH. Must be a new directory or already empty.'
13
13
 
14
14
  c.action do |args, options|
15
15
  Squib::Commands::New.new.process(args)
16
16
  end
17
17
  end
18
-
19
- end
18
+
19
+ end
data/lib/squib.rb CHANGED
@@ -8,25 +8,25 @@ require 'squib/deck'
8
8
  require 'squib/card'
9
9
 
10
10
  module Squib
11
-
11
+
12
12
  # Access the internal logger that Squib uses. By default, Squib configure the logger to the WARN level
13
- # Use this to suppress or increase output levels.
13
+ # Use this to suppress or increase output levels.
14
14
  # @example
15
15
  # Squib.logger.level = Logger::DEBUG #show waaaay more information than you probably need, unless you're a dev
16
16
  # Squib.logger.level = Logger::ERROR #basically turns it off
17
- #
17
+ #
18
18
  # @return [Logger] the ruby logger
19
- # @api public
19
+ # @api public
20
20
  def logger
21
21
  if @logger.nil?
22
22
  @logger = Logger.new(STDOUT);
23
23
  @logger.level = Logger::WARN;
24
- @logger.formatter = proc do |severity, datetime, progname, msg|
25
- "#{severity} #{progname}: #{msg}\n"
24
+ @logger.formatter = proc do |severity, datetime, m_progname, msg|
25
+ "#{datetime} #{severity}: #{msg}\n"
26
26
  end
27
27
  end
28
28
  @logger
29
29
  end
30
30
  module_function :logger
31
-
32
- end
31
+
32
+ end
@@ -1,6 +1,6 @@
1
1
  module Squib
2
2
  class Deck
3
- # Fills the background with the given color
3
+ # Fills the background with the given color
4
4
  # @example
5
5
  # background color: :white
6
6
  #
@@ -14,6 +14,6 @@ module Squib
14
14
  opts = needs(opts,[:range, :color])
15
15
  opts[:range].each { |i| @cards[i].background(opts[:color][i]) }
16
16
  end
17
-
17
+
18
18
  end
19
- end
19
+ end
@@ -4,13 +4,13 @@ module Squib
4
4
 
5
5
  # Pulls Excel data from `.xlsx` files into a column-based hash
6
6
  #
7
- # Pulls the data into a Hash of arrays based on the columns. First row is assumed to be the header row.
7
+ # Pulls the data into a Hash of arrays based on the columns. First row is assumed to be the header row.
8
8
  # See the example `samples/excel.rb` in the [source repository](https://github.com/andymeneely/squib/tree/master/samples)
9
9
  #
10
10
  # @example
11
11
  # # Excel file looks like this:
12
12
  # # | h1 | h2 |
13
- # # ------------
13
+ # # ------------
14
14
  # # | 1 | 2 |
15
15
  # # | 3 | 4 |
16
16
  # data = xlsx file: 'data.xlsx', sheet: 0
@@ -32,7 +32,7 @@ module Squib
32
32
  (s.first_row+1).upto(s.last_row) do |row|
33
33
  cell = s.cell(row,col)
34
34
  # Roo hack for avoiding unnecessary .0's on whole integers
35
- cell = s.excelx_value(row,col) if s.excelx_type(row,col) == [:numeric_or_formula, "General"]
35
+ cell = s.excelx_value(row,col) if s.excelx_type(row,col) == [:numeric_or_formula, 'General']
36
36
  data[header] << cell
37
37
  end#row
38
38
  end#col
@@ -41,12 +41,11 @@ module Squib
41
41
  module_function :xlsx
42
42
 
43
43
  class Deck
44
-
44
+
45
45
  # Convenience call for Squib.xlsx
46
46
  def xlsx(opts = {})
47
47
  Squib.xlsx(opts)
48
- end
48
+ end
49
49
 
50
50
  end
51
51
  end
52
-
@@ -15,14 +15,16 @@ module Squib
15
15
  # @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}. Supports Arrays, see {file:README.md#Arrays_and_Singleton_Expansion Arrays and Singleon Expansion}
16
16
  # @option opts alpha [Decimal] (1.0) the alpha-transparency percentage used to blend this image. Supports Arrays, see {file:README.md#Arrays_and_Singleton_Expansion Arrays and Singleon Expansion}
17
17
  # @option opts blend [:none, :multiply, :screen, :overlay, :darken, :lighten, :color_dodge, :color_burn, :hard_light, :soft_light, :difference, :exclusion, :hsl_hue, :hsl_saturation, :hsl_color, :hsl_luminosity] (:none) the composite blend operator used when applying this image. See Blend Modes at http://cairographics.org/operators. Supports Arrays, see {file:README.md#Arrays_and_Singleton_Expansion Arrays and Singleon Expansion}
18
+ # @option opts angle [FixNum] (0) Rotation of the in radians. Note that this rotates around the upper-left corner, making the placement of x-y coordinates slightly tricky. Supports Arrays, see {file:README.md#Arrays_and_Singleton_Expansion Arrays and Singleon Expansion}
18
19
  # @return [nil] Returns nil
19
20
  # @api public
20
21
  def png(opts = {})
21
- opts = needs(opts, [:range, :files, :x, :y, :alpha, :layout, :blend])
22
+ opts = needs(opts, [:range, :files, :x, :y, :alpha, :layout, :blend, :angle])
22
23
  Dir.chdir(@img_dir) do
23
- @progress_bar.start("Loading PNG(s)", opts[:range].size) do |bar|
24
- opts[:range].each do |i|
25
- @cards[i].png(opts[:file][i], opts[:x][i], opts[:y][i], opts[:alpha][i], opts[:blend][i])
24
+ @progress_bar.start('Loading PNG(s)', opts[:range].size) do |bar|
25
+ opts[:range].each do |i|
26
+ @cards[i].png(opts[:file][i], opts[:x][i], opts[:y][i],
27
+ opts[:alpha][i], opts[:blend][i], opts[:angle][i])
26
28
  bar.increment
27
29
  end
28
30
  end
@@ -32,7 +34,7 @@ module Squib
32
34
  # Renders an entire svg file at the given location. Uses the SVG-specified units and DPI to determine the pixel width and height.
33
35
  #
34
36
  # See {file:samples/load-images.rb samples/load-images.rb} and {file:samples/tgc-overlay.rb samples/tgc-overlay.rb} as examples.
35
- # @example
37
+ # @example
36
38
  # svg 1..2, 'icon.svg', '#stone', x: 50, y:50
37
39
  #
38
40
  # @option opts range [Enumerable, :all] (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
@@ -46,16 +48,17 @@ module Squib
46
48
  # @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}. Supports Arrays, see {file:README.md#Arrays_and_Singleton_Expansion Arrays and Singleon Expansion}
47
49
  # @option opts alpha [Decimal] (1.0) the alpha-transparency percentage used to blend this image. Supports Arrays, see {file:README.md#Arrays_and_Singleton_Expansion Arrays and Singleon Expansion}
48
50
  # @option opts blend [:none, :multiply, :screen, :overlay, :darken, :lighten, :color_dodge, :color_burn, :hard_light, :soft_light, :difference, :exclusion, :hsl_hue, :hsl_saturation, :hsl_color, :hsl_luminosity] (:none) the composite blend operator used when applying this image. See Blend Modes at http://cairographics.org/operators. Supports Arrays, see {file:README.md#Arrays_and_Singleton_Expansion Arrays and Singleon Expansion}
51
+ # @option opts angle [FixNum] (0) Rotation of the in radians. Note that this rotates around the upper-left corner, making the placement of x-y coordinates slightly tricky. Supports Arrays, see {file:README.md#Arrays_and_Singleton_Expansion Arrays and Singleon Expansion}
49
52
  # @return [nil] Returns nil
50
53
  # @api public
51
54
  def svg(opts = {})
52
- p = needs(opts,[:range, :files, :svgid, :force_svgid, :x, :y, :width, :height, :layout, :alpha, :blend])
55
+ p = needs(opts,[:range, :files, :svgid, :force_svgid, :x, :y, :width, :height, :layout, :alpha, :blend, :angle])
53
56
  Dir.chdir(@img_dir) do
54
- @progress_bar.start("Loading SVG(s)", p[:range].size) do |bar|
57
+ @progress_bar.start('Loading SVG(s)', p[:range].size) do |bar|
55
58
  p[:range].each do |i|
56
59
  unless p[:force_id][i] && p[:id][i].to_s.empty?
57
- @cards[i].svg(p[:file][i], p[:id][i], p[:x][i], p[:y][i],
58
- p[:width][i], p[:height][i], p[:alpha][i], p[:blend][i])
60
+ @cards[i].svg(p[:file][i], p[:id][i], p[:x][i], p[:y][i],
61
+ p[:width][i], p[:height][i], p[:alpha][i], p[:blend][i], p[:angle][i])
59
62
  end
60
63
  bar.increment
61
64
  end
@@ -64,4 +67,4 @@ module Squib
64
67
  end
65
68
 
66
69
  end
67
- end
70
+ end
@@ -1,6 +1,6 @@
1
1
  module Squib
2
2
  class Deck
3
-
3
+
4
4
  # Saves the given range of cards to either PNG or PDF
5
5
  #
6
6
  # @option opts [Enumerable] range (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
@@ -16,8 +16,8 @@ module Squib
16
16
  save_pdf(opts) if opts[:format].include? :pdf
17
17
  self
18
18
  end
19
-
20
- # Saves the given range of cards to a PNG
19
+
20
+ # Saves the given range of cards to a PNG
21
21
  #
22
22
  # @example
23
23
  # save range: 1..8, dir: '_pnp', prefix: 'bw_'
@@ -31,7 +31,7 @@ module Squib
31
31
  def save_png(opts = {})
32
32
  opts = needs(opts,[:range, :creatable_dir, :prefix, :rotate])
33
33
  @progress_bar.start("Saving PNGs to #{opts[:dir]}/#{opts[:prefix]}*", @cards.size) do |bar|
34
- opts[:range].each do |i|
34
+ opts[:range].each do |i|
35
35
  @cards[i].save_png(i, opts[:dir], opts[:prefix], opts[:rotate], opts[:angle])
36
36
  bar.increment
37
37
  end
@@ -40,4 +40,3 @@ module Squib
40
40
 
41
41
  end
42
42
  end
43
-
@@ -1,7 +1,7 @@
1
1
  module Squib
2
2
  class Deck
3
3
 
4
- # Toggle hints globally.
4
+ # Toggle hints globally.
5
5
  #
6
6
  # Text hints are rectangles around where the text will be laid out. They are intended to be temporary.
7
7
  # Setting a hint to nil or to :off will disable hints. @see samples/text.rb
@@ -9,7 +9,7 @@ module Squib
9
9
  # hint text: :cyan
10
10
  # hint text: :cyan
11
11
  #
12
- # @param [String] text the color of the text hint. To turn off use :off. @see README.md
12
+ # @param [String] text the color of the text hint. To turn off use :off. @see README.md
13
13
  # @return [nil] Returns nothing
14
14
  # @api public
15
15
  def hint(text: :off)
@@ -17,7 +17,7 @@ module Squib
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.
20
- # @example
20
+ # @example
21
21
  # set font: 'Arial 26'
22
22
  # text 'blah' # in Arial 26
23
23
  # text 'blah24', font: 'Arial 24' # in Arial 24
@@ -31,7 +31,7 @@ module Squib
31
31
  opts = needs(opts, [:font, :img_dir])
32
32
  @font = opts[:font][0] #was expanded - just need the first
33
33
  @img_dir = opts[:img_dir]
34
- end
34
+ end
35
35
 
36
36
  end
37
37
  end