Class: SimpleCovSmallBadge::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/simplecov_small_badge/formatter.rb

Overview

Basic Badge Formater Class that creates the badges.

Instance Method Summary collapse

Constructor Details

#initialize(output = nil) ⇒ Formatter

Returns a new instance of Formatter.



9
10
11
12
# File 'lib/simplecov_small_badge/formatter.rb', line 9

def initialize(output = nil)
  @output = output || $stdout
  @config = SimpleCovSmallBadge.config
end

Instance Method Details

#format(result) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/simplecov_small_badge/formatter.rb', line 14

def format(result)
  percent = result.source_files.covered_percent.round(0)
  @image = RepoSmallBadge::Image.new(map_image_config(state(percent)))
  badge('total', 'total', percent)
  group_percent_from_result(result) do |name, title, cov_percent|
    badge(name, title, cov_percent.round(0))
  end
end