Squib supports various configuration properties that can be specified in an external file. By default, Squib looks for a file called
config.yml in the current directory. Or, you can set the
config: option in
Deck.new to specify the name of the configuration file.
These properties are intended to be immutable for the life of the Deck, and intended to configure how Squib behaves.
The options include:
When set to
true, long-running operations will show a progress bar in the console
Text hints are used to show the boundaries of text boxes. Can be enabled/disabled for individual commands, or set globally with the hint method. This setting is overridden by hint (and subsequently individual text).
Defines globally-available named colors available to the deck. Must be specified as a hash in yaml. For example:
# config.yml custom_colors: fg: '#abc' bg: '#def'
Set the algorithm that Cairo will use for anti-aliasing throughout its rendering. Available options are
Not every option is available on every platform. Using our benchmarks on large decks, best is only ~10% slower anyway. For more info see the Cairo docs.
Defines how Cairo will store the operations. Can be
memory. See Vector vs. Raster Backends.
When using an SVG backend, cards are auto-saved with this prefix and
For reading image file command (e.g. png and svg), read from this directory instead
Show a warning on the console when text is ellipsized. Warning is issued per card.
Show a warning on the console when a PNG file is upscaled. Warning is issued per card.
Smart quoting: change the left single quote when
Smart quoting: change the right single quote when
Smart quoting: change the left double quote when
Smart quoting: change the right double quote when
--to this character when
---to this character when
...to this character when
markup: true, the
textmethod will convert quotes. With
smart_quotes: false, explicit replacements like em-dashes and en-dashes will be replaced but not smart quotes.
The number of pixels that the “cell” custom unit is set to. See Unit Conversion
Options are available as methods¶
For debugging/sanity purposes, if you want to make sure your configuration options are parsed correctly, the above options are also available as methods within
Squib::Deck, for example:
Squib::Deck.new do puts backend # prints 'memory' by default end
These are read-only - you will not be able to change these.
Set options programmatically¶
You can also use Squib.configure to override anything in the config file. Use it like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
# This is a sample Rakefile require 'squib' desc 'Build all decks black-and-white' task default: [:characters, :skills] desc 'Build all decks with color' task color: [:with_color, :default] desc 'Enable color build' task :with_color do puts "Enabling color build" Squib.configure img_dir: 'color' end desc 'Build the character deck' task :characters do puts "Building characters" load 'src/characters.rb' end desc 'Build the skills deck' task :skills do puts "Building skills" load 'src/skills.rb' end
See The Squib Way pt 3: Workflows for how we put this to good use.
Making Squib Verbose¶
By default, Squib’s logger is set to
WARN, but more fine-grained logging is embedded in the code. To set the logger, just put this at the top of your script:
Squib::logger.level = Logger::INFO
If you REALLY want to see tons of output, you can also set DEBUG, but that’s not intended for general consumption.