Class: Markdown::Merge::MergeResult
- Inherits:
-
Ast::Merge::MergeResultBase
- Object
- Ast::Merge::MergeResultBase
- Markdown::Merge::MergeResult
- Defined in:
- lib/markdown/merge/merge_result.rb
Overview
Represents the result of a Markdown merge operation.
Inherits from Ast::Merge::MergeResultBase to provide consistent result
handling across all merge gems. Contains the merged content along
with metadata about conflicts, frozen sections, and changes made.
Instance Attribute Summary collapse
-
#problems ⇒ DocumentProblems
readonly
Problems found during merge.
Instance Method Summary collapse
-
#conflicts? ⇒ Boolean
Check if there are unresolved conflicts.
-
#content ⇒ String?
Get the merged content as a string.
-
#content? ⇒ Boolean
Check if content has been set (not nil).
-
#content_string ⇒ String?
Get content as a string (alias for content in this class).
-
#frozen_count ⇒ Integer
Get count of frozen blocks preserved.
-
#has_frozen_blocks? ⇒ Boolean
Check if any frozen blocks were preserved.
-
#initialize(content:, conflicts: [], frozen_blocks: [], stats: {}, problems: nil, **options) ⇒ MergeResult
constructor
Initialize a new MergeResult.
-
#inspect ⇒ String
String representation for debugging.
-
#merge_time_ms ⇒ Float?
Get merge duration in milliseconds.
-
#nodes_added ⇒ Integer
Get count of nodes added during merge.
-
#nodes_modified ⇒ Integer
Get count of nodes modified during merge.
-
#nodes_removed ⇒ Integer
Get count of nodes removed during merge.
-
#success? ⇒ Boolean
Check if merge was successful (no unresolved conflicts).
-
#to_s ⇒ String
Convert to string (returns merged content).
Constructor Details
#initialize(content:, conflicts: [], frozen_blocks: [], stats: {}, problems: nil, **options) ⇒ MergeResult
Initialize a new MergeResult
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/markdown/merge/merge_result.rb', line 45 def initialize(content:, conflicts: [], frozen_blocks: [], stats: {}, problems: nil, **) super( conflicts: conflicts, frozen_blocks: frozen_blocks, stats: default_stats.merge(stats), ** ) @content_raw = content @problems = problems || DocumentProblems.new end |
Instance Attribute Details
#problems ⇒ DocumentProblems (readonly)
Returns Problems found during merge.
35 36 37 |
# File 'lib/markdown/merge/merge_result.rb', line 35 def problems @problems end |
Instance Method Details
#conflicts? ⇒ Boolean
Check if there are unresolved conflicts
89 90 91 |
# File 'lib/markdown/merge/merge_result.rb', line 89 def conflicts? !conflicts.empty? end |
#content ⇒ String?
Get the merged content as a string.
Overrides base class to return string content directly.
60 61 62 |
# File 'lib/markdown/merge/merge_result.rb', line 60 def content @content_raw end |
#content? ⇒ Boolean
Check if content has been set (not nil).
Overrides base class for string-based content.
68 69 70 |
# File 'lib/markdown/merge/merge_result.rb', line 68 def content? !@content_raw.nil? end |
#content_string ⇒ String?
Get content as a string (alias for content in this class).
75 76 77 |
# File 'lib/markdown/merge/merge_result.rb', line 75 def content_string @content_raw end |
#frozen_count ⇒ Integer
Get count of frozen blocks preserved
131 132 133 |
# File 'lib/markdown/merge/merge_result.rb', line 131 def frozen_count frozen_blocks.size end |
#has_frozen_blocks? ⇒ Boolean
Check if any frozen blocks were preserved
96 97 98 |
# File 'lib/markdown/merge/merge_result.rb', line 96 def has_frozen_blocks? !frozen_blocks.empty? end |
#inspect ⇒ String
String representation for debugging
138 139 140 141 142 |
# File 'lib/markdown/merge/merge_result.rb', line 138 def inspect status = success? ? "success" : "failed" "#<#{self.class.name} #{status} conflicts=#{conflicts.size} frozen=#{frozen_blocks.size} " \ "added=#{nodes_added} removed=#{nodes_removed} modified=#{nodes_modified}>" end |
#merge_time_ms ⇒ Float?
Get merge duration in milliseconds
124 125 126 |
# File 'lib/markdown/merge/merge_result.rb', line 124 def merge_time_ms stats[:merge_time_ms] end |
#nodes_added ⇒ Integer
Get count of nodes added during merge
103 104 105 |
# File 'lib/markdown/merge/merge_result.rb', line 103 def nodes_added stats[:nodes_added] || 0 end |
#nodes_modified ⇒ Integer
Get count of nodes modified during merge
117 118 119 |
# File 'lib/markdown/merge/merge_result.rb', line 117 def nodes_modified stats[:nodes_modified] || 0 end |
#nodes_removed ⇒ Integer
Get count of nodes removed during merge
110 111 112 |
# File 'lib/markdown/merge/merge_result.rb', line 110 def nodes_removed stats[:nodes_removed] || 0 end |
#success? ⇒ Boolean
Check if merge was successful (no unresolved conflicts)
82 83 84 |
# File 'lib/markdown/merge/merge_result.rb', line 82 def success? conflicts.empty? && content? end |
#to_s ⇒ String
Convert to string (returns merged content)
147 148 149 |
# File 'lib/markdown/merge/merge_result.rb', line 147 def to_s content || "" end |