squib 0.14.3.pre1 → 0.16.0.pre.preview1
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/workflows/tests.yml +22 -0
 - data/CHANGELOG.md +58 -2
 - data/Dockerfile +27 -0
 - data/Guardfile +8 -0
 - data/README.md +24 -6
 - data/RELEASE TODO.md +1 -0
 - data/Rakefile +3 -0
 - data/lib/squib.rb +3 -1
 - data/lib/squib/args/arg_loader.rb +109 -106
 - data/lib/squib/args/box.rb +52 -48
 - data/lib/squib/args/card_range.rb +26 -24
 - data/lib/squib/args/color_validator.rb +4 -9
 - data/lib/squib/args/coords.rb +39 -25
 - data/lib/squib/args/csv_opts.rb +13 -16
 - data/lib/squib/args/dir_validator.rb +7 -12
 - data/lib/squib/args/draw.rb +69 -68
 - data/lib/squib/args/embed_adjust.rb +12 -15
 - data/lib/squib/args/embed_key.rb +6 -11
 - data/lib/squib/args/hand_special.rb +25 -25
 - data/lib/squib/args/import.rb +54 -27
 - data/lib/squib/args/input_file.rb +22 -26
 - data/lib/squib/args/paint.rb +30 -31
 - data/lib/squib/args/paragraph.rb +95 -93
 - data/lib/squib/args/save_batch.rb +50 -48
 - data/lib/squib/args/scale_box.rb +43 -39
 - data/lib/squib/args/sheet.rb +147 -149
 - data/lib/squib/args/showcase_special.rb +32 -29
 - data/lib/squib/args/sprue_file.rb +30 -30
 - data/lib/squib/args/svg_special.rb +26 -26
 - data/lib/squib/args/transform.rb +48 -54
 - data/lib/squib/args/typographer.rb +88 -92
 - data/lib/squib/args/unit_conversion.rb +6 -8
 - data/lib/squib/args/xywh_shorthands.rb +56 -0
 - data/lib/squib/builtin/projects/advanced/config.yml +3 -6
 - data/lib/squib/builtin/projects/basic/config.yml +3 -6
 - data/lib/squib/commands/make_sprue.rb +2 -0
 - data/lib/squib/conf.rb +5 -5
 - data/lib/squib/deck.rb +34 -12
 - data/lib/squib/dsl/background.rb +35 -0
 - data/lib/squib/dsl/circle.rb +39 -0
 - data/lib/squib/dsl/csv.rb +42 -0
 - data/lib/squib/dsl/curve.rb +35 -0
 - data/lib/squib/dsl/cut_zone.rb +47 -0
 - data/lib/squib/dsl/ellipse.rb +37 -0
 - data/lib/squib/dsl/grid.rb +35 -0
 - data/lib/squib/{api → dsl}/groups.rb +0 -0
 - data/lib/squib/dsl/hand.rb +42 -0
 - data/lib/squib/dsl/line.rb +35 -0
 - data/lib/squib/dsl/png.rb +56 -0
 - data/lib/squib/dsl/polygon.rb +36 -0
 - data/lib/squib/dsl/rect.rb +37 -0
 - data/lib/squib/dsl/safe_zone.rb +48 -0
 - data/lib/squib/dsl/save.rb +21 -0
 - data/lib/squib/dsl/save_pdf.rb +50 -0
 - data/lib/squib/dsl/save_png.rb +47 -0
 - data/lib/squib/dsl/save_sheet.rb +53 -0
 - data/lib/squib/dsl/showcase.rb +43 -0
 - data/lib/squib/dsl/star.rb +37 -0
 - data/lib/squib/dsl/svg.rb +62 -0
 - data/lib/squib/dsl/text.rb +54 -0
 - data/lib/squib/dsl/text_embed.rb +78 -0
 - data/lib/squib/dsl/triangle.rb +35 -0
 - data/lib/squib/{api → dsl}/units.rb +10 -0
 - data/lib/squib/dsl/xlsx.rb +40 -0
 - data/lib/squib/dsl/yaml.rb +40 -0
 - data/lib/squib/errors_warnings/warn_unexpected_params.rb +14 -0
 - data/lib/squib/graphics/cairo_context_wrapper.rb +2 -2
 - data/lib/squib/graphics/image.rb +0 -6
 - data/lib/squib/graphics/save_images.rb +3 -3
 - data/lib/squib/graphics/save_sprue.rb +39 -12
 - data/lib/squib/graphics/showcase.rb +1 -1
 - data/lib/squib/graphics/text.rb +37 -9
 - data/lib/squib/import/csv_importer.rb +45 -0
 - data/lib/squib/import/quantity_exploder.rb +18 -0
 - data/lib/squib/import/xlsx_importer.rb +28 -0
 - data/lib/squib/import/yaml_importer.rb +30 -0
 - data/lib/squib/layout_parser.rb +24 -7
 - data/lib/squib/sprues/crop_line.rb +6 -6
 - data/lib/squib/sprues/crop_line_dash.rb +6 -6
 - data/lib/squib/sprues/sprue.rb +19 -14
 - data/lib/squib/sprues/sprue_schema.rb +4 -2
 - data/lib/squib/version.rb +1 -1
 - data/samples/autoscale_font/_autoscale_font.rb +77 -8
 - data/samples/colors/_colors.rb +11 -5
 - data/samples/colors/_switch_color.rb +33 -0
 - data/samples/data/_excel.rb +1 -1
 - data/samples/images/_more_load_images.rb +1 -1
 - data/samples/ranges/_ranges.rb +1 -1
 - data/samples/saves/_save_filenames.rb +28 -0
 - data/samples/saves/_save_pdf.rb +1 -1
 - data/samples/saves/_saves.rb +2 -1
 - data/samples/shapes/_draw_shapes.rb +2 -2
 - data/samples/sprues/_advanced_sprues.rb +4 -3
 - data/samples/sprues/_builtin_sprues.rb +1 -0
 - data/samples/sprues/_fold_sheet.rb +4 -1
 - data/samples/text/_text.rb +6 -1
 - data/samples/text/_text_options.rb +2 -1
 - data/samples/units/_cells.rb +51 -0
 - data/samples/units/_shorthands.rb +49 -0
 - data/samples/units/_units.rb +7 -0
 - data/squib.gemspec +19 -13
 - metadata +151 -61
 - data/.travis.yml +0 -19
 - data/appveyor.yml +0 -24
 - data/lib/squib/api/background.rb +0 -15
 - data/lib/squib/api/data.rb +0 -137
 - data/lib/squib/api/image.rb +0 -49
 - data/lib/squib/api/save.rb +0 -83
 - data/lib/squib/api/shapes.rb +0 -124
 - data/lib/squib/api/text.rb +0 -25
 - data/lib/squib/api/text_embed.rb +0 -71
 - data/samples/bug256/_bug256.rb +0 -13
 
| 
         @@ -1,15 +1,10 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require_relative '../constants'
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
       3 
4 
     | 
    
         
             
            module Squib
         
     | 
| 
       4 
5 
     | 
    
         
             
              module Args
         
     | 
| 
       5 
     | 
    
         
            -
                # :nodoc:
         
     | 
| 
       6 
     | 
    
         
            -
                # @api private
         
     | 
| 
       7 
6 
     | 
    
         
             
                module UnitConversion
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
                  # :nodoc:
         
     | 
| 
       10 
     | 
    
         
            -
                  # @api private
         
     | 
| 
       11 
     | 
    
         
            -
                  module_function
         
     | 
| 
       12 
     | 
    
         
            -
                  def parse(arg, dpi=300)
         
     | 
| 
      
 7 
     | 
    
         
            +
                  module_function def parse(arg, dpi=300, cell_px=37.5)
         
     | 
| 
       13 
8 
     | 
    
         
             
                    case arg.to_s.rstrip
         
     | 
| 
       14 
9 
     | 
    
         
             
                    when /in$/ # ends with "in"
         
     | 
| 
       15 
10 
     | 
    
         
             
                      arg.rstrip[0..-2].to_f * dpi
         
     | 
| 
         @@ -19,11 +14,14 @@ module Squib 
     | 
|
| 
       19 
14 
     | 
    
         
             
                      arg.rstrip[0..-2].to_f * dpi * INCHES_IN_CM
         
     | 
| 
       20 
15 
     | 
    
         
             
                    when /mm$/ # ends with "mm"
         
     | 
| 
       21 
16 
     | 
    
         
             
                      arg.rstrip[0..-2].to_f * dpi * INCHES_IN_CM / 10.0
         
     | 
| 
      
 17 
     | 
    
         
            +
                    when /deg$/ # ends with "deg"
         
     | 
| 
      
 18 
     | 
    
         
            +
                      arg.rstrip[0..-3].to_f * (Math::PI / 180.0)
         
     | 
| 
      
 19 
     | 
    
         
            +
                    when /c(ell)?[s]?$/ # ends with 'c', 'cell', or 'cells'
         
     | 
| 
      
 20 
     | 
    
         
            +
                      arg.sub(/c(ell)?[s]?$/, '').to_f * cell_px
         
     | 
| 
       22 
21 
     | 
    
         
             
                    else
         
     | 
| 
       23 
22 
     | 
    
         
             
                      arg
         
     | 
| 
       24 
23 
     | 
    
         
             
                    end
         
     | 
| 
       25 
24 
     | 
    
         
             
                  end
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
25 
     | 
    
         
             
                end
         
     | 
| 
       28 
26 
     | 
    
         
             
              end
         
     | 
| 
       29 
27 
     | 
    
         
             
            end
         
     | 
| 
         @@ -0,0 +1,56 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require_relative 'unit_conversion'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Squib
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Args
         
     | 
| 
      
 5 
     | 
    
         
            +
                module XYWHShorthands
         
     | 
| 
      
 6 
     | 
    
         
            +
                  WIDTH_MINUS_REGEX = /^width\s*\-\s*/
         
     | 
| 
      
 7 
     | 
    
         
            +
                  HEIGHT_MINUS_REGEX = /^height\s*\-\s*/
         
     | 
| 
      
 8 
     | 
    
         
            +
                  WIDTH_DIV_REGEX = /^width\s*\/\s*/
         
     | 
| 
      
 9 
     | 
    
         
            +
                  HEIGHT_DIV_REGEX = /^height\s*\/\s*/
         
     | 
| 
      
 10 
     | 
    
         
            +
                  MIDDLE_PLUS_REGEX = /^middle\s*\+\s*/
         
     | 
| 
      
 11 
     | 
    
         
            +
                  MIDDLE_MINUS_REGEX = /^middle\s*\-\s*/
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                  # dimension is usually either deck_width or deck_height
         
     | 
| 
      
 15 
     | 
    
         
            +
                  def apply_shorthands(arg, deck, axis: :x)
         
     | 
| 
      
 16 
     | 
    
         
            +
                    dimension = (axis == :x) ? deck.width : deck.height
         
     | 
| 
      
 17 
     | 
    
         
            +
                    arg_s = arg.to_s
         
     | 
| 
      
 18 
     | 
    
         
            +
                    case arg_s
         
     | 
| 
      
 19 
     | 
    
         
            +
                    when 'middle'
         
     | 
| 
      
 20 
     | 
    
         
            +
                      dimension / 2.0
         
     | 
| 
      
 21 
     | 
    
         
            +
                    when 'center'
         
     | 
| 
      
 22 
     | 
    
         
            +
                      dimension / 2.0
         
     | 
| 
      
 23 
     | 
    
         
            +
                    when 'deck'
         
     | 
| 
      
 24 
     | 
    
         
            +
                      dimension
         
     | 
| 
      
 25 
     | 
    
         
            +
                    when WIDTH_MINUS_REGEX # e.g. width - 1.5in
         
     | 
| 
      
 26 
     | 
    
         
            +
                      n = arg_s.sub WIDTH_MINUS_REGEX, ''
         
     | 
| 
      
 27 
     | 
    
         
            +
                      n = UnitConversion.parse(n, deck.dpi, deck.cell_px)
         
     | 
| 
      
 28 
     | 
    
         
            +
                      deck.width - n
         
     | 
| 
      
 29 
     | 
    
         
            +
                    when HEIGHT_MINUS_REGEX # e.g. height - 1.5in
         
     | 
| 
      
 30 
     | 
    
         
            +
                      n = arg_s.sub HEIGHT_MINUS_REGEX, ''
         
     | 
| 
      
 31 
     | 
    
         
            +
                      n = UnitConversion.parse(n, deck.dpi, deck.cell_px)
         
     | 
| 
      
 32 
     | 
    
         
            +
                      deck.height - n
         
     | 
| 
      
 33 
     | 
    
         
            +
                    when WIDTH_DIV_REGEX # e.g. width / 3
         
     | 
| 
      
 34 
     | 
    
         
            +
                      n = arg_s.sub WIDTH_DIV_REGEX, ''
         
     | 
| 
      
 35 
     | 
    
         
            +
                      n = UnitConversion.parse(n, deck.dpi, deck.cell_px).to_f
         
     | 
| 
      
 36 
     | 
    
         
            +
                      deck.width / n
         
     | 
| 
      
 37 
     | 
    
         
            +
                    when HEIGHT_DIV_REGEX # e.g. height / 3
         
     | 
| 
      
 38 
     | 
    
         
            +
                      n = arg_s.sub HEIGHT_DIV_REGEX, ''
         
     | 
| 
      
 39 
     | 
    
         
            +
                      n = UnitConversion.parse(n, deck.dpi, deck.cell_px).to_f
         
     | 
| 
      
 40 
     | 
    
         
            +
                      deck.height / n
         
     | 
| 
      
 41 
     | 
    
         
            +
                    when MIDDLE_PLUS_REGEX # e.g. middle + 1.5in
         
     | 
| 
      
 42 
     | 
    
         
            +
                      n = arg_s.sub MIDDLE_PLUS_REGEX, ''
         
     | 
| 
      
 43 
     | 
    
         
            +
                      n = UnitConversion.parse(n, deck.dpi, deck.cell_px)
         
     | 
| 
      
 44 
     | 
    
         
            +
                      dimension / 2.0 + n
         
     | 
| 
      
 45 
     | 
    
         
            +
                    when MIDDLE_MINUS_REGEX # e.g. middle - 1.5in
         
     | 
| 
      
 46 
     | 
    
         
            +
                      n = arg_s.sub MIDDLE_MINUS_REGEX, ''
         
     | 
| 
      
 47 
     | 
    
         
            +
                      n = UnitConversion.parse(n, deck.dpi, deck.cell_px)
         
     | 
| 
      
 48 
     | 
    
         
            +
                      dimension / 2.0 - n
         
     | 
| 
      
 49 
     | 
    
         
            +
                    else
         
     | 
| 
      
 50 
     | 
    
         
            +
                      arg
         
     | 
| 
      
 51 
     | 
    
         
            +
                    end
         
     | 
| 
      
 52 
     | 
    
         
            +
                  end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                end
         
     | 
| 
      
 55 
     | 
    
         
            +
              end
         
     | 
| 
      
 56 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -1,8 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # Settings in the config.yml are overriding Squib's defaults. Anything in the main script will override this.
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            # DPI  
     | 
| 
       4 
     | 
    
         
            -
            # Default: 300
         
     | 
| 
       5 
     | 
    
         
            -
            #dpi: 72
         
     | 
| 
      
 3 
     | 
    
         
            +
            # Looking for DPI? It needs to be a parameter to Squib::Deck.new. See https://squib.readthedocs.io/en/latest/dsl/deck.html
         
     | 
| 
       6 
4 
     | 
    
         | 
| 
       7 
5 
     | 
    
         
             
            #antialias: best #recommended. Only about 10% slower than fast
         
     | 
| 
       8 
6 
     | 
    
         
             
            #antialias: default # set the anti-aliasing algorithm. default defers to the underlying graphics device. See http://www.cairographics.org/manual/cairo-cairo-t.html#cairo-antialias-t
         
     | 
| 
         @@ -48,6 +46,5 @@ warn_ellipsize: true # default 
     | 
|
| 
       48 
46 
     | 
    
         
             
            warn_png_scale: true # default
         
     | 
| 
       49 
47 
     | 
    
         
             
            # warn_png_scale: false # turn off entirely
         
     | 
| 
       50 
48 
     | 
    
         | 
| 
       51 
     | 
    
         
            -
            #  
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
            # warn_zero_size_image: false # turn off warnings
         
     | 
| 
      
 49 
     | 
    
         
            +
            # How many pixels are in a "cell"?
         
     | 
| 
      
 50 
     | 
    
         
            +
            # cell_px: 37.5 # default
         
     | 
| 
         @@ -1,8 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # Settings in the config.yml are overriding Squib's defaults. Anything in the main script will override this.
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            # DPI  
     | 
| 
       4 
     | 
    
         
            -
            # Default: 300
         
     | 
| 
       5 
     | 
    
         
            -
            #dpi: 72
         
     | 
| 
      
 3 
     | 
    
         
            +
            # Looking for DPI? It needs to be a parameter to Squib::Deck.new
         
     | 
| 
       6 
4 
     | 
    
         | 
| 
       7 
5 
     | 
    
         
             
            #antialias: best #recommended. Only about 10% slower than fast
         
     | 
| 
       8 
6 
     | 
    
         
             
            #antialias: default # set the anti-aliasing algorithm. default defers to the underlying graphics device. See http://www.cairographics.org/manual/cairo-cairo-t.html#cairo-antialias-t
         
     | 
| 
         @@ -48,6 +46,5 @@ 
     | 
|
| 
       48 
46 
     | 
    
         
             
            # warn_png_scale: true # default
         
     | 
| 
       49 
47 
     | 
    
         
             
            # warn_png_scale: false # turn off entirely
         
     | 
| 
       50 
48 
     | 
    
         | 
| 
       51 
     | 
    
         
            -
            #  
     | 
| 
       52 
     | 
    
         
            -
            #  
     | 
| 
       53 
     | 
    
         
            -
            # warn_zero_size_image: false # turn off warnings
         
     | 
| 
      
 49 
     | 
    
         
            +
            # How many pixels are in a "cell"?
         
     | 
| 
      
 50 
     | 
    
         
            +
            # cell_px: 37.5 # default
         
     | 
    
        data/lib/squib/conf.rb
    CHANGED
    
    | 
         @@ -17,6 +17,7 @@ module Squib 
     | 
|
| 
       17 
17 
     | 
    
         
             
                DEFAULTS = {
         
     | 
| 
       18 
18 
     | 
    
         
             
                  'antialias'     => 'best',
         
     | 
| 
       19 
19 
     | 
    
         
             
                  'backend'       => 'memory',
         
     | 
| 
      
 20 
     | 
    
         
            +
                  'cell_px'       => 37.5,
         
     | 
| 
       20 
21 
     | 
    
         
             
                  'count_format'  => '%02d',
         
     | 
| 
       21 
22 
     | 
    
         
             
                  'custom_colors' => {},
         
     | 
| 
       22 
23 
     | 
    
         
             
                  'dir'           => '_output',
         
     | 
| 
         @@ -35,7 +36,6 @@ module Squib 
     | 
|
| 
       35 
36 
     | 
    
         
             
                  'text_hint'     => 'off',
         
     | 
| 
       36 
37 
     | 
    
         
             
                  'warn_ellipsize' => true,
         
     | 
| 
       37 
38 
     | 
    
         
             
                  'warn_png_scale' => true,
         
     | 
| 
       38 
     | 
    
         
            -
                  'warn_zero_size_image' => true,
         
     | 
| 
       39 
39 
     | 
    
         
             
                }
         
     | 
| 
       40 
40 
     | 
    
         | 
| 
       41 
41 
     | 
    
         
             
                # Translate the hints to the methods.
         
     | 
| 
         @@ -90,6 +90,10 @@ module Squib 
     | 
|
| 
       90 
90 
     | 
    
         
             
                  @typographer
         
     | 
| 
       91 
91 
     | 
    
         
             
                end
         
     | 
| 
       92 
92 
     | 
    
         | 
| 
      
 93 
     | 
    
         
            +
                def cell_px
         
     | 
| 
      
 94 
     | 
    
         
            +
                  @config_hash['cell_px'].to_f
         
     | 
| 
      
 95 
     | 
    
         
            +
                end
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
       93 
97 
     | 
    
         
             
                def dir
         
     | 
| 
       94 
98 
     | 
    
         
             
                  @config_hash['dir']
         
     | 
| 
       95 
99 
     | 
    
         
             
                end
         
     | 
| 
         @@ -121,10 +125,6 @@ module Squib 
     | 
|
| 
       121 
125 
     | 
    
         
             
                def warn_png_scale?
         
     | 
| 
       122 
126 
     | 
    
         
             
                  @config_hash['warn_png_scale']
         
     | 
| 
       123 
127 
     | 
    
         
             
                end
         
     | 
| 
       124 
     | 
    
         
            -
                
         
     | 
| 
       125 
     | 
    
         
            -
                def warn_zero_size_image?
         
     | 
| 
       126 
     | 
    
         
            -
                  @config_hash['warn_zero_size_image']
         
     | 
| 
       127 
     | 
    
         
            -
                end
         
     | 
| 
       128 
128 
     | 
    
         | 
| 
       129 
129 
     | 
    
         
             
                private
         
     | 
| 
       130 
130 
     | 
    
         | 
    
        data/lib/squib/deck.rb
    CHANGED
    
    | 
         @@ -33,7 +33,7 @@ module Squib 
     | 
|
| 
       33 
33 
     | 
    
         
             
                                      :img_dir, :prefix, :text_hint, :typographer
         
     | 
| 
       34 
34 
     | 
    
         
             
                # :nodoc:
         
     | 
| 
       35 
35 
     | 
    
         
             
                # @api private
         
     | 
| 
       36 
     | 
    
         
            -
                attr_reader :layout, :conf, :dpi, :font
         
     | 
| 
      
 36 
     | 
    
         
            +
                attr_reader :layout, :conf, :dpi, :font, :cell_px
         
     | 
| 
       37 
37 
     | 
    
         | 
| 
       38 
38 
     | 
    
         
             
                #
         
     | 
| 
       39 
39 
     | 
    
         
             
                # deck.size is really just @cards.size
         
     | 
| 
         @@ -63,12 +63,13 @@ module Squib 
     | 
|
| 
       63 
63 
     | 
    
         
             
                  @font          = DEFAULT_FONT
         
     | 
| 
       64 
64 
     | 
    
         
             
                  @cards         = []
         
     | 
| 
       65 
65 
     | 
    
         
             
                  @conf          = Conf.load(config)
         
     | 
| 
      
 66 
     | 
    
         
            +
                  @cell_px       = @conf.cell_px
         
     | 
| 
       66 
67 
     | 
    
         
             
                  @progress_bar  = Progress.new(@conf.progress_bars) # FIXME this is evil. Using something different with @ and non-@
         
     | 
| 
       67 
68 
     | 
    
         
             
                  show_info(config, layout)
         
     | 
| 
       68 
     | 
    
         
            -
                  @width         = Args::UnitConversion.parse width, dpi
         
     | 
| 
       69 
     | 
    
         
            -
                  @height        = Args::UnitConversion.parse height, dpi
         
     | 
| 
      
 69 
     | 
    
         
            +
                  @width         = Args::UnitConversion.parse width, dpi, @cell_px
         
     | 
| 
      
 70 
     | 
    
         
            +
                  @height        = Args::UnitConversion.parse height, dpi, @cell_px
         
     | 
| 
       70 
71 
     | 
    
         
             
                  cards.times{ |i| @cards << Squib::Card.new(self, @width, @height, i) }
         
     | 
| 
       71 
     | 
    
         
            -
                  @layout = LayoutParser.new(dpi).load_layout(layout)
         
     | 
| 
      
 72 
     | 
    
         
            +
                  @layout = LayoutParser.new(dpi, @cell_px).load_layout(layout)
         
     | 
| 
       72 
73 
     | 
    
         
             
                  enable_groups_from_env!
         
     | 
| 
       73 
74 
     | 
    
         
             
                  if block_given?
         
     | 
| 
       74 
75 
     | 
    
         
             
                    instance_eval(&block) # here we go. wheeeee!
         
     | 
| 
         @@ -102,15 +103,36 @@ module Squib 
     | 
|
| 
       102 
103 
     | 
    
         
             
                ##################
         
     | 
| 
       103 
104 
     | 
    
         
             
                ### PUBLIC API ###
         
     | 
| 
       104 
105 
     | 
    
         
             
                ##################
         
     | 
| 
       105 
     | 
    
         
            -
                require_relative 'api/background'
         
     | 
| 
       106 
     | 
    
         
            -
                require_relative 'api/data'
         
     | 
| 
       107 
     | 
    
         
            -
                require_relative 'api/groups'
         
     | 
| 
       108 
     | 
    
         
            -
                require_relative 'api/image'
         
     | 
| 
       109 
     | 
    
         
            -
                require_relative 'api/save'
         
     | 
| 
       110 
106 
     | 
    
         
             
                require_relative 'api/settings'
         
     | 
| 
       111 
     | 
    
         
            -
                require_relative 'api/shapes'
         
     | 
| 
       112 
     | 
    
         
            -
                require_relative 'api/text'
         
     | 
| 
       113 
     | 
    
         
            -
                require_relative 'api/units'
         
     | 
| 
       114 
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'
         
     | 
| 
       115 
137 
     | 
    
         
             
              end
         
     | 
| 
       116 
138 
     | 
    
         
             
            end
         
     | 
| 
         @@ -0,0 +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
         
     | 
| 
         @@ -0,0 +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
         
     | 
| 
         @@ -0,0 +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
         
     | 
| 
         @@ -0,0 +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
         
     | 
| 
         @@ -0,0 +1,47 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require_relative '../errors_warnings/warn_unexpected_params'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Squib
         
     | 
| 
      
 4 
     | 
    
         
            +
              class Deck
         
     | 
| 
      
 5 
     | 
    
         
            +
                def cut_zone(opts = {})
         
     | 
| 
      
 6 
     | 
    
         
            +
                  DSL::CutZone.new(self, __callee__).run(opts)
         
     | 
| 
      
 7 
     | 
    
         
            +
                end
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              module DSL
         
     | 
| 
      
 11 
     | 
    
         
            +
                class CutZone
         
     | 
| 
      
 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(x y width height margin angle
         
     | 
| 
      
 22 
     | 
    
         
            +
                       x_radius y_radius radius
         
     | 
| 
      
 23 
     | 
    
         
            +
                       fill_color stroke_color stroke_width stroke_strategy join dash cap
         
     | 
| 
      
 24 
     | 
    
         
            +
                       range layout)
         
     | 
| 
      
 25 
     | 
    
         
            +
                  end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                  def run(opts)
         
     | 
| 
      
 28 
     | 
    
         
            +
                    warn_if_unexpected opts
         
     | 
| 
      
 29 
     | 
    
         
            +
                    cut_defaults = {
         
     | 
| 
      
 30 
     | 
    
         
            +
                      margin: '0.125in',
         
     | 
| 
      
 31 
     | 
    
         
            +
                      radius: '0.125in',
         
     | 
| 
      
 32 
     | 
    
         
            +
                      stroke_color: :red,
         
     | 
| 
      
 33 
     | 
    
         
            +
                      fill_color: '#0000',
         
     | 
| 
      
 34 
     | 
    
         
            +
                      stroke_width: 2.0,
         
     | 
| 
      
 35 
     | 
    
         
            +
                    }
         
     | 
| 
      
 36 
     | 
    
         
            +
                    new_opts = cut_defaults.merge(opts)
         
     | 
| 
      
 37 
     | 
    
         
            +
                    margin = Args::UnitConversion.parse new_opts[:margin], @deck.dpi, @deck.cell_px
         
     | 
| 
      
 38 
     | 
    
         
            +
                    new_opts[:x] = margin
         
     | 
| 
      
 39 
     | 
    
         
            +
                    new_opts[:y] = margin
         
     | 
| 
      
 40 
     | 
    
         
            +
                    new_opts[:width] = deck.width - (2 * margin)
         
     | 
| 
      
 41 
     | 
    
         
            +
                    new_opts[:height] = deck.height - (2 * margin)
         
     | 
| 
      
 42 
     | 
    
         
            +
                    new_opts.delete :margin
         
     | 
| 
      
 43 
     | 
    
         
            +
                    deck.rect new_opts
         
     | 
| 
      
 44 
     | 
    
         
            +
                  end
         
     | 
| 
      
 45 
     | 
    
         
            +
                end
         
     | 
| 
      
 46 
     | 
    
         
            +
              end
         
     | 
| 
      
 47 
     | 
    
         
            +
            end
         
     |