Table of Contents
1. Choose Your Interface
Canon provides three ways to work with document comparisons:
-
Ruby API - Using Canon from Ruby code
-
Command-line Interface - Terminal commands and options
-
RSpec Matchers - Testing with Canon in RSpec
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