Module: Philiprehberger::TomlKit::Diff
- Defined in:
- lib/philiprehberger/toml_kit/diff.rb
Overview
Compares two TOML documents (as hashes) and reports differences.
Returns a structured diff with:
- :added -> keys present only in the right document
- :removed -> keys present only in the left document
- :changed -> keys present in both but with different values
Defined Under Namespace
Classes: Change
Class Method Summary collapse
-
.additions(left, right) ⇒ Array<Change>
Return only additions (keys in right but not left).
-
.changes(left, right) ⇒ Array<Change>
Return only changes (keys in both with different values).
-
.diff(left, right) ⇒ Array<Change>
Compare two parsed TOML hashes.
-
.identical?(left, right) ⇒ Boolean
Check if two documents are identical.
-
.removals(left, right) ⇒ Array<Change>
Return only removals (keys in left but not right).
Class Method Details
.additions(left, right) ⇒ Array<Change>
Return only additions (keys in right but not left).
31 32 33 |
# File 'lib/philiprehberger/toml_kit/diff.rb', line 31 def self.additions(left, right) diff(left, right).select { |c| c.type == :added } end |
.changes(left, right) ⇒ Array<Change>
Return only changes (keys in both with different values).
49 50 51 |
# File 'lib/philiprehberger/toml_kit/diff.rb', line 49 def self.changes(left, right) diff(left, right).select { |c| c.type == :changed } end |
.diff(left, right) ⇒ Array<Change>
Compare two parsed TOML hashes.
20 21 22 23 24 |
# File 'lib/philiprehberger/toml_kit/diff.rb', line 20 def self.diff(left, right) changes = [] compare(left, right, [], changes) changes end |
.identical?(left, right) ⇒ Boolean
Check if two documents are identical.
58 59 60 |
# File 'lib/philiprehberger/toml_kit/diff.rb', line 58 def self.identical?(left, right) diff(left, right).empty? end |
.removals(left, right) ⇒ Array<Change>
Return only removals (keys in left but not right).
40 41 42 |
# File 'lib/philiprehberger/toml_kit/diff.rb', line 40 def self.removals(left, right) diff(left, right).select { |c| c.type == :removed } end |