Class: Yaml::Merge::MergeResult
- Inherits:
-
Ast::Merge::MergeResultBase
- Object
- Ast::Merge::MergeResultBase
- Yaml::Merge::MergeResult
- Defined in:
- lib/yaml/merge/merge_result.rb
Constant Summary collapse
- DECISION_KEPT_TEMPLATE =
Ast::Merge::MergeResultBase::DECISION_KEPT_TEMPLATE
- DECISION_KEPT_DEST =
Ast::Merge::MergeResultBase::DECISION_KEPT_DEST
- DECISION_MERGED =
Ast::Merge::MergeResultBase::DECISION_MERGED
- DECISION_ADDED =
Ast::Merge::MergeResultBase::DECISION_ADDED
- DECISION_FREEZE_BLOCK =
Ast::Merge::MergeResultBase::DECISION_FREEZE_BLOCK
Instance Attribute Summary collapse
-
#statistics ⇒ Object
readonly
Returns the value of attribute statistics.
Instance Method Summary collapse
- #add_line(line, decision:, source:, original_line: nil) ⇒ Object
-
#initialize(**options) ⇒ MergeResult
constructor
A new instance of MergeResult.
- #line_count ⇒ Object
- #to_yaml ⇒ Object (also: #content, #to_s)
Constructor Details
#initialize(**options) ⇒ MergeResult
Returns a new instance of MergeResult.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/yaml/merge/merge_result.rb', line 14 def initialize(**) super(**) @statistics = { template_lines: 0, dest_lines: 0, merged_lines: 0, freeze_preserved_lines: 0, total_decisions: 0 } end |
Instance Attribute Details
#statistics ⇒ Object (readonly)
Returns the value of attribute statistics.
12 13 14 |
# File 'lib/yaml/merge/merge_result.rb', line 12 def statistics @statistics end |
Instance Method Details
#add_line(line, decision:, source:, original_line: nil) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/yaml/merge/merge_result.rb', line 25 def add_line(line, decision:, source:, original_line: nil) @lines << { content: line, decision: decision, source: source, original_line: original_line } track_statistics(decision) track_decision(decision, source, line: original_line) end |
#line_count ⇒ Object
45 46 47 |
# File 'lib/yaml/merge/merge_result.rb', line 45 def line_count @lines.size end |
#to_yaml ⇒ Object Also known as: content, to_s
36 37 38 39 40 |
# File 'lib/yaml/merge/merge_result.rb', line 36 def to_yaml content = @lines.map { |line| line[:content] }.join("\n") content += "\n" unless content.empty? || content.end_with?("\n") content end |