Class: Pinspec::Validate::PinScorer::Report
- Inherits:
-
Data
- Object
- Data
- Pinspec::Validate::PinScorer::Report
- Defined in:
- lib/pinspec/validate/pin_scorer.rb
Instance Attribute Summary collapse
-
#scores ⇒ Object
readonly
Returns the value of attribute scores.
-
#skipped ⇒ Object
readonly
Returns the value of attribute skipped.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
Instance Method Summary collapse
- #covered_by_another_aspect ⇒ Object
- #mutant_key(survivor) ⇒ Object
- #scored ⇒ Object
- #strong_ratio ⇒ Object
- #surviving_all_aspects ⇒ Object
Instance Attribute Details
#scores ⇒ Object (readonly)
Returns the value of attribute scores
20 21 22 |
# File 'lib/pinspec/validate/pin_scorer.rb', line 20 def scores @scores end |
#skipped ⇒ Object (readonly)
Returns the value of attribute skipped
20 21 22 |
# File 'lib/pinspec/validate/pin_scorer.rb', line 20 def skipped @skipped end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject
20 21 22 |
# File 'lib/pinspec/validate/pin_scorer.rb', line 20 def subject @subject end |
Instance Method Details
#covered_by_another_aspect ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/pinspec/validate/pin_scorer.rb', line 39 def covered_by_another_aspect all = scored.flat_map(&:survivors) gaps = surviving_all_aspects.map { |s| mutant_key(s) } all.reject { |s| gaps.include?(mutant_key(s)) } .uniq { |s| mutant_key(s) } end |
#mutant_key(survivor) ⇒ Object
47 48 49 |
# File 'lib/pinspec/validate/pin_scorer.rb', line 47 def mutant_key(survivor) [survivor["operator"], survivor["line"], survivor["token"]].join(":") end |
#scored ⇒ Object
21 22 23 |
# File 'lib/pinspec/validate/pin_scorer.rb', line 21 def scored scores.reject { |score| score.score.nil? } end |
#strong_ratio ⇒ Object
25 26 27 28 29 |
# File 'lib/pinspec/validate/pin_scorer.rb', line 25 def strong_ratio return 0.0 if scored.empty? (scored.count(&:strong?).to_f / scored.size * 100).round(1) end |
#surviving_all_aspects ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/pinspec/validate/pin_scorer.rb', line 31 def surviving_all_aspects sets = scored.map { |score| score.survivors.map { |s| mutant_key(s) } } return [] if sets.empty? || sets.any?(&:empty?) shared = sets.reduce(:&) scored.first.survivors.select { |s| shared.include?(mutant_key(s)) } end |