Class: SimpleCov::Formatter::MaterialFormatter
- Inherits:
-
Object
- Object
- SimpleCov::Formatter::MaterialFormatter
- Defined in:
- lib/simplecov-material.rb,
lib/simplecov-material/version.rb
Overview
rubocop:disable Metrics/ClassLength
Constant Summary collapse
- VERSION =
"1.0.0"
Instance Method Summary collapse
- #branchable_result? ⇒ Boolean
-
#format(result) ⇒ Object
rubocop:disable Metrics/AbcSize.
-
#initialize ⇒ MaterialFormatter
constructor
A new instance of MaterialFormatter.
- #line_status?(source_file, line) ⇒ Boolean
- #output_message(result) ⇒ Object
Constructor Details
#initialize ⇒ MaterialFormatter
Returns a new instance of MaterialFormatter.
18 19 20 |
# File 'lib/simplecov-material.rb', line 18 def initialize @branchable_result = SimpleCov.branch_coverage? end |
Instance Method Details
#branchable_result? ⇒ Boolean
39 40 41 42 43 44 |
# File 'lib/simplecov-material.rb', line 39 def branchable_result? # cached in initialize because we truly look it up a whole bunch of times # and it's easier to cache here then in SimpleCov because there we might # still enable/disable branch coverage criterion @branchable_result end |
#format(result) ⇒ Object
rubocop:disable Metrics/AbcSize
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/simplecov-material.rb', line 22 def format(result) # rubocop:disable Metrics/AbcSize Dir[File.join(File.dirname(__FILE__), "../public/*")].each do |path| FileUtils.cp_r(path, asset_output_path) end File.open(File.join(output_path, "index.html"), "wb") do |file| file.puts template("main").result(binding) end puts (result) end |
#line_status?(source_file, line) ⇒ Boolean
46 47 48 49 50 51 52 |
# File 'lib/simplecov-material.rb', line 46 def line_status?(source_file, line) if branchable_result? && source_file.line_with_missed_branch?(line.number) "missed-branch" else line.status end end |
#output_message(result) ⇒ Object
33 34 35 36 37 |
# File 'lib/simplecov-material.rb', line 33 def (result) "Coverage report generated for #{result.command_name} to " \ "#{output_path}. #{result.covered_lines} / #{result.total_lines} LOC" \ " (#{result.covered_percent.round(2)}%) covered." end |