Class: Canon::Comparison::CompareProfile
- Inherits:
-
Object
- Object
- Canon::Comparison::CompareProfile
- Defined in:
- lib/canon/comparison/compare_profile.rb
Overview
CompareProfile encapsulates the policy decisions about how differences in various dimensions should be handled during comparison.
This class provides separation of concerns:
-
CompareProfile: Policy decisions (what to track, what affects equivalence)
-
Comparator: Comparison logic (detect differences)
-
DiffClassifier: Classification logic (normative vs informative vs formatting)
Direct Known Subclasses
Instance Attribute Summary collapse
-
#match_options ⇒ Object
readonly
Returns the value of attribute match_options.
Instance Method Summary collapse
-
#affects_equivalence?(dimension) ⇒ Boolean
Should differences in this dimension affect equivalence?.
-
#behavior_for(dimension) ⇒ Symbol
Get the behavior setting for a dimension.
-
#initialize(match_options) ⇒ CompareProfile
constructor
A new instance of CompareProfile.
-
#normative_dimension?(dimension) ⇒ Boolean
Is a difference in this dimension normative (affects equivalence)?.
-
#supports_formatting_detection?(dimension) ⇒ Boolean
Can a difference in this dimension be formatting-only?.
- #track_dimension?(_dimension) ⇒ Boolean
Constructor Details
#initialize(match_options) ⇒ CompareProfile
Returns a new instance of CompareProfile.
16 17 18 |
# File 'lib/canon/comparison/compare_profile.rb', line 16 def initialize() @match_options = end |
Instance Attribute Details
#match_options ⇒ Object (readonly)
Returns the value of attribute match_options.
13 14 15 |
# File 'lib/canon/comparison/compare_profile.rb', line 13 def @match_options end |
Instance Method Details
#affects_equivalence?(dimension) ⇒ Boolean
Should differences in this dimension affect equivalence?
28 29 30 31 |
# File 'lib/canon/comparison/compare_profile.rb', line 28 def affects_equivalence?(dimension) behavior = behavior_for(dimension) behavior != :ignore end |
#behavior_for(dimension) ⇒ Symbol
Get the behavior setting for a dimension
65 66 67 68 69 70 71 72 73 |
# File 'lib/canon/comparison/compare_profile.rb', line 65 def behavior_for(dimension) if .is_a?(ResolvedMatchOptions) .behavior_for(dimension) elsif .is_a?(Hash) [dimension] || :strict else :strict end end |
#normative_dimension?(dimension) ⇒ Boolean
Is a difference in this dimension normative (affects equivalence)?
Delegates to the Dimension object’s normative? rule. Falls back to the default rule (normative unless :ignore) for dimensions not in the format’s dimension set (e.g., derived dimensions like :element_structure).
41 42 43 44 45 46 47 48 |
# File 'lib/canon/comparison/compare_profile.rb', line 41 def normative_dimension?(dimension) dim = dimension_for(dimension) if dim dim.normative?(behavior_for(dimension)) else behavior_for(dimension) != :ignore end end |
#supports_formatting_detection?(dimension) ⇒ Boolean
Can a difference in this dimension be formatting-only?
Delegates to the Dimension object’s supports_formatting_detection? flag. Falls back to false for unknown dimensions.
57 58 59 60 |
# File 'lib/canon/comparison/compare_profile.rb', line 57 def supports_formatting_detection?(dimension) dim = dimension_for(dimension) dim ? dim.supports_formatting_detection? : false end |
#track_dimension?(_dimension) ⇒ Boolean
20 21 22 |
# File 'lib/canon/comparison/compare_profile.rb', line 20 def track_dimension?(_dimension) true end |