Module: Canon::Comparison::Dimensions::Registry
- Defined in:
- lib/canon/comparison/dimensions/registry.rb
Overview
Registry for comparison dimensions
Provides a central access point for all dimension classes and maps dimension symbols to their implementations.
Constant Summary collapse
- DIMENSION_CLASSES =
Dimension class mappings
{ text_content: TextContentDimension, comments: CommentsDimension, attribute_values: AttributeValuesDimension, attribute_presence: AttributePresenceDimension, attribute_order: AttributeOrderDimension, element_position: ElementPositionDimension, structural_whitespace: StructuralWhitespaceDimension, }.freeze
Class Method Summary collapse
-
.available_dimensions ⇒ Array<Symbol>
Get all available dimension names.
-
.compare(dimension_name, node1, node2, behavior) ⇒ Boolean
Compare two nodes for a specific dimension.
-
.dimension_exists?(dimension_name) ⇒ Boolean
Check if a dimension is available.
-
.get(dimension_name) ⇒ BaseDimension
Get a dimension instance by name.
Class Method Details
.available_dimensions ⇒ Array<Symbol>
Get all available dimension names
51 52 53 |
# File 'lib/canon/comparison/dimensions/registry.rb', line 51 def self.available_dimensions DIMENSION_CLASSES.keys end |
.compare(dimension_name, node1, node2, behavior) ⇒ Boolean
Compare two nodes for a specific dimension
70 71 72 73 |
# File 'lib/canon/comparison/dimensions/registry.rb', line 70 def self.compare(dimension_name, node1, node2, behavior) # rubocop:disable Naming/PredicateMethod dimension = get(dimension_name) dimension.equivalent?(node1, node2, behavior) end |
.dimension_exists?(dimension_name) ⇒ Boolean
Check if a dimension is available
59 60 61 |
# File 'lib/canon/comparison/dimensions/registry.rb', line 59 def self.dimension_exists?(dimension_name) DIMENSION_CLASSES.key?(dimension_name) end |
.get(dimension_name) ⇒ BaseDimension
Get a dimension instance by name
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/canon/comparison/dimensions/registry.rb', line 36 def self.get(dimension_name) dimension_class = DIMENSION_CLASSES[dimension_name] unless dimension_class raise Canon::Error, "Unknown dimension: #{dimension_name}. " \ "Valid dimensions: #{DIMENSION_CLASSES.keys.join(', ')}" end dimension_class.new end |