Class: CoverMe::Processor
- Inherits:
-
Object
- Object
- CoverMe::Processor
- Defined in:
- lib/cover_me/processor.rb
Overview
Processes the coverage results and then formats them.
Instance Attribute Summary collapse
-
#coverage_results ⇒ Object
Returns the value of attribute coverage_results.
-
#index ⇒ Object
Returns the value of attribute index.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(coverage_results, options = {}) ⇒ Processor
constructor
:nodoc:.
-
#process! ⇒ Object
Processes the coverage results and then formats them.
Constructor Details
#initialize(coverage_results, options = {}) ⇒ Processor
:nodoc:
8 9 10 11 12 13 14 15 16 |
# File 'lib/cover_me/processor.rb', line 8 def initialize(coverage_results, = {}) # :nodoc: self.coverage_results = coverage_results self. = ({:patterns => CoverMe.config.file_pattern, :exclude_patterns => CoverMe.config.exclude_file_patterns, :formatter => CoverMe.config.formatter.new}.merge()).to_mash self.index = CoverMe::Index.new self.[:patterns] = [self.[:patterns]].flatten self.[:exclude_patterns] = [self.[:exclude_patterns]].flatten end |
Instance Attribute Details
#coverage_results ⇒ Object
Returns the value of attribute coverage_results.
4 5 6 |
# File 'lib/cover_me/processor.rb', line 4 def coverage_results @coverage_results end |
#index ⇒ Object
Returns the value of attribute index.
6 7 8 |
# File 'lib/cover_me/processor.rb', line 6 def index @index end |
#options ⇒ Object
Returns the value of attribute options.
5 6 7 |
# File 'lib/cover_me/processor.rb', line 5 def @options end |
Instance Method Details
#process! ⇒ Object
Processes the coverage results and then formats them. Coverage is only reported if the file matches the pattern defined in the configuration. See the README for more details.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/cover_me/processor.rb', line 22 def process! self.coverage_results.map do |filename, coverage| # next unless filename.match(/#{CoverMe.config.project.root}/) exclude = false self.[:exclude_patterns].each do |pattern| if filename.match(pattern) exclude = true break end end next if exclude self.[:patterns].each do |pattern| if filename.match(pattern) report = CoverMe::Report.new(filename, coverage) if report.exists? self.index.reports << report self.[:formatter].format(report) end break end end end self.[:formatter].format(self.index) self.[:formatter].finalize end |