Module: Canon::Comparison::BaseComparator
- Defined in:
- lib/canon/comparison/base_comparator.rb
Overview
Base module for comparators providing common patterns Each comparator should include this module and implement:
-
serialize_for_display(content, match_opts)
Instance Method Summary collapse
-
#build_verbose_result(differences, content1, content2, match_opts) ⇒ Hash
Build verbose result hash with preprocessed strings.
-
#serialize_for_display(content, match_opts) ⇒ String
Serialize content for display in diffs This method must be implemented by each comparator.
Instance Method Details
#build_verbose_result(differences, content1, content2, match_opts) ⇒ Hash
Build verbose result hash with preprocessed strings
16 17 18 19 20 21 22 23 24 |
# File 'lib/canon/comparison/base_comparator.rb', line 16 def build_verbose_result(differences, content1, content2, match_opts) { differences: differences, preprocessed: [ serialize_for_display(content1, match_opts), serialize_for_display(content2, match_opts), ], } end |
#serialize_for_display(content, match_opts) ⇒ String
Serialize content for display in diffs This method must be implemented by each comparator
33 34 35 36 |
# File 'lib/canon/comparison/base_comparator.rb', line 33 def serialize_for_display(content, match_opts) raise NotImplementedError, "#{self.class.name} must implement serialize_for_display" end |