1. Choose Your Interface

Canon provides three ways to work with document comparisons:

2. Quick Examples

2.1. Ruby API

require 'canon'

# Compare two XML files
result = Canon.compare(
  File.read('expected.xml'),
  File.read('actual.xml'),
  format: :xml
)

puts result ? "✅ Equivalent" : "❌ Different"

2.2. Command Line

# Compare two files (shows diff if they differ)
canon diff expected.xml actual.xml

# With detailed configuration info
canon diff expected.xml actual.xml --verbose

# With advanced options
canon diff expected.xml actual.xml \
  --diff-algorithm semantic \
  --match-profile strict \
  --verbose

2.3. RSpec

RSpec.describe "My XML" do
  it "matches expected output" do
    expect(actual_xml).to match_xml(expected_xml)
  end
end