canon 0.1.9 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +25 -99
- data/README.adoc +220 -26
- data/docs/advanced/diff-classification.adoc +118 -26
- data/lib/canon/cli.rb +30 -0
- data/lib/canon/commands/diff_command.rb +3 -0
- data/lib/canon/comparison/markup_comparator.rb +109 -2
- data/lib/canon/comparison/xml_comparator/diff_node_builder.rb +108 -0
- data/lib/canon/comparison/xml_comparator.rb +192 -0
- data/lib/canon/config/env_schema.rb +5 -1
- data/lib/canon/config.rb +30 -0
- data/lib/canon/diff/diff_classifier.rb +48 -33
- data/lib/canon/diff/xml_serialization_formatter.rb +153 -0
- data/lib/canon/diff_formatter.rb +102 -12
- data/lib/canon/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e123b3a909e4ca7309ed6815282fd03c86e4514fa325d82f1e8973f1428ce83a
|
|
4
|
+
data.tar.gz: '09e45b9a9f5e8721f4df5b41465b199d0a34824640745321f35cd7edd6d65a91'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c027b7abd237f7b0f3dc679c3b919c11dea6d02f8636aaca9ac95ba56c2d9e321ed3dc23691c33274fa1403f7147b0547011adebb4cb70f1073875cac557a394
|
|
7
|
+
data.tar.gz: 75aea03c181390b0f927c5d7ba979a8ed6a5ab807e9ab40fa281257e3d165fa001e62fa7ad9bfff3c1d007e1d8157aa49c7218cb2a99bb07919efb1b7da6b120
|
data/.rubocop_todo.yml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# This configuration was generated by
|
|
2
2
|
# `rubocop --auto-gen-config`
|
|
3
|
-
# on 2026-01-
|
|
3
|
+
# on 2026-01-21 06:10:55 UTC using RuboCop version 1.81.7.
|
|
4
4
|
# The point is for the user to remove these configuration records
|
|
5
5
|
# one by one as the offenses are removed from the code base.
|
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
|
@@ -12,70 +12,29 @@ Gemspec/RequiredRubyVersion:
|
|
|
12
12
|
Exclude:
|
|
13
13
|
- 'canon.gemspec'
|
|
14
14
|
|
|
15
|
-
# Offense count: 2
|
|
16
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
17
|
-
# Configuration parameters: EnforcedStyleAlignWith.
|
|
18
|
-
# SupportedStylesAlignWith: either, start_of_block, start_of_line
|
|
19
|
-
Layout/BlockAlignment:
|
|
20
|
-
Exclude:
|
|
21
|
-
- 'spec/canon/rspec_matchers_spec.rb'
|
|
22
|
-
|
|
23
|
-
# Offense count: 2
|
|
24
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
25
|
-
Layout/BlockEndNewline:
|
|
26
|
-
Exclude:
|
|
27
|
-
- 'spec/canon/rspec_matchers_spec.rb'
|
|
28
|
-
|
|
29
|
-
# Offense count: 2
|
|
30
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
31
|
-
# Configuration parameters: AllowForAlignment.
|
|
32
|
-
Layout/CommentIndentation:
|
|
33
|
-
Exclude:
|
|
34
|
-
- 'lib/canon/comparison/xml_comparator.rb'
|
|
35
|
-
|
|
36
|
-
# Offense count: 1
|
|
37
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
38
|
-
Layout/ElseAlignment:
|
|
39
|
-
Exclude:
|
|
40
|
-
- 'lib/canon/comparison/xml_comparator.rb'
|
|
41
|
-
|
|
42
|
-
# Offense count: 1
|
|
43
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
44
|
-
# Configuration parameters: EnforcedStyleAlignWith, Severity.
|
|
45
|
-
# SupportedStylesAlignWith: keyword, variable, start_of_line
|
|
46
|
-
Layout/EndAlignment:
|
|
47
|
-
Exclude:
|
|
48
|
-
- 'lib/canon/comparison/xml_comparator.rb'
|
|
49
|
-
|
|
50
|
-
# Offense count: 1
|
|
51
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
52
|
-
# Configuration parameters: EnforcedStyle.
|
|
53
|
-
# SupportedStyles: normal, indented_internal_methods
|
|
54
|
-
Layout/IndentationConsistency:
|
|
55
|
-
Exclude:
|
|
56
|
-
- 'lib/canon/comparison/xml_comparator.rb'
|
|
57
|
-
|
|
58
15
|
# Offense count: 4
|
|
59
16
|
# This cop supports safe autocorrection (--autocorrect).
|
|
60
|
-
# Configuration parameters:
|
|
61
|
-
|
|
17
|
+
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
|
18
|
+
# SupportedStyles: with_first_argument, with_fixed_indentation
|
|
19
|
+
Layout/ArgumentAlignment:
|
|
62
20
|
Exclude:
|
|
63
|
-
- '
|
|
21
|
+
- 'lib/canon/diff_formatter.rb'
|
|
22
|
+
- 'spec/canon/diff_formatter_spec.rb'
|
|
64
23
|
|
|
65
|
-
# Offense count:
|
|
24
|
+
# Offense count: 705
|
|
66
25
|
# This cop supports safe autocorrection (--autocorrect).
|
|
67
26
|
# Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
|
|
68
27
|
# URISchemes: http, https
|
|
69
28
|
Layout/LineLength:
|
|
70
29
|
Enabled: false
|
|
71
30
|
|
|
72
|
-
# Offense count:
|
|
31
|
+
# Offense count: 5
|
|
73
32
|
# This cop supports safe autocorrection (--autocorrect).
|
|
74
|
-
# Configuration parameters:
|
|
75
|
-
|
|
76
|
-
Layout/MultilineOperationIndentation:
|
|
33
|
+
# Configuration parameters: AllowInHeredoc.
|
|
34
|
+
Layout/TrailingWhitespace:
|
|
77
35
|
Exclude:
|
|
78
|
-
- 'lib/canon/
|
|
36
|
+
- 'lib/canon/diff_formatter.rb'
|
|
37
|
+
- 'spec/canon/diff_formatter_spec.rb'
|
|
79
38
|
|
|
80
39
|
# Offense count: 48
|
|
81
40
|
# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches, IgnoreDuplicateElseBranch.
|
|
@@ -117,7 +76,7 @@ Lint/UnusedMethodArgument:
|
|
|
117
76
|
- 'lib/canon/diff_formatter/by_line/xml_formatter.rb'
|
|
118
77
|
- 'lib/canon/diff_formatter/by_object/base_formatter.rb'
|
|
119
78
|
|
|
120
|
-
# Offense count:
|
|
79
|
+
# Offense count: 209
|
|
121
80
|
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
|
|
122
81
|
Metrics/AbcSize:
|
|
123
82
|
Enabled: false
|
|
@@ -128,22 +87,22 @@ Metrics/AbcSize:
|
|
|
128
87
|
Metrics/BlockLength:
|
|
129
88
|
Max: 84
|
|
130
89
|
|
|
131
|
-
# Offense count:
|
|
90
|
+
# Offense count: 176
|
|
132
91
|
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
|
|
133
92
|
Metrics/CyclomaticComplexity:
|
|
134
93
|
Enabled: false
|
|
135
94
|
|
|
136
|
-
# Offense count:
|
|
95
|
+
# Offense count: 362
|
|
137
96
|
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
|
138
97
|
Metrics/MethodLength:
|
|
139
98
|
Max: 110
|
|
140
99
|
|
|
141
|
-
# Offense count:
|
|
100
|
+
# Offense count: 44
|
|
142
101
|
# Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
|
|
143
102
|
Metrics/ParameterLists:
|
|
144
103
|
Max: 9
|
|
145
104
|
|
|
146
|
-
# Offense count:
|
|
105
|
+
# Offense count: 142
|
|
147
106
|
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
|
|
148
107
|
Metrics/PerceivedComplexity:
|
|
149
108
|
Enabled: false
|
|
@@ -167,13 +126,15 @@ Naming/PredicatePrefix:
|
|
|
167
126
|
Exclude:
|
|
168
127
|
- 'lib/canon/comparison/html_comparator.rb'
|
|
169
128
|
|
|
170
|
-
# Offense count:
|
|
129
|
+
# Offense count: 6
|
|
171
130
|
# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
|
|
172
131
|
# SupportedStyles: snake_case, normalcase, non_integer
|
|
173
132
|
# AllowedIdentifiers: TLS1_1, TLS1_2, capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64
|
|
174
133
|
Naming/VariableNumber:
|
|
175
134
|
Exclude:
|
|
176
135
|
- 'lib/canon/comparison/json_comparator.rb'
|
|
136
|
+
- 'lib/canon/comparison/markup_comparator.rb'
|
|
137
|
+
- 'lib/canon/comparison/xml_comparator/diff_node_builder.rb'
|
|
177
138
|
|
|
178
139
|
# Offense count: 2
|
|
179
140
|
# Configuration parameters: MinSize.
|
|
@@ -199,7 +160,7 @@ RSpec/DescribeMethod:
|
|
|
199
160
|
- 'spec/canon/comparison/multiple_differences_spec.rb'
|
|
200
161
|
- 'spec/canon/diff_formatter/character_map_customization_spec.rb'
|
|
201
162
|
|
|
202
|
-
# Offense count:
|
|
163
|
+
# Offense count: 679
|
|
203
164
|
# Configuration parameters: CountAsOne.
|
|
204
165
|
RSpec/ExampleLength:
|
|
205
166
|
Max: 67
|
|
@@ -250,7 +211,7 @@ RSpec/MultipleDescribes:
|
|
|
250
211
|
Exclude:
|
|
251
212
|
- 'spec/canon/comparison/match_options_spec.rb'
|
|
252
213
|
|
|
253
|
-
# Offense count:
|
|
214
|
+
# Offense count: 522
|
|
254
215
|
RSpec/MultipleExpectations:
|
|
255
216
|
Max: 15
|
|
256
217
|
|
|
@@ -296,26 +257,16 @@ RSpec/SpecFilePathFormat:
|
|
|
296
257
|
- 'spec/canon/yaml/formatter_spec.rb'
|
|
297
258
|
- 'spec/xml_c14n_spec.rb'
|
|
298
259
|
|
|
299
|
-
# Offense count:
|
|
260
|
+
# Offense count: 120
|
|
300
261
|
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
|
|
301
262
|
RSpec/VerifiedDoubles:
|
|
302
263
|
Exclude:
|
|
303
264
|
- 'spec/canon/comparison/whitespace_sensitivity_spec.rb'
|
|
304
265
|
- 'spec/canon/diff/diff_classifier_spec.rb'
|
|
305
266
|
- 'spec/canon/diff/path_builder_spec.rb'
|
|
267
|
+
- 'spec/canon/diff/xml_serialization_formatter_spec.rb'
|
|
306
268
|
- 'spec/canon/tree_diff/operation_converter_spec.rb'
|
|
307
269
|
|
|
308
|
-
# Offense count: 3
|
|
309
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
310
|
-
# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
|
|
311
|
-
# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
|
|
312
|
-
# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
|
|
313
|
-
# FunctionalMethods: let, let!, subject, watch
|
|
314
|
-
# AllowedMethods: lambda, proc, it
|
|
315
|
-
Style/BlockDelimiters:
|
|
316
|
-
Exclude:
|
|
317
|
-
- 'spec/canon/rspec_matchers_spec.rb'
|
|
318
|
-
|
|
319
270
|
# Offense count: 1
|
|
320
271
|
# This cop supports safe autocorrection (--autocorrect).
|
|
321
272
|
# Configuration parameters: EnforcedStyle, AllowComments.
|
|
@@ -331,11 +282,10 @@ Style/HashLikeCase:
|
|
|
331
282
|
- 'lib/canon/diff/diff_block_builder.rb'
|
|
332
283
|
- 'lib/canon/xml/character_encoder.rb'
|
|
333
284
|
|
|
334
|
-
# Offense count:
|
|
285
|
+
# Offense count: 4
|
|
335
286
|
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
336
287
|
Style/IdenticalConditionalBranches:
|
|
337
288
|
Exclude:
|
|
338
|
-
- 'lib/canon/comparison/xml_comparator.rb'
|
|
339
289
|
- 'lib/canon/diff_formatter/by_object/base_formatter.rb'
|
|
340
290
|
- 'lib/canon/diff_formatter/legend.rb'
|
|
341
291
|
|
|
@@ -345,27 +295,3 @@ Style/IdenticalConditionalBranches:
|
|
|
345
295
|
Style/OptionalBooleanParameter:
|
|
346
296
|
Exclude:
|
|
347
297
|
- 'lib/canon/diff_formatter/debug_output.rb'
|
|
348
|
-
|
|
349
|
-
# Offense count: 6
|
|
350
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
351
|
-
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
|
|
352
|
-
# SupportedStyles: single_quotes, double_quotes
|
|
353
|
-
Style/StringLiterals:
|
|
354
|
-
Exclude:
|
|
355
|
-
- 'spec/canon/rspec_matchers_spec.rb'
|
|
356
|
-
|
|
357
|
-
# Offense count: 5
|
|
358
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
359
|
-
# Configuration parameters: EnforcedStyleForMultiline.
|
|
360
|
-
# SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma
|
|
361
|
-
Style/TrailingCommaInArguments:
|
|
362
|
-
Exclude:
|
|
363
|
-
- 'spec/canon/rspec_matchers_spec.rb'
|
|
364
|
-
|
|
365
|
-
# Offense count: 3
|
|
366
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
367
|
-
# Configuration parameters: EnforcedStyleForMultiline.
|
|
368
|
-
# SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma
|
|
369
|
-
Style/TrailingCommaInHashLiteral:
|
|
370
|
-
Exclude:
|
|
371
|
-
- 'spec/canon/rspec_matchers_spec.rb'
|
data/README.adoc
CHANGED
|
@@ -224,68 +224,262 @@ expect(actual).to be_xml_equivalent_to(expected)
|
|
|
224
224
|
.show_diffs(:normative)
|
|
225
225
|
----
|
|
226
226
|
|
|
227
|
-
===
|
|
227
|
+
=== Input display options
|
|
228
228
|
|
|
229
|
-
When debugging test failures, it's often helpful to see the exact
|
|
230
|
-
|
|
231
|
-
`verbose_diff` option displays the original input strings in an RSpec-style
|
|
232
|
-
format with line numbers.
|
|
229
|
+
When debugging test failures, it's often helpful to see the exact inputs that were
|
|
230
|
+
passed to the comparison. Canon provides four input display options:
|
|
233
231
|
|
|
232
|
+
`show_raw_inputs`:: Show raw/original file contents (before preprocessing)
|
|
233
|
+
|
|
234
|
+
`show_preprocessed_inputs`:: Show what was actually compared (after preprocessing)
|
|
235
|
+
|
|
236
|
+
`show_line_numbered_inputs`:: Show raw inputs with line numbers (for reference)
|
|
237
|
+
|
|
238
|
+
`verbose_diff`:: Convenience flag that enables all three options above
|
|
239
|
+
|
|
240
|
+
You can enable any combination of them independently.
|
|
241
|
+
|
|
242
|
+
==== Show raw inputs
|
|
243
|
+
|
|
244
|
+
Display the raw file contents before any preprocessing. This shows exactly what's
|
|
245
|
+
in your files, useful for copying to specs.
|
|
246
|
+
|
|
247
|
+
**Ruby API:**
|
|
234
248
|
[source,ruby]
|
|
235
249
|
----
|
|
236
|
-
# Enable
|
|
250
|
+
# Enable raw input display in configuration
|
|
237
251
|
Canon::Config.configure do |config|
|
|
238
|
-
config.xml.diff.
|
|
252
|
+
config.xml.diff.show_raw_inputs = true
|
|
239
253
|
end
|
|
240
254
|
|
|
241
255
|
# Or programmatically for a specific comparison
|
|
242
256
|
result = Canon::Comparison.equivalent?(xml1, xml2,
|
|
243
257
|
verbose: true,
|
|
244
|
-
|
|
258
|
+
show_raw_inputs: true
|
|
245
259
|
)
|
|
246
260
|
----
|
|
247
261
|
|
|
262
|
+
**CLI usage:**
|
|
263
|
+
[source,bash]
|
|
264
|
+
----
|
|
265
|
+
# Show raw file contents (for copying to specs)
|
|
266
|
+
$ canon diff file1.xml file2.xml --show-raw-inputs
|
|
267
|
+
|
|
268
|
+
# Show both raw and preprocessed (full trace)
|
|
269
|
+
$ canon diff file1.xml file2.xml --show-raw-inputs --show-preprocessed-inputs
|
|
270
|
+
----
|
|
271
|
+
|
|
272
|
+
**Environment variables:**
|
|
273
|
+
[source,bash]
|
|
274
|
+
----
|
|
275
|
+
# Global (all formats)
|
|
276
|
+
export CANON_SHOW_RAW_INPUTS=true
|
|
277
|
+
|
|
278
|
+
# Format-specific
|
|
279
|
+
export CANON_XML_SHOW_RAW_INPUTS=true
|
|
280
|
+
export CANON_HTML_SHOW_RAW_INPUTS=true
|
|
281
|
+
export CANON_JSON_SHOW_RAW_INPUTS=true
|
|
282
|
+
export CANON_YAML_SHOW_RAW_INPUTS=true
|
|
283
|
+
----
|
|
284
|
+
|
|
248
285
|
**Output format:**
|
|
249
286
|
----
|
|
250
|
-
|
|
251
|
-
ORIGINAL INPUT STRINGS
|
|
252
|
-
==================================================================
|
|
287
|
+
=== ORIGINAL INPUTS (Raw) ===
|
|
253
288
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
289
|
+
EXPECTED:
|
|
290
|
+
----------------------------------------------------------------------
|
|
291
|
+
<root> hello
|
|
292
|
+
world</root>
|
|
293
|
+
|
|
294
|
+
RECEIVED:
|
|
295
|
+
----------------------------------------------------------------------
|
|
296
|
+
<root>hello world</root>
|
|
297
|
+
|
|
298
|
+
----
|
|
299
|
+
|
|
300
|
+
==== Show preprocessed inputs
|
|
301
|
+
|
|
302
|
+
Display the content after preprocessing (c14n, normalize, format, etc.).
|
|
303
|
+
This shows what the comparison actually compared, useful for understanding
|
|
304
|
+
how preprocessing affects your content.
|
|
305
|
+
|
|
306
|
+
**Ruby API:**
|
|
307
|
+
[source,ruby]
|
|
308
|
+
----
|
|
309
|
+
# Enable preprocessed input display in configuration
|
|
310
|
+
Canon::Config.configure do |config|
|
|
311
|
+
config.xml.diff.show_preprocessed_inputs = true
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
# Or programmatically for a specific comparison
|
|
315
|
+
result = Canon::Comparison.equivalent?(xml1, xml2,
|
|
316
|
+
verbose: true,
|
|
317
|
+
show_preprocessed_inputs: true
|
|
318
|
+
)
|
|
319
|
+
----
|
|
320
|
+
|
|
321
|
+
**CLI usage:**
|
|
322
|
+
[source,bash]
|
|
323
|
+
----
|
|
324
|
+
# Show what was actually compared
|
|
325
|
+
$ canon diff file1.xml file2.xml --show-preprocessed-inputs
|
|
326
|
+
|
|
327
|
+
# Preprocess with normalization and show what was compared
|
|
328
|
+
$ canon diff file1.xml file2.xml --preprocessing normalize --show-preprocessed-inputs
|
|
329
|
+
----
|
|
330
|
+
|
|
331
|
+
**Environment variables:**
|
|
332
|
+
[source,bash]
|
|
333
|
+
----
|
|
334
|
+
# Global (all formats)
|
|
335
|
+
export CANON_SHOW_PROCESSED_INPUTS=true
|
|
336
|
+
|
|
337
|
+
# Format-specific
|
|
338
|
+
export CANON_XML_SHOW_PROCESSED_INPUTS=true
|
|
339
|
+
export CANON_HTML_SHOW_PROCESSED_INPUTS=true
|
|
340
|
+
export CANON_JSON_SHOW_PROCESSED_INPUTS=true
|
|
341
|
+
export CANON_YAML_SHOW_PROCESSED_INPUTS=true
|
|
342
|
+
----
|
|
343
|
+
|
|
344
|
+
**Output format:**
|
|
345
|
+
----
|
|
346
|
+
=== PREPROCESSED INPUTS (Compared) ===
|
|
347
|
+
Preprocessing: normalize
|
|
348
|
+
|
|
349
|
+
EXPECTED:
|
|
350
|
+
----------------------------------------------------------------------
|
|
351
|
+
<root> hello world </root>
|
|
352
|
+
|
|
353
|
+
RECEIVED:
|
|
354
|
+
----------------------------------------------------------------------
|
|
355
|
+
<root>hello world</root>
|
|
258
356
|
|
|
259
|
-
|
|
357
|
+
----
|
|
358
|
+
|
|
359
|
+
==== Show line-numbered inputs
|
|
360
|
+
|
|
361
|
+
Display raw inputs with line numbers (RSpec-style format). Useful for
|
|
362
|
+
pinpointing specific lines when debugging.
|
|
363
|
+
|
|
364
|
+
**Ruby API:**
|
|
365
|
+
[source,ruby]
|
|
366
|
+
----
|
|
367
|
+
# Enable line-numbered input display in configuration
|
|
368
|
+
Canon::Config.configure do |config|
|
|
369
|
+
config.xml.diff.show_line_numbered_inputs = true
|
|
370
|
+
end
|
|
371
|
+
|
|
372
|
+
# Or programmatically for a specific comparison
|
|
373
|
+
result = Canon::Comparison.equivalent?(xml1, xml2,
|
|
374
|
+
verbose: true,
|
|
375
|
+
show_line_numbered_inputs: true
|
|
376
|
+
)
|
|
377
|
+
----
|
|
378
|
+
|
|
379
|
+
**CLI usage:**
|
|
380
|
+
[source,bash]
|
|
381
|
+
----
|
|
382
|
+
# Show raw inputs with line numbers (RSpec-style)
|
|
383
|
+
$ canon diff file1.xml file2.xml --show-line-numbered-inputs
|
|
384
|
+
----
|
|
385
|
+
|
|
386
|
+
**Environment variables:**
|
|
387
|
+
[source,bash]
|
|
388
|
+
----
|
|
389
|
+
# Global (all formats)
|
|
390
|
+
export CANON_SHOW_LINE_NUMBERED_INPUTS=true
|
|
391
|
+
|
|
392
|
+
# Format-specific
|
|
393
|
+
export CANON_XML_SHOW_LINE_NUMBERED_INPUTS=true
|
|
394
|
+
export CANON_HTML_SHOW_LINE_NUMBERED_INPUTS=true
|
|
395
|
+
export CANON_JSON_SHOW_LINE_NUMBERED_INPUTS=true
|
|
396
|
+
export CANON_YAML_SHOW_LINE_NUMBERED_INPUTS=true
|
|
397
|
+
----
|
|
398
|
+
|
|
399
|
+
**Output format:**
|
|
400
|
+
----
|
|
401
|
+
======================================================================
|
|
402
|
+
ORIGINAL INPUTS (with line numbers)
|
|
403
|
+
======================================================================
|
|
404
|
+
|
|
405
|
+
Expected:
|
|
260
406
|
1 | <root>
|
|
261
|
-
2 |
|
|
407
|
+
2 | hello
|
|
262
408
|
3 | </root>
|
|
263
409
|
|
|
264
|
-
|
|
410
|
+
Received:
|
|
411
|
+
1 | <root>hello world</root>
|
|
412
|
+
|
|
413
|
+
======================================================================
|
|
265
414
|
----
|
|
266
415
|
|
|
267
|
-
|
|
416
|
+
==== Verbose diff (all input displays)
|
|
268
417
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
418
|
+
The `verbose_diff` option is a convenience flag that enables all three input
|
|
419
|
+
display options at once. This is useful for maximum debugging output.
|
|
420
|
+
|
|
421
|
+
**Ruby API:**
|
|
422
|
+
[source,ruby]
|
|
423
|
+
----
|
|
424
|
+
# Enable all input displays in configuration
|
|
425
|
+
Canon::Config.configure do |config|
|
|
426
|
+
config.xml.diff.verbose_diff = true
|
|
427
|
+
end
|
|
273
428
|
|
|
274
|
-
|
|
429
|
+
# Or programmatically for a specific comparison
|
|
430
|
+
result = Canon::Comparison.equivalent?(xml1, xml2,
|
|
431
|
+
verbose: true,
|
|
432
|
+
verbose_diff: true
|
|
433
|
+
)
|
|
434
|
+
----
|
|
435
|
+
|
|
436
|
+
**CLI usage:**
|
|
437
|
+
[source,bash]
|
|
438
|
+
----
|
|
439
|
+
# Show all three input displays
|
|
440
|
+
$ canon diff file1.xml file2.xml --verbose
|
|
441
|
+
----
|
|
442
|
+
|
|
443
|
+
**Environment variables:**
|
|
275
444
|
[source,bash]
|
|
276
445
|
----
|
|
446
|
+
# Format-specific
|
|
277
447
|
export CANON_XML_DIFF_VERBOSE_DIFF=true
|
|
278
448
|
export CANON_HTML_DIFF_VERBOSE_DIFF=true
|
|
279
449
|
export CANON_JSON_DIFF_VERBOSE_DIFF=true
|
|
280
450
|
export CANON_YAML_DIFF_VERBOSE_DIFF=true
|
|
281
451
|
----
|
|
282
452
|
|
|
453
|
+
==== When to use each option
|
|
454
|
+
|
|
455
|
+
`show_raw_inputs`::
|
|
456
|
+
** You want to copy the expected output to paste into your test specs
|
|
457
|
+
** You need to see the exact formatting/structure of your input files
|
|
458
|
+
** You're debugging file reading/parsing issues
|
|
459
|
+
|
|
460
|
+
`show_preprocessed_inputs`::
|
|
461
|
+
** You want to understand what the comparison actually compared
|
|
462
|
+
** You're debugging why two documents are considered equivalent (or not)
|
|
463
|
+
** You need to trace the effect of preprocessing (c14n, normalize, format)
|
|
464
|
+
|
|
465
|
+
`show_line_numbered_inputs`::
|
|
466
|
+
** You need line numbers for pinpointing specific lines
|
|
467
|
+
** You prefer the RSpec-style format
|
|
468
|
+
** You're collaborating on debugging with others
|
|
469
|
+
|
|
470
|
+
`verbose_diff`::
|
|
471
|
+
** You want maximum debugging output (all three displays at once)
|
|
472
|
+
** You're doing initial investigation of a complex comparison issue
|
|
473
|
+
|
|
283
474
|
=== Algorithm choice
|
|
284
475
|
|
|
285
476
|
Canon provides two diff algorithms:
|
|
286
477
|
|
|
287
|
-
|
|
288
|
-
|
|
478
|
+
DOM diff (default):: Stable, position-based comparison for traditional
|
|
479
|
+
line-by-line output
|
|
480
|
+
|
|
481
|
+
Semantic tree diff (experimental):: Advanced operation detection (INSERT,
|
|
482
|
+
DELETE, UPDATE, MOVE, MERGE, SPLIT, UPGRADE, DOWNGRADE)
|
|
289
483
|
|
|
290
484
|
[source,ruby]
|
|
291
485
|
----
|