Class: SnapDiff::Reporters::Default
- Inherits:
-
Object
- Object
- SnapDiff::Reporters::Default
- Defined in:
- lib/snap_diff/reporters/default.rb
Constant Summary collapse
- NEW_LINE =
"\n"- THRESHOLDS =
The thresholds a comparison is judged against, in the order they read best. Only the ones actually set are printed -- see #thresholds.
[ :tolerance, :area_size_limit, :color_distance_limit, :shift_distance_limit, :perceptual_threshold ].freeze
- ARTIFACT_LABELS =
The five artifacts a comparison can leave on disk, in the order a reader wants them: the two inputs first, then what we drew on them.
{ "baseline" => :base_image_path, "actual" => :image_path, "baseline annotated" => :annotated_base_image_path, "actual annotated" => :annotated_image_path, "heatmap" => :heatmap_diff_path }.freeze
Instance Attribute Summary collapse
-
#difference ⇒ Object
readonly
Returns the value of attribute difference.
Instance Method Summary collapse
- #annotate_and_save_images ⇒ Object
- #annotated_base_image_path ⇒ Object
- #annotated_image_path ⇒ Object
- #build_error_for_different_dimensions ⇒ Object
- #build_error_message ⇒ Object
- #clean_tmp_files ⇒ Object
- #generate ⇒ Object
- #heatmap_diff_path ⇒ Object
-
#initialize(difference) ⇒ Default
constructor
A new instance of Default.
Constructor Details
#initialize(difference) ⇒ Default
Returns a new instance of Default.
14 15 16 17 |
# File 'lib/snap_diff/reporters/default.rb', line 14 def initialize(difference) @difference = difference @annotation_service = SnapDiff::AnnotationService.new(difference) end |
Instance Attribute Details
#difference ⇒ Object (readonly)
Returns the value of attribute difference.
12 13 14 |
# File 'lib/snap_diff/reporters/default.rb', line 12 def difference @difference end |
Instance Method Details
#annotate_and_save_images ⇒ Object
50 51 52 |
# File 'lib/snap_diff/reporters/default.rb', line 50 def annotate_and_save_images annotation_service.annotate_and_save_images end |
#annotated_base_image_path ⇒ Object
23 24 25 |
# File 'lib/snap_diff/reporters/default.rb', line 23 def annotated_base_image_path annotation_service.annotated_base_image_path end |
#annotated_image_path ⇒ Object
19 20 21 |
# File 'lib/snap_diff/reporters/default.rb', line 19 def annotated_image_path annotation_service.annotated_image_path end |
#build_error_for_different_dimensions ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/snap_diff/reporters/default.rb', line 54 def build_error_for_different_dimensions change_msg = [comparison.base_image, comparison.new_image] .map { |image| driver.dimension(image).join("x") } .join(" => ") "Dimensions have changed: #{change_msg}\n#{base_image_path.to_path}\n#{image_path.to_path}" end |
#build_error_message ⇒ Object
84 85 86 |
# File 'lib/snap_diff/reporters/default.rb', line 84 def [headline, *metric_lines, *artifact_lines].join(NEW_LINE) end |
#clean_tmp_files ⇒ Object
46 47 48 |
# File 'lib/snap_diff/reporters/default.rb', line 46 def clean_tmp_files annotation_service.clean_tmp_files end |
#generate ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/snap_diff/reporters/default.rb', line 31 def generate if difference.equal? # NOTE: Delete previous run runtime files clean_tmp_files return nil end if difference.failed? && difference.failed_by[:different_dimensions] return build_error_for_different_dimensions end annotate_and_save_images end |
#heatmap_diff_path ⇒ Object
27 28 29 |
# File 'lib/snap_diff/reporters/default.rb', line 27 def heatmap_diff_path annotation_service.heatmap_diff_path end |