Sha256: ff6e6a07350a88347fcf46764c8be0c70474e7de342474f23331fdb4bcab99ec

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

require 'rasem'
require 'color'
require "svgshield/version"

class Svgshield
  attr_reader :shield

  def initialize(subject, status, color = '#aaa')
    color = Color::CSS[color] if color[0] == '#'

    @shield = Rasem::SVGImage.new(width: 90, height: 20) do
      linearGradient('a', x2: 0, y2: '100%') do
        stop 0, '#bbb', '.1'
        stop 1, nil, '.1'
      end

      rect nil, nil, '90', '20', '3', fill: '#555', stroke_width: 0
      rect '37', nil, '53', '20', '3', fill: color, stroke_width: 0
      path fill: color, d: 'M37 0h4v20h-4z'
      rect nil, nil, '90', '20', '3', fill: 'url(#a)', stroke_width: 0

      group(
        fill: '#fff',
        'text-anchor' => 'middle',
        'font-family' => 'DejaVu Sans,Verdana,Geneva,sans-serif',
        'font-size' => 11
      ) do
        text(19.5, 15, fill: '#010101', 'fill-opacity' => '.3') { raw subject }
        text(19.5, 14, fill: '#fff') { raw subject }
        text(62.5, 15, fill: '#010101', 'fill-opacity' => '.3') { raw status }
        text(62.5, 14, fill: '#fff') { raw status }
      end
    end
  end

  def to_s
    shield.to_s
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
svgshield-0.1.2 lib/svgshield.rb