class CircleCIReporter::Report
Encapsulate a report created by a reporter.
Attributes
base_result[R]
current_result[R]
previous_result[R]
reporter[R]
Public Class Methods
new(reporter, current, base: nil, previous: nil)
click to toggle source
@param reporter [Reporters::Base] the reporter of the report @param current [Result] @param base [Result, nil] result at master branch @param previous [Result, nil] result at previous build in same branch
# File lib/circleci_reporter/report.rb, line 12 def initialize(reporter, current, base: nil, previous: nil) @reporter = reporter @current_result = current @base_result = base @previous_result = previous end
Public Instance Methods
to_s()
click to toggle source
@return [String]
# File lib/circleci_reporter/report.rb, line 20 def to_s "#{link}: #{current_result.pretty_coverage}#{emoji}#{progress}" end
Private Instance Methods
base_diff()
click to toggle source
@return [Float, nil]
# File lib/circleci_reporter/report.rb, line 79 def base_diff return unless base_result current_result.coverage - base_result.coverage end
base_progress()
click to toggle source
@return [String, nil]
# File lib/circleci_reporter/report.rb, line 55 def base_progress base_diff ? "[master](#{base_result.url}): #{pretty_base_diff}" : nil end
branch_diff()
click to toggle source
@return [Float, nil]
# File lib/circleci_reporter/report.rb, line 86 def branch_diff return unless previous_result current_result.coverage - previous_result.coverage end
branch_progress()
click to toggle source
@return [String, nil]
# File lib/circleci_reporter/report.rb, line 60 def branch_progress branch_diff ? "[previous](#{previous_result.url}): #{pretty_branch_diff}" : nil end
emoji()
click to toggle source
@return [String]
# File lib/circleci_reporter/report.rb, line 34 def emoji if base_diff.nil? || base_diff.nan? || base_diff.round(2).zero? '' elsif base_diff.positive? ':chart_with_upwards_trend:' else ':chart_with_downwards_trend:' end end
link()
click to toggle source
@return [String]
# File lib/circleci_reporter/report.rb, line 29 def link "[#{reporter.name}](#{current_result.url})" end
pretty_base_diff()
click to toggle source
@return [String, nil]
# File lib/circleci_reporter/report.rb, line 65 def pretty_base_diff return unless base_diff pretty_diff(base_diff.round(2)) end
pretty_branch_diff()
click to toggle source
@return [String, nil]
# File lib/circleci_reporter/report.rb, line 72 def pretty_branch_diff return unless branch_diff pretty_diff(branch_diff.round(2)) end
pretty_diff(diff)
click to toggle source
@param diff [Float] @return [String]
# File lib/circleci_reporter/report.rb, line 94 def pretty_diff(diff) if diff.nan? 'NaN' elsif diff.positive? "+#{diff}" elsif diff.negative? diff.to_s else '±0' end end
progress()
click to toggle source
@return [String]
# File lib/circleci_reporter/report.rb, line 45 def progress progresses.empty? ? '' : "(#{progresses.join(', ')})" end
progresses()
click to toggle source
@return [Array<String>]
# File lib/circleci_reporter/report.rb, line 50 def progresses [base_progress, branch_progress].compact end