canon 0.3.120 → 0.3.121

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 38a359346723b741f1bc368f5bb563f816a6cce60645fd4329c6a615175492d9
4
- data.tar.gz: f02379429df3da9c8ad8835eeba4ccafb423d4b00e7a0b65ba6dac8acc488aa6
3
+ metadata.gz: ea0a5d94e934c12df80540761d13587ddf9adabad10db384f7bfad3b640affbf
4
+ data.tar.gz: 27ad206ee9f2fc7bb0c37b09948716ee46bb42fbaa2894b813feb90246823343
5
5
  SHA512:
6
- metadata.gz: 90794b21762de80ba03846c814a5980da475d156efbb63b6248e76956967408988341145abbec476f253f8113524c87367c343366a875d0eb50008b5b48497f7
7
- data.tar.gz: f26fdd27f3f203dc0da8a612bb421889fee7c2d1823a2c6ccb29aad10dc0dca8876906c7438739296d1db6baac6111a1363ae9f7f0e8a131e42adbe2c06958c4
6
+ metadata.gz: 961d3fda5a67a3219e7fad26f5d90cf52ad691e7e625d8f831d29d29cd81593147617cef7dbe17073ecf7d1ad279af0ea941f2d20a88652857e90f373bd6bdec
7
+ data.tar.gz: 99f8e9910736ee42355ccd4a7350d9ba56ed819eb1a2530ed326dd2cc2524b4ddcb50ad7a3e87972279d962637ab2b04d65f79afcfb8b99562ad4697a1e01325
@@ -637,6 +637,15 @@ module Canon
637
637
  resolved = opts.dup
638
638
  format_hint = resolved[:format]
639
639
 
640
+ # Arrays have no document format of their own: suites extract
641
+ # value lists (attributes, anchors) or node lists and compare
642
+ # them as arrays. Element-wise, order-sensitive, each element
643
+ # recursing through the normal pipeline (strings short-circuit,
644
+ # nodes take their own format path).
645
+ if obj1.is_a?(Array) && obj2.is_a?(Array)
646
+ return array_diff(obj1, obj2, resolved)
647
+ end
648
+
640
649
  # Detect formats (with explicit hint) and pre-parse HTML strings
641
650
  # through Nokogiri::HTML5 so html4 and html5 share HTML's
642
651
  # whitespace-sensitivity semantics (issue #118). Pre-parsing
@@ -690,6 +699,33 @@ module Canon
690
699
  # @param format1 [Symbol]
691
700
  # @param format2 [Symbol]
692
701
  # @return [Symbol]
702
+ def array_diff(arr1, arr2, opts = {})
703
+ verbose = opts[:verbose]
704
+ if arr1.size != arr2.size
705
+ return verbose ? [:size_mismatch] : false
706
+ end
707
+
708
+ # Elements are extracted values, not documents: strings compare
709
+ # literally (a matcher format hint must not turn "ref1" into an
710
+ # XML fragment, where every bare string parses equal), and the
711
+ # format hint is dropped for the recursion on other scalars.
712
+ scalar_opts = opts.except(:verbose, :format)
713
+ diffs = []
714
+ arr1.zip(arr2).each_with_index do |(a, b), i|
715
+ eq = if a.is_a?(String) && b.is_a?(String)
716
+ a == b
717
+ else
718
+ equivalent?(a, b, scalar_opts)
719
+ end
720
+ next if eq == true
721
+
722
+ return false unless verbose
723
+
724
+ diffs << { index: i, difference: eq == false ? :different : eq }
725
+ end
726
+ verbose ? diffs : diffs.empty?
727
+ end
728
+
693
729
  def normalize_comparison_format(format1, format2)
694
730
  return format2 if format1 == :ruby_object &&
695
731
  %i[json yaml].include?(format2)
data/lib/canon/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Canon
4
- VERSION = "0.3.120"
4
+ VERSION = "0.3.121"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.120
4
+ version: 0.3.121
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-11-02 00:00:00.000000000 Z
11
+ date: 2026-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: diff-lcs