Module: Minitest::Cc
- Defined in:
- lib/minitest/cc.rb,
lib/minitest/cc/version.rb,
lib/minitest/cc/reporter.rb,
lib/minitest/cc/file_array.rb,
lib/minitest/cc/file_coverage.rb
Overview
Main module of the plugin
Defined Under Namespace
Classes: FileArray, FileCoverage, Reporter
Constant Summary collapse
- MODES =
%i[lines branches methods].freeze
- VERSION =
plugin version
'1.0.0'
Class Method Summary collapse
-
.cattr_accessor(name) ⇒ Object
:nodoc:.
-
.peek_result ⇒ Object
This method populate the FileArray variable with results.
-
.result_for_file(file_path) ⇒ Hash?
Find the result for a file with the full path if the file was not tracked by Coverage this will return nil.
-
.resume ⇒ String
compose the string with resume of cc.
-
.start(*args) ⇒ Object
start coverage process this method recive the arguments direct and not depend on set coverage mode before start.
-
.start_coverage ⇒ Object
deprecated
Deprecated.
Use #self#self.start(*args) instead.
-
.summary ⇒ Object
Print results after the runs.
Instance Method Summary collapse
-
#cc_mode ⇒ Symbol
Mode of the summary.
-
#coverage_mode ⇒ Array
Mode of the coverage, this array could contain: :lines, :branches, :methods.
-
#tracked_files ⇒ Array
Pattern to find files that must be cover by the tests.
Class Method Details
.cattr_accessor(name) ⇒ Object
:nodoc:
20 21 22 |
# File 'lib/minitest/cc.rb', line 20 def self.cattr_accessor(name) # :nodoc: (class << self; self; end).attr_accessor name end |
.peek_result ⇒ Object
This method populate the FileArray variable with results
77 78 79 80 81 82 83 |
# File 'lib/minitest/cc.rb', line 77 def peek_result @results = Coverage.result Dir.glob(tracked_files.each { |f| File.(f) }).each do |d| full_path = File.(d) @files << FileCoverage.new(full_path, d, result_for_file(full_path)) end end |
.result_for_file(file_path) ⇒ Hash?
Find the result for a file with the full path if the file was not tracked by Coverage this will return nil
90 91 92 93 94 |
# File 'lib/minitest/cc.rb', line 90 def result_for_file(file_path) return if @results.empty? @results[file_path] end |
.resume ⇒ String
compose the string with resume of cc
99 100 101 102 103 104 105 |
# File 'lib/minitest/cc.rb', line 99 def resume str = '' str += "Lines: #{@files.lines_average.round(2).to_s_color}%\t" if coverage_mode.include? :lines str += "Branches: #{@files.branches_average.round(2).to_s_color}%\t" if coverage_mode.include? :branches str += "Methods: #{@files.methods_average.round(2).to_s_color}%\t" if coverage_mode.include? :methods str end |
.start(*args) ⇒ Object
start coverage process this method recive the arguments direct and not depend on set coverage mode before start
56 57 58 59 |
# File 'lib/minitest/cc.rb', line 56 def start(*args) @coverage_mode = args.collect(&:to_sym).select { |a| MODES.include? a } unless args.empty? Coverage.start(@coverage_mode.collect { |m| [m, true] }.to_h) end |
.start_coverage ⇒ Object
Use Minitest::Cc#self#self.start(*args) instead.
Start the coverage process
46 47 48 |
# File 'lib/minitest/cc.rb', line 46 def start_coverage Coverage.start(@coverage_mode.collect { |m| [m, true] }.to_h) end |
.summary ⇒ Object
Print results after the runs
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/minitest/cc.rb', line 64 def summary puts "\n\n# Coverage:\n\n" case cc_mode when :per_file @files.each { |f| puts f.to_s } else puts resume end puts "\nAverage: #{@files.total_coverage_percent.round(2).to_s_color}%" end |
Instance Method Details
#cc_mode ⇒ Symbol
Returns mode of the summary. Could be :resume or :per_file.
25 |
# File 'lib/minitest/cc.rb', line 25 cattr_accessor :cc_mode |
#coverage_mode ⇒ Array
Returns mode of the coverage, this array could contain: :lines, :branches, :methods.
37 |
# File 'lib/minitest/cc.rb', line 37 cattr_accessor :coverage_mode |
#tracked_files ⇒ Array
Returns pattern to find files that must be cover by the tests.
29 |
# File 'lib/minitest/cc.rb', line 29 cattr_accessor :tracked_files |