Class: Canon::TreeDiff::Operations::OperationDetector
- Inherits:
-
Object
- Object
- Canon::TreeDiff::Operations::OperationDetector
- Defined in:
- lib/canon/tree_diff/operations/operation_detector.rb
Overview
OperationDetector analyzes tree matching results to detect high-level semantic operations.
Based on research from XDiff, XyDiff, and JATS-diff, this detector identifies operations in three levels:
Level 1: Basic operations (INSERT, DELETE, UPDATE) Level 2: Structural operations (MOVE) Level 3: Semantic operations (MERGE, SPLIT, UPGRADE, DOWNGRADE)
Instance Attribute Summary collapse
-
#match_options ⇒ Object
readonly
Returns the value of attribute match_options.
-
#matching ⇒ Object
readonly
Returns the value of attribute matching.
-
#operations ⇒ Object
readonly
Returns the value of attribute operations.
-
#tree1 ⇒ Object
readonly
Returns the value of attribute tree1.
-
#tree2 ⇒ Object
readonly
Returns the value of attribute tree2.
Instance Method Summary collapse
-
#detect ⇒ Array<Operation>
Detect all operations.
-
#initialize(tree1, tree2, matching, match_options = {}) ⇒ OperationDetector
constructor
Initialize a new operation detector.
Constructor Details
#initialize(tree1, tree2, matching, match_options = {}) ⇒ OperationDetector
Initialize a new operation detector
32 33 34 35 36 37 38 |
# File 'lib/canon/tree_diff/operations/operation_detector.rb', line 32 def initialize(tree1, tree2, matching, = {}) @tree1 = tree1 @tree2 = tree2 @matching = matching @match_options = || {} @operations = [] end |
Instance Attribute Details
#match_options ⇒ Object (readonly)
Returns the value of attribute match_options.
24 25 26 |
# File 'lib/canon/tree_diff/operations/operation_detector.rb', line 24 def @match_options end |
#matching ⇒ Object (readonly)
Returns the value of attribute matching.
24 25 26 |
# File 'lib/canon/tree_diff/operations/operation_detector.rb', line 24 def matching @matching end |
#operations ⇒ Object (readonly)
Returns the value of attribute operations.
24 25 26 |
# File 'lib/canon/tree_diff/operations/operation_detector.rb', line 24 def operations @operations end |
#tree1 ⇒ Object (readonly)
Returns the value of attribute tree1.
24 25 26 |
# File 'lib/canon/tree_diff/operations/operation_detector.rb', line 24 def tree1 @tree1 end |
#tree2 ⇒ Object (readonly)
Returns the value of attribute tree2.
24 25 26 |
# File 'lib/canon/tree_diff/operations/operation_detector.rb', line 24 def tree2 @tree2 end |
Instance Method Details
#detect ⇒ Array<Operation>
Detect all operations
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/canon/tree_diff/operations/operation_detector.rb', line 43 def detect @operations = [] # Level 1: Basic operations detect_inserts detect_deletes detect_updates # Level 2: Structural operations detect_moves # Level 3: Semantic operations # These require more sophisticated pattern analysis detect_merges detect_splits detect_upgrades detect_downgrades @operations end |