squib 0.16.0.pre.preview1 → 0.16.0.pre.preview2
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/lib/squib/args/xywh_shorthands.rb +25 -30
 - data/lib/squib/dsl/save_png.rb +7 -10
 - data/lib/squib/version.rb +2 -1
 - data/samples/units/_shorthands.rb +3 -4
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: b29314be4965781e64f6f4d476fd7f0bbc629459636144f3a779637070315087
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: da76c57ce49a539e118d565b474088034a043552cf873df1affd457e12d6666e
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 7eddabde27b55fa664fe9501d46cecd4acef80e9135738f385196332465c9efc3fc87c9ae9137d2327cf0a8355f71a2bc646ac94d8f1b9fcd758a931237369d7
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: a53b8248edc59ab15560fadc73e1c4a0f3615b4c976c940a2226a54681f13b7b225d85d50ee46bed5b7955c8e4f1236f7e7fc80911dedea8cc23b71b3a0cf90b
         
     | 
| 
         @@ -3,49 +3,44 @@ require_relative 'unit_conversion' 
     | 
|
| 
       3 
3 
     | 
    
         
             
            module Squib
         
     | 
| 
       4 
4 
     | 
    
         
             
              module Args
         
     | 
| 
       5 
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 
6 
     | 
    
         | 
| 
      
 7 
     | 
    
         
            +
                  MIDDLE_ONLY = /^(middle|center)\s*$/
         
     | 
| 
      
 8 
     | 
    
         
            +
                  DECK_ONLY = /^deck\s*$/
         
     | 
| 
      
 9 
     | 
    
         
            +
                  MIDDLE_MINUS_REGEX = /^(middle|center)\s*\-\s*/
         
     | 
| 
      
 10 
     | 
    
         
            +
                  MIDDLE_PLUS_REGEX = /^(middle|center)\s*\+\s*/
         
     | 
| 
      
 11 
     | 
    
         
            +
                  DECK_MINUS_REGEX = /^deck\s*\-\s*/
         
     | 
| 
      
 12 
     | 
    
         
            +
                  DECK_PLUS_REGEX = /^deck\s*\+\s*/
         
     | 
| 
      
 13 
     | 
    
         
            +
                  DECK_DIV_REGEX = /^deck\s*\/\s*/
         
     | 
| 
       13 
14 
     | 
    
         | 
| 
       14 
15 
     | 
    
         
             
                  # dimension is usually either deck_width or deck_height
         
     | 
| 
       15 
16 
     | 
    
         
             
                  def apply_shorthands(arg, deck, axis: :x)
         
     | 
| 
       16 
17 
     | 
    
         
             
                    dimension = (axis == :x) ? deck.width : deck.height
         
     | 
| 
       17 
18 
     | 
    
         
             
                    arg_s = arg.to_s
         
     | 
| 
       18 
19 
     | 
    
         
             
                    case arg_s
         
     | 
| 
       19 
     | 
    
         
            -
                    when  
     | 
| 
      
 20 
     | 
    
         
            +
                    when MIDDLE_ONLY
         
     | 
| 
       20 
21 
     | 
    
         
             
                      dimension / 2.0
         
     | 
| 
       21 
     | 
    
         
            -
                    when  
     | 
| 
       22 
     | 
    
         
            -
                      dimension / 2.0
         
     | 
| 
       23 
     | 
    
         
            -
                    when 'deck'
         
     | 
| 
      
 22 
     | 
    
         
            +
                    when DECK_ONLY
         
     | 
| 
       24 
23 
     | 
    
         
             
                      dimension
         
     | 
| 
       25 
     | 
    
         
            -
                    when  
     | 
| 
       26 
     | 
    
         
            -
                      n = arg_s.sub  
     | 
| 
       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, ''
         
     | 
| 
      
 24 
     | 
    
         
            +
                    when MIDDLE_MINUS_REGEX # e.g. width: middle - 3
         
     | 
| 
      
 25 
     | 
    
         
            +
                      n = arg_s.sub MIDDLE_MINUS_REGEX, ''
         
     | 
| 
       39 
26 
     | 
    
         
             
                      n = UnitConversion.parse(n, deck.dpi, deck.cell_px).to_f
         
     | 
| 
       40 
     | 
    
         
            -
                       
     | 
| 
      
 27 
     | 
    
         
            +
                      dimension / 2.0 - n
         
     | 
| 
       41 
28 
     | 
    
         
             
                    when MIDDLE_PLUS_REGEX # e.g. middle + 1.5in
         
     | 
| 
       42 
29 
     | 
    
         
             
                      n = arg_s.sub MIDDLE_PLUS_REGEX, ''
         
     | 
| 
       43 
     | 
    
         
            -
                      n = UnitConversion.parse(n, deck.dpi, deck.cell_px)
         
     | 
| 
      
 30 
     | 
    
         
            +
                      n = UnitConversion.parse(n, deck.dpi, deck.cell_px).to_f
         
     | 
| 
       44 
31 
     | 
    
         
             
                      dimension / 2.0 + n
         
     | 
| 
       45 
     | 
    
         
            -
                    when  
     | 
| 
       46 
     | 
    
         
            -
                      n = arg_s.sub  
     | 
| 
       47 
     | 
    
         
            -
                      n = UnitConversion.parse(n, deck.dpi, deck.cell_px)
         
     | 
| 
       48 
     | 
    
         
            -
                      dimension  
     | 
| 
      
 32 
     | 
    
         
            +
                    when DECK_MINUS_REGEX # e.g. width: deck - 1.5in
         
     | 
| 
      
 33 
     | 
    
         
            +
                      n = arg_s.sub DECK_MINUS_REGEX, ''
         
     | 
| 
      
 34 
     | 
    
         
            +
                      n = UnitConversion.parse(n, deck.dpi, deck.cell_px).to_f
         
     | 
| 
      
 35 
     | 
    
         
            +
                      dimension - n
         
     | 
| 
      
 36 
     | 
    
         
            +
                    when DECK_PLUS_REGEX # e.g. deck + 1.5in (which is weird but ok)
         
     | 
| 
      
 37 
     | 
    
         
            +
                      n = arg_s.sub DECK_PLUS_REGEX, ''
         
     | 
| 
      
 38 
     | 
    
         
            +
                      n = UnitConversion.parse(n, deck.dpi, deck.cell_px).to_f
         
     | 
| 
      
 39 
     | 
    
         
            +
                      dimension + n
         
     | 
| 
      
 40 
     | 
    
         
            +
                    when DECK_DIV_REGEX # e.g. width: deck/3
         
     | 
| 
      
 41 
     | 
    
         
            +
                      n = arg_s.sub DECK_DIV_REGEX, ''
         
     | 
| 
      
 42 
     | 
    
         
            +
                      n = UnitConversion.parse(n, deck.dpi, deck.cell_px).to_f
         
     | 
| 
      
 43 
     | 
    
         
            +
                      dimension / n
         
     | 
| 
       49 
44 
     | 
    
         
             
                    else
         
     | 
| 
       50 
45 
     | 
    
         
             
                      arg
         
     | 
| 
       51 
46 
     | 
    
         
             
                    end
         
     | 
    
        data/lib/squib/dsl/save_png.rb
    CHANGED
    
    | 
         @@ -29,19 +29,16 @@ module Squib 
     | 
|
| 
       29 
29 
     | 
    
         | 
| 
       30 
30 
     | 
    
         
             
                  def run(opts)
         
     | 
| 
       31 
31 
     | 
    
         
             
                    warn_if_unexpected opts
         
     | 
| 
       32 
     | 
    
         
            -
                     
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
                       
     | 
| 
       36 
     | 
    
         
            -
                         
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
                          bar.increment
         
     | 
| 
       39 
     | 
    
         
            -
                        end
         
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
      
 32 
     | 
    
         
            +
                    range = Args.extract_range opts, deck
         
     | 
| 
      
 33 
     | 
    
         
            +
                    batch = Args.extract_save_batch opts, deck
         
     | 
| 
      
 34 
     | 
    
         
            +
                    @bar.start("Saving PNGs to #{batch.summary}", deck.size) do |bar|
         
     | 
| 
      
 35 
     | 
    
         
            +
                      range.map do |i|
         
     | 
| 
      
 36 
     | 
    
         
            +
                        deck.cards[i].save_png(batch[i])
         
     | 
| 
      
 37 
     | 
    
         
            +
                        bar.increment
         
     | 
| 
       41 
38 
     | 
    
         
             
                      end
         
     | 
| 
       42 
39 
     | 
    
         
             
                    end
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
40 
     | 
    
         
             
                  end
         
     | 
| 
       45 
41 
     | 
    
         
             
                end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
       46 
43 
     | 
    
         
             
              end
         
     | 
| 
       47 
44 
     | 
    
         
             
            end
         
     | 
    
        data/lib/squib/version.rb
    CHANGED
    
    
| 
         @@ -20,14 +20,13 @@ Squib::Deck.new(width: '0.5in', height: '0.25in') do 
     | 
|
| 
       20 
20 
     | 
    
         | 
| 
       21 
21 
     | 
    
         
             
              # We can also do width-, height-, width/, height/
         
     | 
| 
       22 
22 
     | 
    
         
             
              rect x: 20, y: 5, stroke_color: :green,
         
     | 
| 
       23 
     | 
    
         
            -
              width: ' 
     | 
| 
      
 23 
     | 
    
         
            +
              width: 'deck - 0.1in', height: 10
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
       25 
     | 
    
         
            -
              rect x: 10, y: 50, width: 10, height: ' 
     | 
| 
      
 25 
     | 
    
         
            +
              rect x: 10, y: 50, width: 10, height: 'deck / 3',
         
     | 
| 
       26 
26 
     | 
    
         
             
                   stroke_color: :purple
         
     | 
| 
       27 
27 
     | 
    
         | 
| 
       28 
28 
     | 
    
         
             
              # And middle+/-
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
              rect x: 'middle + 0.1in', y: 'middle - 0.1in',
         
     | 
| 
      
 29 
     | 
    
         
            +
              rect x: 'middle + 0.1in', y: 'center - 0.1in',
         
     | 
| 
       31 
30 
     | 
    
         
             
                   width: '0.1in', height: '0.1in', fill_color: :blue
         
     | 
| 
       32 
31 
     | 
    
         | 
| 
       33 
32 
     | 
    
         
             
              # Layouts apply this too.
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: squib
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.16.0.pre. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.16.0.pre.preview2
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Andy Meneely
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2020-11- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2020-11-24 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: cairo
         
     |