svgshield 0.1.2 → 0.1.3
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/README.md +1 -1
- data/lib/svgshield/version.rb +1 -1
- data/lib/svgshield.rb +39 -10
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 98c71f4e4668d935007fd16f61e3fa01bd22e5f8
         | 
| 4 | 
            +
              data.tar.gz: 564d22d63da5aa2e1250139814b04ff48b78bc3a
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 5fdd57a767b1a78b7ad742313a9b44ddd5ffdd58c5ac3c3f33ba308143e86ba16a0567e185a142ffb0580676baf83e45a58ba941825f37616dd8046e08009c72
         | 
| 7 | 
            +
              data.tar.gz: af68cde0e251c61e92fd2c49c83a823a4d4e5abe2cb0cb6ef38cb814da24df35e5fdfe2972999936472e94de28bce2e3e2f08eb314f3ecbb477cedacf5957921
         | 
    
        data/README.md
    CHANGED
    
    
    
        data/lib/svgshield/version.rb
    CHANGED
    
    
    
        data/lib/svgshield.rb
    CHANGED
    
    | @@ -8,16 +8,26 @@ class Svgshield | |
| 8 8 | 
             
              def initialize(subject, status, color = '#aaa')
         | 
| 9 9 | 
             
                color = Color::CSS[color] if color[0] == '#'
         | 
| 10 10 |  | 
| 11 | 
            -
                 | 
| 12 | 
            -
             | 
| 11 | 
            +
                # subject_width = 37 
         | 
| 12 | 
            +
                # status_width = 53 
         | 
| 13 | 
            +
                full_width = 86
         | 
| 14 | 
            +
                full_height = 20
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                @shield = Rasem::SVGImage.new(width: full_width, height: full_height) do
         | 
| 17 | 
            +
                  linearGradient('b', x2: 0, y2: '100%') do
         | 
| 13 18 | 
             
                    stop 0, '#bbb', '.1'
         | 
| 14 19 | 
             
                    stop 1, nil, '.1'
         | 
| 15 20 | 
             
                  end
         | 
| 16 21 |  | 
| 17 | 
            -
                   | 
| 18 | 
            -
             | 
| 19 | 
            -
                   | 
| 20 | 
            -
             | 
| 22 | 
            +
                  clipPath(id: 'a') do
         | 
| 23 | 
            +
                    rect nil, nil, full_width, full_height, rx: 3, stroke_width: 0, fill: '#fff'
         | 
| 24 | 
            +
                  end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                  group 'clip-path' => 'url(#a)' do
         | 
| 27 | 
            +
                    path fill: '#555', d: "M0 0h37v#{full_height}H0z"
         | 
| 28 | 
            +
                    path fill: color, d: "M37 0h49v#{full_height}H37z"
         | 
| 29 | 
            +
                    path fill: 'url(#b)' d: "M0 0h#{full_width}v#{full_height}H0z"
         | 
| 30 | 
            +
                  end
         | 
| 21 31 |  | 
| 22 32 | 
             
                  group(
         | 
| 23 33 | 
             
                    fill: '#fff',
         | 
| @@ -25,10 +35,10 @@ class Svgshield | |
| 25 35 | 
             
                    'font-family' => 'DejaVu Sans,Verdana,Geneva,sans-serif',
         | 
| 26 36 | 
             
                    'font-size' => 11
         | 
| 27 37 | 
             
                  ) do
         | 
| 28 | 
            -
                    text( | 
| 29 | 
            -
                    text( | 
| 30 | 
            -
                    text( | 
| 31 | 
            -
                    text( | 
| 38 | 
            +
                    text(18.5, 15, fill: '#010101', 'fill-opacity' => '.3') { raw subject }
         | 
| 39 | 
            +
                    text(18.5, 14, fill: '#fff') { raw subject }
         | 
| 40 | 
            +
                    text(60.5, 15, fill: '#010101', 'fill-opacity' => '.3') { raw status }
         | 
| 41 | 
            +
                    text(60.5, 14, fill: '#fff') { raw status }
         | 
| 32 42 | 
             
                  end
         | 
| 33 43 | 
             
                end
         | 
| 34 44 | 
             
              end
         | 
| @@ -36,4 +46,23 @@ class Svgshield | |
| 36 46 | 
             
              def to_s
         | 
| 37 47 | 
             
                shield.to_s
         | 
| 38 48 | 
             
              end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
              private
         | 
| 51 | 
            +
             | 
| 52 | 
            +
              def string_width(string)
         | 
| 53 | 
            +
                # Output is (theoretically, anyway) in pixels
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                string.chars.inject(0) { |sum, char| sum + char_width(char) }.round 0
         | 
| 56 | 
            +
              end
         | 
| 57 | 
            +
             | 
| 58 | 
            +
              def char_width(char)
         | 
| 59 | 
            +
                {
         | 
| 60 | 
            +
                  'i' => 8.0,
         | 
| 61 | 
            +
                  'j' => 9.0,
         | 
| 62 | 
            +
                  'l' => 6.0,
         | 
| 63 | 
            +
                  'm' => 11.0,
         | 
| 64 | 
            +
                  'w' => 11.0,
         | 
| 65 | 
            +
                  '1' => 8.5
         | 
| 66 | 
            +
                }[char] || 9.0
         | 
| 67 | 
            +
              end
         | 
| 39 68 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: svgshield
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.1. | 
| 4 | 
            +
              version: 0.1.3
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Evertrue, Inc
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2017-04- | 
| 11 | 
            +
            date: 2017-04-13 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rasem
         |