squib 0.18.0 → 0.19.0a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.md +39 -39
- data/.github/ISSUE_TEMPLATE/feature_request.md +22 -22
- data/.github/ISSUE_TEMPLATE/help-wanted.md +13 -13
- data/.github/ISSUE_TEMPLATE/release-todo.md +45 -33
- data/.github/PULL_REQUEST_TEMPLATE.md +13 -13
- data/.github/workflows/tests.yml +22 -22
- data/.gitignore +41 -41
- data/.vscode/settings.json +4 -3
- data/CHANGELOG.md +460 -460
- data/CONTRIBUTING.md +40 -40
- data/Dockerfile +27 -27
- data/Gemfile +2 -2
- data/Guardfile +8 -8
- data/LICENSE.txt +22 -22
- data/README.md +139 -139
- data/Rakefile +51 -51
- data/bin/squib +5 -5
- data/lib/squib/api/settings.rb +21 -21
- data/lib/squib/args/arg_loader.rb +138 -138
- data/lib/squib/args/box.rb +59 -59
- data/lib/squib/args/card_range.rb +34 -34
- data/lib/squib/args/color_validator.rb +7 -7
- data/lib/squib/args/coords.rb +49 -49
- data/lib/squib/args/csv_opts.rb +22 -22
- data/lib/squib/args/dir_validator.rb +11 -11
- data/lib/squib/args/draw.rb +93 -93
- data/lib/squib/args/drop_shadow.rb +39 -39
- data/lib/squib/args/embed_adjust.rb +22 -22
- data/lib/squib/args/embed_key.rb +12 -12
- data/lib/squib/args/hand_special.rb +37 -37
- data/lib/squib/args/import.rb +67 -67
- data/lib/squib/args/input_file.rb +55 -55
- data/lib/squib/args/paint.rb +43 -43
- data/lib/squib/args/paragraph.rb +118 -118
- data/lib/squib/args/save_batch.rb +65 -65
- data/lib/squib/args/scale_box.rb +57 -57
- data/lib/squib/args/sheet.rb +165 -165
- data/lib/squib/args/showcase_special.rb +41 -41
- data/lib/squib/args/sprue_file.rb +44 -44
- data/lib/squib/args/svg_special.rb +37 -37
- data/lib/squib/args/transform.rb +55 -55
- data/lib/squib/args/typographer.rb +115 -115
- data/lib/squib/args/unit_conversion.rb +27 -27
- data/lib/squib/args/xywh_shorthands.rb +50 -50
- data/lib/squib/builtin/layouts/economy.yml +85 -85
- data/lib/squib/builtin/layouts/fantasy.yml +101 -101
- data/lib/squib/builtin/layouts/hand.yml +62 -62
- data/lib/squib/builtin/layouts/party.yml +94 -94
- data/lib/squib/builtin/layouts/playing-card.yml +35 -35
- data/lib/squib/builtin/layouts/tuck_box.yml +46 -46
- data/lib/squib/builtin/projects/advanced/.gitignore +4 -4
- data/lib/squib/builtin/projects/advanced/ABOUT.md +19 -19
- data/lib/squib/builtin/projects/advanced/Gemfile +11 -11
- data/lib/squib/builtin/projects/advanced/Guardfile +21 -21
- data/lib/squib/builtin/projects/advanced/IDEAS.md +22 -22
- data/lib/squib/builtin/projects/advanced/PLAYTESTING.md +26 -26
- data/lib/squib/builtin/projects/advanced/Rakefile +27 -27
- data/lib/squib/builtin/projects/advanced/config.yml +49 -49
- data/lib/squib/builtin/projects/advanced/docs/PNP NOTES.md +3 -3
- data/lib/squib/builtin/projects/advanced/docs/RULES.md +21 -21
- data/lib/squib/builtin/projects/advanced/img/example.svg +60 -60
- data/lib/squib/builtin/projects/advanced/layouts/deck.yml +27 -27
- data/lib/squib/builtin/projects/advanced/src/deck.rb +34 -34
- data/lib/squib/builtin/projects/advanced/src/version.rb +3 -3
- data/lib/squib/builtin/projects/basic/.gitignore +4 -4
- data/lib/squib/builtin/projects/basic/ABOUT.md +19 -19
- data/lib/squib/builtin/projects/basic/Gemfile +3 -3
- data/lib/squib/builtin/projects/basic/IDEAS.md +22 -22
- data/lib/squib/builtin/projects/basic/PLAYTESTING.md +26 -26
- data/lib/squib/builtin/projects/basic/PNP NOTES.md +3 -3
- data/lib/squib/builtin/projects/basic/RULES.md +21 -21
- data/lib/squib/builtin/projects/basic/Rakefile +7 -7
- data/lib/squib/builtin/projects/basic/config.yml +50 -50
- data/lib/squib/builtin/projects/basic/deck.rb +6 -6
- data/lib/squib/builtin/sprues/a4_euro_card.yml +42 -42
- data/lib/squib/builtin/sprues/a4_poker_card_8up.yml +40 -40
- data/lib/squib/builtin/sprues/a4_poker_card_9up.yml +42 -42
- data/lib/squib/builtin/sprues/a4_usa_card.yml +42 -42
- data/lib/squib/builtin/sprues/drivethrucards_1up.yml +10 -10
- data/lib/squib/builtin/sprues/letter_poker_card_9up.yml +25 -25
- data/lib/squib/builtin/sprues/letter_poker_foldable_8up.yml +52 -52
- data/lib/squib/builtin/sprues/printplaygames_18up.yml +68 -68
- data/lib/squib/card.rb +75 -75
- data/lib/squib/commands/cli.rb +39 -39
- data/lib/squib/commands/data/template_option.rb +109 -109
- data/lib/squib/commands/make_sprue.rb +277 -277
- data/lib/squib/commands/new.rb +77 -77
- data/lib/squib/conf.rb +149 -149
- data/lib/squib/constants.rb +17 -17
- data/lib/squib/deck.rb +138 -138
- data/lib/squib/dsl/background.rb +35 -35
- data/lib/squib/dsl/circle.rb +39 -39
- data/lib/squib/dsl/csv.rb +42 -42
- data/lib/squib/dsl/curve.rb +35 -35
- data/lib/squib/dsl/cut_zone.rb +47 -47
- data/lib/squib/dsl/ellipse.rb +37 -37
- data/lib/squib/dsl/grid.rb +35 -35
- data/lib/squib/dsl/groups.rb +54 -54
- data/lib/squib/dsl/hand.rb +42 -42
- data/lib/squib/dsl/line.rb +35 -35
- data/lib/squib/dsl/png.rb +57 -57
- data/lib/squib/dsl/polygon.rb +36 -36
- data/lib/squib/dsl/rect.rb +37 -37
- data/lib/squib/dsl/safe_zone.rb +48 -48
- data/lib/squib/dsl/save.rb +21 -21
- data/lib/squib/dsl/save_pdf.rb +50 -50
- data/lib/squib/dsl/save_png.rb +48 -48
- data/lib/squib/dsl/save_sheet.rb +53 -53
- data/lib/squib/dsl/showcase.rb +43 -43
- data/lib/squib/dsl/star.rb +37 -37
- data/lib/squib/dsl/svg.rb +63 -63
- data/lib/squib/dsl/text.rb +54 -54
- data/lib/squib/dsl/text_embed.rb +79 -79
- data/lib/squib/dsl/triangle.rb +35 -35
- data/lib/squib/dsl/units.rb +37 -37
- data/lib/squib/dsl/xlsx.rb +40 -40
- data/lib/squib/dsl/yaml.rb +40 -40
- data/lib/squib/errors_warnings/warn_unexpected_params.rb +14 -14
- data/lib/squib/graphics/background.rb +14 -14
- data/lib/squib/graphics/cairo_context_wrapper.rb +115 -115
- data/lib/squib/graphics/embedding_utils.rb +28 -28
- data/lib/squib/graphics/gradient_regex.rb +47 -47
- data/lib/squib/graphics/hand.rb +42 -42
- data/lib/squib/graphics/image.rb +123 -123
- data/lib/squib/graphics/save_doc.rb +77 -77
- data/lib/squib/graphics/save_images.rb +91 -91
- data/lib/squib/graphics/save_pdf.rb +90 -90
- data/lib/squib/graphics/save_sprue.rb +231 -231
- data/lib/squib/graphics/shapes.rb +143 -143
- data/lib/squib/graphics/showcase.rb +85 -85
- data/lib/squib/graphics/text.rb +202 -202
- data/lib/squib/import/csv_importer.rb +45 -45
- data/lib/squib/import/data_frame.rb +108 -108
- data/lib/squib/import/quantity_exploder.rb +17 -17
- data/lib/squib/import/xlsx_importer.rb +28 -28
- data/lib/squib/import/yaml_importer.rb +30 -30
- data/lib/squib/layout_parser.rb +155 -155
- data/lib/squib/progress.rb +38 -38
- data/lib/squib/sample_helpers.rb +34 -34
- data/lib/squib/sprues/crop_line.rb +28 -28
- data/lib/squib/sprues/crop_line_dash.rb +35 -35
- data/lib/squib/sprues/invalid_sprue_definition.rb +9 -9
- data/lib/squib/sprues/sprue.rb +208 -208
- data/lib/squib/sprues/sprue_schema.rb +51 -51
- data/lib/squib/system_fonts.rb +16 -16
- data/lib/squib/version.rb +11 -11
- data/lib/squib.rb +35 -35
- data/samples/autoscale_font/_autoscale_font.rb +98 -98
- data/samples/backend/_backend.rb +26 -26
- data/samples/basic.rb +19 -19
- data/samples/build_groups/build_groups.rb +36 -36
- data/samples/colors/_colors.rb +44 -44
- data/samples/colors/_gradients.rb +34 -34
- data/samples/colors/_switch_color.rb +33 -33
- data/samples/config/config_text_markup.rb +20 -20
- data/samples/config/custom_config.rb +18 -18
- data/samples/data/_csv.rb +33 -33
- data/samples/data/_excel.rb +55 -55
- data/samples/data/_yaml.rb +12 -12
- data/samples/hello_world.rb +6 -6
- data/samples/images/_cairo_access.rb +39 -39
- data/samples/images/_images.rb +104 -104
- data/samples/images/_more_load_images.rb +102 -102
- data/samples/images/_placeholders.rb +48 -48
- data/samples/intro/01_hello.rb +8 -8
- data/samples/intro/02_options.rb +14 -14
- data/samples/intro/03_layout.rb +11 -11
- data/samples/intro/04_arrays.rb +15 -15
- data/samples/intro/05_excel.rb +14 -14
- data/samples/layouts/builtin_layouts.rb +97 -97
- data/samples/layouts/layouts.rb +71 -71
- data/samples/project/src/characters.rb +8 -8
- data/samples/project/src/skills.rb +7 -7
- data/samples/proofs/_tgc_proofs.rb +16 -16
- data/samples/ranges/_ranges.rb +64 -64
- data/samples/saves/_hand.rb +23 -23
- data/samples/saves/_portrait_landscape.rb +23 -23
- data/samples/saves/_save_filenames.rb +28 -28
- data/samples/saves/_save_pdf.rb +29 -29
- data/samples/saves/_saves.rb +75 -75
- data/samples/saves/_showcase.rb +25 -25
- data/samples/shadows/_shadow.rb +71 -71
- data/samples/shapes/_draw_shapes.rb +60 -60
- data/samples/shapes/_proofs.rb +22 -22
- data/samples/sprues/_advanced_sprues.rb +25 -25
- data/samples/sprues/_builtin_sprues.rb +22 -22
- data/samples/sprues/_fold_sheet.rb +30 -30
- data/samples/sprues/_hex_tiles.rb +15 -15
- data/samples/sprues/_mints.rb +11 -11
- data/samples/sprues/_negative_coords.rb +6 -6
- data/samples/sprues/_sprue_example.rb +11 -11
- data/samples/system_font_debug/_list_fonts.rb +14 -14
- data/samples/text/_embed_text.rb +128 -128
- data/samples/text/_text.rb +52 -52
- data/samples/text/_text_options.rb +103 -103
- data/samples/text/bug134.rb +14 -14
- data/samples/units/_cells.rb +50 -50
- data/samples/units/_shorthands.rb +48 -48
- data/samples/units/_units.rb +39 -39
- data/squib.gemspec +58 -58
- metadata +21 -21
data/lib/squib/deck.rb
CHANGED
|
@@ -1,138 +1,138 @@
|
|
|
1
|
-
require 'forwardable'
|
|
2
|
-
require 'pp'
|
|
3
|
-
require_relative '../squib'
|
|
4
|
-
require_relative 'args/unit_conversion'
|
|
5
|
-
require_relative 'card'
|
|
6
|
-
require_relative 'conf'
|
|
7
|
-
require_relative 'constants'
|
|
8
|
-
require_relative 'graphics/hand'
|
|
9
|
-
require_relative 'graphics/showcase'
|
|
10
|
-
require_relative 'layout_parser'
|
|
11
|
-
require_relative 'progress'
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
# The project module
|
|
15
|
-
#
|
|
16
|
-
# @api public
|
|
17
|
-
module Squib
|
|
18
|
-
|
|
19
|
-
# The main interface to Squib. Provides a front-end porcelain whereas the Card class interacts with the graphics plumbing.
|
|
20
|
-
#
|
|
21
|
-
# @api public
|
|
22
|
-
class Deck
|
|
23
|
-
include Enumerable
|
|
24
|
-
extend Forwardable
|
|
25
|
-
|
|
26
|
-
# Attributes for the width, height (in pixels) and number of cards
|
|
27
|
-
# These are expected to be immuatble for the life of Deck
|
|
28
|
-
# @api private
|
|
29
|
-
attr_reader :width, :height, :cards, :progress_bar
|
|
30
|
-
|
|
31
|
-
# Delegate these configuration options to the Squib::Conf object
|
|
32
|
-
def_delegators :conf, :antialias, :backend, :count_format, :custom_colors, :dir,
|
|
33
|
-
:img_dir, :prefix, :text_hint, :typographer
|
|
34
|
-
# :nodoc:
|
|
35
|
-
# @api private
|
|
36
|
-
attr_reader :layout, :conf, :dpi, :font, :cell_px
|
|
37
|
-
|
|
38
|
-
#
|
|
39
|
-
# deck.size is really just @cards.size
|
|
40
|
-
def_delegators :cards, :size
|
|
41
|
-
|
|
42
|
-
# Squib's constructor that sets the immutable properties.
|
|
43
|
-
#
|
|
44
|
-
# This is the starting point for Squib. In providing a block to the constructor, you have access to all of Deck's instance methods.
|
|
45
|
-
# The documented methods in Deck are the ones intended for use by most users.
|
|
46
|
-
# If your game requires multiple different sizes or orientations, I recommend using multiple `Squib::Deck`s in your `deck.rb`. You can modify the internals of `Squib::Deck` (e.g. `@cards`), but that's not recommended.
|
|
47
|
-
# @example
|
|
48
|
-
# require 'squib'
|
|
49
|
-
# Squib::Deck.new do
|
|
50
|
-
# text str: 'Hello, World!"
|
|
51
|
-
# end
|
|
52
|
-
#
|
|
53
|
-
# @param width [Integer] the width of each card in pixels. Supports unit conversion (e.g. '2.5in').
|
|
54
|
-
# @param height [Integer] the height of each card in pixels. Supports unit conversion (e.g. '3.5in').
|
|
55
|
-
# @param cards [Integer] the number of cards in the deck
|
|
56
|
-
# @param dpi [Integer] the pixels per inch when rendering out to PDF or calculating using inches.
|
|
57
|
-
# @param config [String] the file used for global settings of this deck
|
|
58
|
-
# @param layout [String, Array] load a YML file of custom layouts. Multiple files are merged sequentially, redefining collisons. See README and sample for details.
|
|
59
|
-
# @param block [Block] the main body of the script.
|
|
60
|
-
# @api public
|
|
61
|
-
def initialize(width: 825, height: 1125, cards: 1, dpi: 300, config: 'config.yml', layout: nil, &block)
|
|
62
|
-
@dpi = dpi
|
|
63
|
-
@font = DEFAULT_FONT
|
|
64
|
-
@cards = []
|
|
65
|
-
@conf = Conf.load(config)
|
|
66
|
-
@cell_px = @conf.cell_px
|
|
67
|
-
@progress_bar = Progress.new(@conf.progress_bars) # FIXME this is evil. Using something different with @ and non-@
|
|
68
|
-
show_info(config, layout)
|
|
69
|
-
@width = Args::UnitConversion.parse width, dpi, @cell_px
|
|
70
|
-
@height = Args::UnitConversion.parse height, dpi, @cell_px
|
|
71
|
-
cards.times{ |i| @cards << Squib::Card.new(self, @width, @height, i) }
|
|
72
|
-
@layout = LayoutParser.new(dpi, @cell_px).load_layout(layout)
|
|
73
|
-
enable_groups_from_env!
|
|
74
|
-
if block_given?
|
|
75
|
-
instance_eval(&block) # here we go. wheeeee!
|
|
76
|
-
end
|
|
77
|
-
@cards.each { |c| c.finish! }
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
# Directly accesses the array of cards in the deck
|
|
81
|
-
#
|
|
82
|
-
# @api private
|
|
83
|
-
def [](key)
|
|
84
|
-
@cards[key]
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
# Iterates over each card in the deck
|
|
88
|
-
#
|
|
89
|
-
# @api private
|
|
90
|
-
def each(&block)
|
|
91
|
-
@cards.each { |card| block.call(card) }
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
# Use Logger to show more detail on the run
|
|
95
|
-
# :nodoc:
|
|
96
|
-
# @api private
|
|
97
|
-
def show_info(config, layout)
|
|
98
|
-
Squib::logger.info "Squib v#{Squib::VERSION}"
|
|
99
|
-
Squib::logger.info " building #{@cards.size} #{@width}x#{@height} cards"
|
|
100
|
-
Squib::logger.info " using #{@backend}"
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
##################
|
|
104
|
-
### PUBLIC API ###
|
|
105
|
-
##################
|
|
106
|
-
require_relative 'api/settings'
|
|
107
|
-
|
|
108
|
-
###################
|
|
109
|
-
### DSL METHODS ###
|
|
110
|
-
###################
|
|
111
|
-
require_relative 'dsl/background'
|
|
112
|
-
require_relative 'dsl/circle'
|
|
113
|
-
require_relative 'dsl/csv'
|
|
114
|
-
require_relative 'dsl/curve'
|
|
115
|
-
require_relative 'dsl/cut_zone'
|
|
116
|
-
require_relative 'dsl/ellipse'
|
|
117
|
-
require_relative 'dsl/grid'
|
|
118
|
-
require_relative 'dsl/groups'
|
|
119
|
-
require_relative 'dsl/hand'
|
|
120
|
-
require_relative 'dsl/line'
|
|
121
|
-
require_relative 'dsl/png'
|
|
122
|
-
require_relative 'dsl/polygon'
|
|
123
|
-
require_relative 'dsl/rect'
|
|
124
|
-
require_relative 'dsl/safe_zone'
|
|
125
|
-
require_relative 'dsl/save_pdf'
|
|
126
|
-
require_relative 'dsl/save_png'
|
|
127
|
-
require_relative 'dsl/save_sheet'
|
|
128
|
-
require_relative 'dsl/save'
|
|
129
|
-
require_relative 'dsl/showcase'
|
|
130
|
-
require_relative 'dsl/star'
|
|
131
|
-
require_relative 'dsl/svg'
|
|
132
|
-
require_relative 'dsl/text'
|
|
133
|
-
require_relative 'dsl/triangle'
|
|
134
|
-
require_relative 'dsl/units'
|
|
135
|
-
require_relative 'dsl/xlsx'
|
|
136
|
-
require_relative 'dsl/yaml'
|
|
137
|
-
end
|
|
138
|
-
end
|
|
1
|
+
require 'forwardable'
|
|
2
|
+
require 'pp'
|
|
3
|
+
require_relative '../squib'
|
|
4
|
+
require_relative 'args/unit_conversion'
|
|
5
|
+
require_relative 'card'
|
|
6
|
+
require_relative 'conf'
|
|
7
|
+
require_relative 'constants'
|
|
8
|
+
require_relative 'graphics/hand'
|
|
9
|
+
require_relative 'graphics/showcase'
|
|
10
|
+
require_relative 'layout_parser'
|
|
11
|
+
require_relative 'progress'
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# The project module
|
|
15
|
+
#
|
|
16
|
+
# @api public
|
|
17
|
+
module Squib
|
|
18
|
+
|
|
19
|
+
# The main interface to Squib. Provides a front-end porcelain whereas the Card class interacts with the graphics plumbing.
|
|
20
|
+
#
|
|
21
|
+
# @api public
|
|
22
|
+
class Deck
|
|
23
|
+
include Enumerable
|
|
24
|
+
extend Forwardable
|
|
25
|
+
|
|
26
|
+
# Attributes for the width, height (in pixels) and number of cards
|
|
27
|
+
# These are expected to be immuatble for the life of Deck
|
|
28
|
+
# @api private
|
|
29
|
+
attr_reader :width, :height, :cards, :progress_bar
|
|
30
|
+
|
|
31
|
+
# Delegate these configuration options to the Squib::Conf object
|
|
32
|
+
def_delegators :conf, :antialias, :backend, :count_format, :custom_colors, :dir,
|
|
33
|
+
:img_dir, :prefix, :text_hint, :typographer
|
|
34
|
+
# :nodoc:
|
|
35
|
+
# @api private
|
|
36
|
+
attr_reader :layout, :conf, :dpi, :font, :cell_px
|
|
37
|
+
|
|
38
|
+
#
|
|
39
|
+
# deck.size is really just @cards.size
|
|
40
|
+
def_delegators :cards, :size
|
|
41
|
+
|
|
42
|
+
# Squib's constructor that sets the immutable properties.
|
|
43
|
+
#
|
|
44
|
+
# This is the starting point for Squib. In providing a block to the constructor, you have access to all of Deck's instance methods.
|
|
45
|
+
# The documented methods in Deck are the ones intended for use by most users.
|
|
46
|
+
# If your game requires multiple different sizes or orientations, I recommend using multiple `Squib::Deck`s in your `deck.rb`. You can modify the internals of `Squib::Deck` (e.g. `@cards`), but that's not recommended.
|
|
47
|
+
# @example
|
|
48
|
+
# require 'squib'
|
|
49
|
+
# Squib::Deck.new do
|
|
50
|
+
# text str: 'Hello, World!"
|
|
51
|
+
# end
|
|
52
|
+
#
|
|
53
|
+
# @param width [Integer] the width of each card in pixels. Supports unit conversion (e.g. '2.5in').
|
|
54
|
+
# @param height [Integer] the height of each card in pixels. Supports unit conversion (e.g. '3.5in').
|
|
55
|
+
# @param cards [Integer] the number of cards in the deck
|
|
56
|
+
# @param dpi [Integer] the pixels per inch when rendering out to PDF or calculating using inches.
|
|
57
|
+
# @param config [String] the file used for global settings of this deck
|
|
58
|
+
# @param layout [String, Array] load a YML file of custom layouts. Multiple files are merged sequentially, redefining collisons. See README and sample for details.
|
|
59
|
+
# @param block [Block] the main body of the script.
|
|
60
|
+
# @api public
|
|
61
|
+
def initialize(width: 825, height: 1125, cards: 1, dpi: 300, config: 'config.yml', layout: nil, &block)
|
|
62
|
+
@dpi = dpi
|
|
63
|
+
@font = DEFAULT_FONT
|
|
64
|
+
@cards = []
|
|
65
|
+
@conf = Conf.load(config)
|
|
66
|
+
@cell_px = @conf.cell_px
|
|
67
|
+
@progress_bar = Progress.new(@conf.progress_bars) # FIXME this is evil. Using something different with @ and non-@
|
|
68
|
+
show_info(config, layout)
|
|
69
|
+
@width = Args::UnitConversion.parse width, dpi, @cell_px
|
|
70
|
+
@height = Args::UnitConversion.parse height, dpi, @cell_px
|
|
71
|
+
cards.times{ |i| @cards << Squib::Card.new(self, @width, @height, i) }
|
|
72
|
+
@layout = LayoutParser.new(dpi, @cell_px).load_layout(layout)
|
|
73
|
+
enable_groups_from_env!
|
|
74
|
+
if block_given?
|
|
75
|
+
instance_eval(&block) # here we go. wheeeee!
|
|
76
|
+
end
|
|
77
|
+
@cards.each { |c| c.finish! }
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Directly accesses the array of cards in the deck
|
|
81
|
+
#
|
|
82
|
+
# @api private
|
|
83
|
+
def [](key)
|
|
84
|
+
@cards[key]
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# Iterates over each card in the deck
|
|
88
|
+
#
|
|
89
|
+
# @api private
|
|
90
|
+
def each(&block)
|
|
91
|
+
@cards.each { |card| block.call(card) }
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Use Logger to show more detail on the run
|
|
95
|
+
# :nodoc:
|
|
96
|
+
# @api private
|
|
97
|
+
def show_info(config, layout)
|
|
98
|
+
Squib::logger.info "Squib v#{Squib::VERSION}"
|
|
99
|
+
Squib::logger.info " building #{@cards.size} #{@width}x#{@height} cards"
|
|
100
|
+
Squib::logger.info " using #{@backend}"
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
##################
|
|
104
|
+
### PUBLIC API ###
|
|
105
|
+
##################
|
|
106
|
+
require_relative 'api/settings'
|
|
107
|
+
|
|
108
|
+
###################
|
|
109
|
+
### DSL METHODS ###
|
|
110
|
+
###################
|
|
111
|
+
require_relative 'dsl/background'
|
|
112
|
+
require_relative 'dsl/circle'
|
|
113
|
+
require_relative 'dsl/csv'
|
|
114
|
+
require_relative 'dsl/curve'
|
|
115
|
+
require_relative 'dsl/cut_zone'
|
|
116
|
+
require_relative 'dsl/ellipse'
|
|
117
|
+
require_relative 'dsl/grid'
|
|
118
|
+
require_relative 'dsl/groups'
|
|
119
|
+
require_relative 'dsl/hand'
|
|
120
|
+
require_relative 'dsl/line'
|
|
121
|
+
require_relative 'dsl/png'
|
|
122
|
+
require_relative 'dsl/polygon'
|
|
123
|
+
require_relative 'dsl/rect'
|
|
124
|
+
require_relative 'dsl/safe_zone'
|
|
125
|
+
require_relative 'dsl/save_pdf'
|
|
126
|
+
require_relative 'dsl/save_png'
|
|
127
|
+
require_relative 'dsl/save_sheet'
|
|
128
|
+
require_relative 'dsl/save'
|
|
129
|
+
require_relative 'dsl/showcase'
|
|
130
|
+
require_relative 'dsl/star'
|
|
131
|
+
require_relative 'dsl/svg'
|
|
132
|
+
require_relative 'dsl/text'
|
|
133
|
+
require_relative 'dsl/triangle'
|
|
134
|
+
require_relative 'dsl/units'
|
|
135
|
+
require_relative 'dsl/xlsx'
|
|
136
|
+
require_relative 'dsl/yaml'
|
|
137
|
+
end
|
|
138
|
+
end
|
data/lib/squib/dsl/background.rb
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
require_relative '../errors_warnings/warn_unexpected_params'
|
|
2
|
-
|
|
3
|
-
module Squib
|
|
4
|
-
class Deck
|
|
5
|
-
def background(opts = {})
|
|
6
|
-
DSL::Background.new(self, __callee__).run(opts)
|
|
7
|
-
end
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
module DSL
|
|
11
|
-
class Background
|
|
12
|
-
include WarnUnexpectedParams
|
|
13
|
-
attr_reader :dsl_method, :deck
|
|
14
|
-
|
|
15
|
-
def initialize(deck, dsl_method)
|
|
16
|
-
@deck = deck
|
|
17
|
-
@dsl_method = dsl_method
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def self.accepted_params
|
|
21
|
-
%i{
|
|
22
|
-
range
|
|
23
|
-
color
|
|
24
|
-
}
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def run(opts)
|
|
28
|
-
warn_if_unexpected opts
|
|
29
|
-
range = Args.extract_range opts, deck
|
|
30
|
-
draw = Args.extract_draw opts, deck
|
|
31
|
-
range.each { |i| @deck.cards[i].background(draw.color[i]) }
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
1
|
+
require_relative '../errors_warnings/warn_unexpected_params'
|
|
2
|
+
|
|
3
|
+
module Squib
|
|
4
|
+
class Deck
|
|
5
|
+
def background(opts = {})
|
|
6
|
+
DSL::Background.new(self, __callee__).run(opts)
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
module DSL
|
|
11
|
+
class Background
|
|
12
|
+
include WarnUnexpectedParams
|
|
13
|
+
attr_reader :dsl_method, :deck
|
|
14
|
+
|
|
15
|
+
def initialize(deck, dsl_method)
|
|
16
|
+
@deck = deck
|
|
17
|
+
@dsl_method = dsl_method
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.accepted_params
|
|
21
|
+
%i{
|
|
22
|
+
range
|
|
23
|
+
color
|
|
24
|
+
}
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def run(opts)
|
|
28
|
+
warn_if_unexpected opts
|
|
29
|
+
range = Args.extract_range opts, deck
|
|
30
|
+
draw = Args.extract_draw opts, deck
|
|
31
|
+
range.each { |i| @deck.cards[i].background(draw.color[i]) }
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
data/lib/squib/dsl/circle.rb
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
require_relative '../errors_warnings/warn_unexpected_params'
|
|
2
|
-
require_relative '../args/card_range'
|
|
3
|
-
require_relative '../args/coords'
|
|
4
|
-
require_relative '../args/draw'
|
|
5
|
-
|
|
6
|
-
module Squib
|
|
7
|
-
class Deck
|
|
8
|
-
def circle(opts = {})
|
|
9
|
-
DSL::Circle.new(self, __callee__).run(opts)
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
module DSL
|
|
14
|
-
class Circle
|
|
15
|
-
include WarnUnexpectedParams
|
|
16
|
-
attr_reader :dsl_method, :deck
|
|
17
|
-
|
|
18
|
-
def initialize(deck, dsl_method)
|
|
19
|
-
@deck = deck
|
|
20
|
-
@dsl_method = dsl_method
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def self.accepted_params
|
|
24
|
-
%i(x y
|
|
25
|
-
radius arc_start arc_end arc_direction arc_close
|
|
26
|
-
fill_color stroke_color stroke_width stroke_strategy join dash cap
|
|
27
|
-
range layout)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def run(opts)
|
|
31
|
-
warn_if_unexpected opts
|
|
32
|
-
range = Args.extract_range opts, deck
|
|
33
|
-
coords = Args.extract_coords opts, deck
|
|
34
|
-
draw = Args.extract_draw opts, deck
|
|
35
|
-
range.each { |i| deck.cards[i].circle(coords[i], draw[i]) }
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
1
|
+
require_relative '../errors_warnings/warn_unexpected_params'
|
|
2
|
+
require_relative '../args/card_range'
|
|
3
|
+
require_relative '../args/coords'
|
|
4
|
+
require_relative '../args/draw'
|
|
5
|
+
|
|
6
|
+
module Squib
|
|
7
|
+
class Deck
|
|
8
|
+
def circle(opts = {})
|
|
9
|
+
DSL::Circle.new(self, __callee__).run(opts)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
module DSL
|
|
14
|
+
class Circle
|
|
15
|
+
include WarnUnexpectedParams
|
|
16
|
+
attr_reader :dsl_method, :deck
|
|
17
|
+
|
|
18
|
+
def initialize(deck, dsl_method)
|
|
19
|
+
@deck = deck
|
|
20
|
+
@dsl_method = dsl_method
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.accepted_params
|
|
24
|
+
%i(x y
|
|
25
|
+
radius arc_start arc_end arc_direction arc_close
|
|
26
|
+
fill_color stroke_color stroke_width stroke_strategy join dash cap
|
|
27
|
+
range layout)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def run(opts)
|
|
31
|
+
warn_if_unexpected opts
|
|
32
|
+
range = Args.extract_range opts, deck
|
|
33
|
+
coords = Args.extract_coords opts, deck
|
|
34
|
+
draw = Args.extract_draw opts, deck
|
|
35
|
+
range.each { |i| deck.cards[i].circle(coords[i], draw[i]) }
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
data/lib/squib/dsl/csv.rb
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
require_relative '../args/import'
|
|
2
|
-
require_relative '../args/csv_opts'
|
|
3
|
-
require_relative '../import/csv_importer'
|
|
4
|
-
require_relative '../errors_warnings/warn_unexpected_params'
|
|
5
|
-
|
|
6
|
-
module Squib
|
|
7
|
-
# DSL method. See http://squib.readthedocs.io
|
|
8
|
-
def csv(opts = {}, &block)
|
|
9
|
-
DSL::Csv.new(__callee__).run(opts, &block)
|
|
10
|
-
end
|
|
11
|
-
module_function :csv
|
|
12
|
-
|
|
13
|
-
class Deck
|
|
14
|
-
# DSL method. See http://squib.readthedocs.io
|
|
15
|
-
def csv(opts = {}, &block)
|
|
16
|
-
DSL::Csv.new(__callee__).run(opts, &block)
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
module DSL
|
|
21
|
-
class Csv
|
|
22
|
-
include WarnUnexpectedParams
|
|
23
|
-
attr_reader :dsl_method, :block
|
|
24
|
-
|
|
25
|
-
def initialize(dsl_method)
|
|
26
|
-
@dsl_method = dsl_method
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def self.accepted_params
|
|
30
|
-
%i( file data strip explode col_sep quote_char)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def run(opts,&block)
|
|
34
|
-
warn_if_unexpected opts
|
|
35
|
-
import_args = Args.extract_import opts
|
|
36
|
-
importer = Squib::Import::CsvImporter.new
|
|
37
|
-
csv_opts = Args::CSV_Opts.new(opts)
|
|
38
|
-
importer.import_to_dataframe(import_args, csv_opts, &block)
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
1
|
+
require_relative '../args/import'
|
|
2
|
+
require_relative '../args/csv_opts'
|
|
3
|
+
require_relative '../import/csv_importer'
|
|
4
|
+
require_relative '../errors_warnings/warn_unexpected_params'
|
|
5
|
+
|
|
6
|
+
module Squib
|
|
7
|
+
# DSL method. See http://squib.readthedocs.io
|
|
8
|
+
def csv(opts = {}, &block)
|
|
9
|
+
DSL::Csv.new(__callee__).run(opts, &block)
|
|
10
|
+
end
|
|
11
|
+
module_function :csv
|
|
12
|
+
|
|
13
|
+
class Deck
|
|
14
|
+
# DSL method. See http://squib.readthedocs.io
|
|
15
|
+
def csv(opts = {}, &block)
|
|
16
|
+
DSL::Csv.new(__callee__).run(opts, &block)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
module DSL
|
|
21
|
+
class Csv
|
|
22
|
+
include WarnUnexpectedParams
|
|
23
|
+
attr_reader :dsl_method, :block
|
|
24
|
+
|
|
25
|
+
def initialize(dsl_method)
|
|
26
|
+
@dsl_method = dsl_method
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.accepted_params
|
|
30
|
+
%i( file data strip explode col_sep quote_char)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def run(opts,&block)
|
|
34
|
+
warn_if_unexpected opts
|
|
35
|
+
import_args = Args.extract_import opts
|
|
36
|
+
importer = Squib::Import::CsvImporter.new
|
|
37
|
+
csv_opts = Args::CSV_Opts.new(opts)
|
|
38
|
+
importer.import_to_dataframe(import_args, csv_opts, &block)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
data/lib/squib/dsl/curve.rb
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
require_relative '../errors_warnings/warn_unexpected_params'
|
|
2
|
-
|
|
3
|
-
module Squib
|
|
4
|
-
class Deck
|
|
5
|
-
def curve(opts = {})
|
|
6
|
-
DSL::Curve.new(self, __callee__).run(opts)
|
|
7
|
-
end
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
module DSL
|
|
11
|
-
class Curve
|
|
12
|
-
include WarnUnexpectedParams
|
|
13
|
-
attr_reader :dsl_method, :deck
|
|
14
|
-
|
|
15
|
-
def initialize(deck, dsl_method)
|
|
16
|
-
@deck = deck
|
|
17
|
-
@dsl_method = dsl_method
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def self.accepted_params
|
|
21
|
-
%i(x1 y1 x2 y2 cx1 cy1 cx2 cy2
|
|
22
|
-
fill_color stroke_color stroke_width stroke_strategy join dash cap
|
|
23
|
-
range layout)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def run(opts)
|
|
27
|
-
warn_if_unexpected opts
|
|
28
|
-
range = Args.extract_range opts, deck
|
|
29
|
-
draw = Args.extract_draw opts, deck
|
|
30
|
-
coords = Args.extract_coords opts, deck
|
|
31
|
-
range.each { |i| deck.cards[i].curve(coords[i], draw[i]) }
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
1
|
+
require_relative '../errors_warnings/warn_unexpected_params'
|
|
2
|
+
|
|
3
|
+
module Squib
|
|
4
|
+
class Deck
|
|
5
|
+
def curve(opts = {})
|
|
6
|
+
DSL::Curve.new(self, __callee__).run(opts)
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
module DSL
|
|
11
|
+
class Curve
|
|
12
|
+
include WarnUnexpectedParams
|
|
13
|
+
attr_reader :dsl_method, :deck
|
|
14
|
+
|
|
15
|
+
def initialize(deck, dsl_method)
|
|
16
|
+
@deck = deck
|
|
17
|
+
@dsl_method = dsl_method
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.accepted_params
|
|
21
|
+
%i(x1 y1 x2 y2 cx1 cy1 cx2 cy2
|
|
22
|
+
fill_color stroke_color stroke_width stroke_strategy join dash cap
|
|
23
|
+
range layout)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def run(opts)
|
|
27
|
+
warn_if_unexpected opts
|
|
28
|
+
range = Args.extract_range opts, deck
|
|
29
|
+
draw = Args.extract_draw opts, deck
|
|
30
|
+
coords = Args.extract_coords opts, deck
|
|
31
|
+
range.each { |i| deck.cards[i].curve(coords[i], draw[i]) }
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|