Class: Canon::Comparison::Strategies::MatchStrategyFactory
- Inherits:
-
Object
- Object
- Canon::Comparison::Strategies::MatchStrategyFactory
- Defined in:
- lib/canon/comparison/strategies/match_strategy_factory.rb
Overview
Factory for creating match strategies
Selects the appropriate match strategy based on match options. This provides a single point for strategy instantiation and enables easy extension with new matching algorithms.
Class Method Summary collapse
-
.create(format:, match_options:) ⇒ BaseMatchStrategy
Create appropriate match strategy.
Class Method Details
.create(format:, match_options:) ⇒ BaseMatchStrategy
Create appropriate match strategy
Examines match options to determine which strategy to use:
-
If semantic_diff is enabled: SemanticTreeMatchStrategy
-
Otherwise (default): DomMatchStrategy
Future strategies can be added here by checking additional options and returning the appropriate strategy class.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/canon/comparison/strategies/match_strategy_factory.rb', line 50 def self.create(format:, match_options:) # Check for semantic diff option if [:semantic_diff] require_relative "semantic_tree_match_strategy" SemanticTreeMatchStrategy.new(format: format, match_options: ) else # Default to DOM matching require_relative "dom_match_strategy" DomMatchStrategy.new(format: format, match_options: ) end # Future: Add more strategies here # Example: # elsif match_options[:hybrid_diff] # require_relative "hybrid_match_strategy" # HybridMatchStrategy.new(format, match_options) # elsif match_options[:fuzzy_diff] # require_relative "fuzzy_match_strategy" # FuzzyMatchStrategy.new(format, match_options) end |