Class: RSpec::Covers::Evaluation
- Inherits:
-
Object
- Object
- RSpec::Covers::Evaluation
- Defined in:
- lib/rspec/covers/evaluation.rb
Class Method Summary collapse
Instance Method Summary collapse
- #evaluate ⇒ Object
-
#initialize(ground_truth:, predictions:) ⇒ Evaluation
constructor
A new instance of Evaluation.
Constructor Details
#initialize(ground_truth:, predictions:) ⇒ Evaluation
Returns a new instance of Evaluation.
16 17 18 19 20 |
# File 'lib/rspec/covers/evaluation.rb', line 16 def initialize(ground_truth:, predictions:) @targets = ground_truth.fetch("targets", {}) @ground_truth = normalize_ground_truth(ground_truth) @predictions = normalize_predictions(predictions) end |
Class Method Details
.evaluate(ground_truth_path:, predictions_path:) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/rspec/covers/evaluation.rb', line 9 def self.evaluate(ground_truth_path:, predictions_path:) new( ground_truth: JSON.parse(File.read(ground_truth_path)), predictions: JSON.parse(File.read(predictions_path)) ).evaluate end |
Instance Method Details
#evaluate ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rspec/covers/evaluation.rb', line 22 def evaluate result = { traceability: traceability_metrics, examples: @ground_truth.length } strict = strict_metrics seeded = seeded_strict_metrics checked = checked_metrics result[:strict] = strict if strict result[:seeded_strict] = seeded if seeded result[:checked] = checked if checked result[:targets] = target_metrics(result) if @targets.any? result end |