Class: Psych::Merge::DiffMapper
- Inherits:
-
Ast::Merge::DiffMapperBase
- Object
- Ast::Merge::DiffMapperBase
- Psych::Merge::DiffMapper
- Defined in:
- lib/psych/merge/diff_mapper.rb
Overview
Maps unified git diffs to YAML AST paths.
DiffMapper parses unified diffs and maps changed lines to their
corresponding YAML key paths (e.g., [“AllCops”, “Exclude”]).
Instance Method Summary collapse
-
#create_analysis(content) ⇒ FileAnalysis
Create a FileAnalysis for the original YAML content.
-
#map_hunk_to_paths(hunk, original_analysis) ⇒ Array<DiffMapping>
Map a diff hunk to YAML key paths.
Instance Method Details
#create_analysis(content) ⇒ FileAnalysis
Create a FileAnalysis for the original YAML content.
25 26 27 |
# File 'lib/psych/merge/diff_mapper.rb', line 25 def create_analysis(content) FileAnalysis.new(content) end |
#map_hunk_to_paths(hunk, original_analysis) ⇒ Array<DiffMapping>
Map a diff hunk to YAML key paths.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/psych/merge/diff_mapper.rb', line 34 def map_hunk_to_paths(hunk, original_analysis) mappings = [] # Group consecutive changed lines by their containing node path_groups = group_lines_by_path(hunk, original_analysis) path_groups.each do |path, lines| mappings << DiffMapping.new( path: path, operation: determine_operation_for_lines(lines), lines: lines, hunk: hunk, ) end mappings end |