Class: SimpleCov::Formatter::ShieldFormatter::Generators::Png

Inherits:
Svg
  • Object
show all
Defined in:
lib/simplecov-formatter-shield/generators/png.rb

Constant Summary

Constants inherited from Svg

Svg::CHAR_WIDTH, Svg::COLOR_MAP, Svg::PADDING

Instance Method Summary collapse

Methods inherited from Svg

#generate, #initialize, #inspect

Constructor Details

This class inherits a constructor from SimpleCov::Formatter::ShieldFormatter::Generators::Svg

Instance Method Details

#svg2png(svg) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/simplecov-formatter-shield/generators/png.rb', line 15

def svg2png(svg)
  image = MiniMagick::Image.create('.svg') do |tmpfile|
    tmpfile.write(svg)
  end

  image.format('png') do |converter|
    converter.resize "#{widths.reduce(&:+)}x20"
    converter.background 'transparent'
    converter.alpha 'on'
  end

  return image.to_blob
end