class SimpleCov::Formatter::ShieldFormatter
Constants
- SHIELD_ROOT
- STYLES
Public Class Methods
config()
click to toggle source
# File lib/simplecov-shield.rb, line 39 def self.config @config end
Public Instance Methods
coverage_percent()
click to toggle source
# File lib/simplecov-shield.rb, line 35 def coverage_percent @coverage_percent ||= @result.covered_percent.round(precision) end
format(result)
click to toggle source
# File lib/simplecov-shield.rb, line 17 def format(result) @result = result generate_shield end
generate_shield()
click to toggle source
# File lib/simplecov-shield.rb, line 22 def generate_shield File.open(shield_file_path, 'w') do |file| file.write HTTParty.get(shield_url).parsed_response end end
shield_url()
click to toggle source
# File lib/simplecov-shield.rb, line 28 def shield_url url = "#{SHIELD_ROOT}/#{badge_name}-#{coverage_percent}%-#{color}.svg" url += "?style=#{style}" if STYLES.include? style URI.encode(url) end
Private Instance Methods
color()
click to toggle source
# File lib/simplecov-shield.rb, line 48 def color case coverage_percent when 90..100 'brightgreen' when 80..89 'yellow' else 'red' end end
shield_file_path()
click to toggle source
# File lib/simplecov-shield.rb, line 44 def shield_file_path "#{SimpleCov.coverage_path}/coverage.svg" end