Learn how to use Canon through different interfaces.
1. Overview
Canon provides three main interfaces for different use cases:
- Ruby API
-
Integrate Canon into Ruby applications for programmatic formatting and comparison.
- Command-Line Interface
-
Use Canon from the terminal for one-off tasks and shell scripting.
- RSpec Matchers
-
Test XML, JSON, and YAML generation with semantic matchers.
2. Choosing an Interface
- Use Ruby API when
-
-
Integrating into a Ruby application
-
Need programmatic control
-
Building custom tooling
-
Processing multiple files
-
- Use CLI when
-
-
Running one-off comparisons
-
Shell scripting
-
CI/CD pipelines
-
Quick formatting tasks
-
- Use RSpec when
-
-
Writing tests
-
Validating generated output
-
TDD/BDD workflows
-
Continuous integration
-
3. Common Patterns Across Interfaces
All interfaces share the same core concepts:
-
Formats: XML, HTML, JSON, YAML
-
Operations: Format (canonicalize/pretty-print) and Compare
-
Options: Match dimensions, profiles, preprocessing
-
Output: Color-coded diffs, character visualization
The interface you choose determines how you invoke these features, but the underlying behavior is consistent.
5. Next Steps
-
Choose your primary interface and dive into its documentation
-
Review Match Options to understand configuration
-
Check Guides for task-oriented tutorials
6. See Also
-
Quick Start - Basic usage examples
-
Match Options - Customizing comparison behavior
-
Architecture - How Canon works internally