class SimpleCov::Formatter::ShieldFormatter::Generators::Svg

Constants

CHAR_WIDTH
COLOR_MAP
PADDING

Public Class Methods

new(options) click to toggle source
# File lib/simplecov-formatter-shield/generators/svg.rb, line 21
def initialize(options)
  @options = options
  @template = ERB.new(File.read(File.expand_path('../svg/template.svg.erb', __FILE__)))
  @image = nil
end

Public Instance Methods

generate() click to toggle source
# File lib/simplecov-formatter-shield/generators/svg.rb, line 27
def generate
  return @image ||= begin
    generate!
  end
end
inspect() click to toggle source
# File lib/simplecov-formatter-shield/generators/svg.rb, line 33
def inspect
  return "#{self.class.name}: options => <#{@options}>"
end

Protected Instance Methods

colors() click to toggle source
# File lib/simplecov-formatter-shield/generators/svg.rb, line 56
def colors
  return @colors ||= COLOR_MAP[@options.color]
end
texts() click to toggle source
# File lib/simplecov-formatter-shield/generators/svg.rb, line 46
def texts
  return @texts ||= [@options.text, @options.status]
end
widths() click to toggle source
# File lib/simplecov-formatter-shield/generators/svg.rb, line 51
def widths
  return @widths ||= texts.map { |str| (str.length * CHAR_WIDTH).ceil + PADDING + 1 }
end

Private Instance Methods

generate!() click to toggle source
# File lib/simplecov-formatter-shield/generators/svg.rb, line 37
def generate!
  texts = self.texts
  widths = self.widths
  colors = self.colors

  return @template.result(binding)
end