Class: MutationTester::Reporters::BaseReporter
- Inherits:
-
Object
- Object
- MutationTester::Reporters::BaseReporter
- Defined in:
- lib/mutation_tester/reporters/base_reporter.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
-
#source_file ⇒ Object
readonly
Returns the value of attribute source_file.
-
#spec_file ⇒ Object
readonly
Returns the value of attribute spec_file.
Class Method Summary collapse
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(results, source_file, spec_file, config, interrupted: false) ⇒ BaseReporter
constructor
A new instance of BaseReporter.
- #interrupted? ⇒ Boolean
Constructor Details
#initialize(results, source_file, spec_file, config, interrupted: false) ⇒ BaseReporter
Returns a new instance of BaseReporter.
18 19 20 21 22 23 24 |
# File 'lib/mutation_tester/reporters/base_reporter.rb', line 18 def initialize(results, source_file, spec_file, config, interrupted: false) @results = results @source_file = source_file @spec_file = spec_file @config = config @interrupted = interrupted end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
4 5 6 |
# File 'lib/mutation_tester/reporters/base_reporter.rb', line 4 def config @config end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
4 5 6 |
# File 'lib/mutation_tester/reporters/base_reporter.rb', line 4 def results @results end |
#source_file ⇒ Object (readonly)
Returns the value of attribute source_file.
4 5 6 |
# File 'lib/mutation_tester/reporters/base_reporter.rb', line 4 def source_file @source_file end |
#spec_file ⇒ Object (readonly)
Returns the value of attribute spec_file.
4 5 6 |
# File 'lib/mutation_tester/reporters/base_reporter.rb', line 4 def spec_file @spec_file end |
Class Method Details
.score(results) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/mutation_tester/reporters/base_reporter.rb', line 6 def self.score(results) effective_killed = results.count { |r| %i[killed timeout].include?(status_for(r)) } scored = results.count { |r| %i[killed timeout survived].include?(status_for(r)) } return 0.0 if scored.zero? (effective_killed.to_f / scored * 100).round(2) end |
.status_for(result) ⇒ Object
14 15 16 |
# File 'lib/mutation_tester/reporters/base_reporter.rb', line 14 def self.status_for(result) result[:status] || (result[:killed] ? :killed : :survived) end |
Instance Method Details
#generate ⇒ Object
30 31 32 |
# File 'lib/mutation_tester/reporters/base_reporter.rb', line 30 def generate raise NotImplementedError, 'Subclasses must implement #generate' end |
#interrupted? ⇒ Boolean
26 27 28 |
# File 'lib/mutation_tester/reporters/base_reporter.rb', line 26 def interrupted? @interrupted end |