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.
20 21 22 23 24 25 26 |
# File 'lib/mutation_tester/reporters/base_reporter.rb', line 20 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, policy: :killed) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/mutation_tester/reporters/base_reporter.rb', line 6 def self.score(results, policy: :killed) killing_statuses = policy == :separate ? %i[killed] : %i[killed timeout] scoring_statuses = killing_statuses + %i[survived] kills = results.count { |r| killing_statuses.include?(status_for(r)) } scored = results.count { |r| scoring_statuses.include?(status_for(r)) } return 0.0 if scored.zero? (kills.to_f / scored * 100).round(2) end |
.status_for(result) ⇒ Object
16 17 18 |
# File 'lib/mutation_tester/reporters/base_reporter.rb', line 16 def self.status_for(result) result[:status] || (result[:killed] ? :killed : :survived) end |
Instance Method Details
#generate ⇒ Object
32 33 34 |
# File 'lib/mutation_tester/reporters/base_reporter.rb', line 32 def generate raise NotImplementedError, 'Subclasses must implement #generate' end |
#interrupted? ⇒ Boolean
28 29 30 |
# File 'lib/mutation_tester/reporters/base_reporter.rb', line 28 def interrupted? @interrupted end |