Class: Canon::Diff::DiffReportBuilder
- Inherits:
-
Object
- Object
- Canon::Diff::DiffReportBuilder
- Defined in:
- lib/canon/diff/diff_report_builder.rb
Overview
Builds a complete DiffReport from DiffLines Orchestrates the pipeline: DiffLines → DiffBlocks → DiffContexts → DiffReport
Class Method Summary collapse
-
.build(diff_lines, options = {}) ⇒ DiffReport
Build a diff report from diff lines.
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(diff_lines, options = {}) ⇒ DiffReportBuilder
constructor
A new instance of DiffReportBuilder.
Constructor Details
#initialize(diff_lines, options = {}) ⇒ DiffReportBuilder
Returns a new instance of DiffReportBuilder.
27 28 29 30 31 32 33 34 35 |
# File 'lib/canon/diff/diff_report_builder.rb', line 27 def initialize(diff_lines, = {}) @diff_lines = diff_lines @show_diffs = [:show_diffs] || :all @context_lines = [:context_lines] || 3 @grouping_lines = [:grouping_lines] @element_name = [:element_name] || "root" @file1_name = [:file1_name] @file2_name = [:file2_name] end |
Class Method Details
.build(diff_lines, options = {}) ⇒ DiffReport
Build a diff report from diff lines
23 24 25 |
# File 'lib/canon/diff/diff_report_builder.rb', line 23 def self.build(diff_lines, = {}) new(diff_lines, ).build end |
Instance Method Details
#build ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/canon/diff/diff_report_builder.rb', line 37 def build # Step 1: Build blocks from lines (with filtering) diff_blocks = DiffBlockBuilder.build_blocks( @diff_lines, show_diffs: @show_diffs, ) # Step 2: Build contexts from blocks diff_contexts = DiffContextBuilder.build_contexts( diff_blocks, @diff_lines, context_lines: @context_lines, grouping_lines: @grouping_lines, ) # Step 3: Wrap in DiffReport DiffReport.new( element_name: @element_name, file1_name: @file1_name, file2_name: @file2_name, contexts: diff_contexts, ) end |