svg_conform 0.2.1 → 0.2.2

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: 136c672fbb6005495a240d2d8b7f30000fae008cd16fff6bfe51a74e7dbe2262
4
- data.tar.gz: 679452859b709b2e9ef78916918ea9e58040ebfb382291b8c6543b9062a5ee09
3
+ metadata.gz: 7e8eb5ad65e9d19baccc8d9751bc57a188b24a59c46c6937489ca8dea3e70901
4
+ data.tar.gz: 8b4fe6936b5dfffc1546ca629a1ffc3dde72bc920fbebc5f4059a5508252f471
5
5
  SHA512:
6
- metadata.gz: 26a32728202834b61e892d78ef87bb6bae0030e768414985cfe0bfa208da9fa21828035fe6f247225c6cd37a299dff6fe91863c70137c528d7e24a9aade3250e
7
- data.tar.gz: 47b4ba1d348244438817269403a2b5b09019687024849e691ff6fe4dcbb9d4fed1a322f132758af38f8ba1310fb0666cc5d9dbaeef93192a8edaf19df66bb1c9
6
+ metadata.gz: 5e4862706e6ff92b9730d1362f7687090e9394800c1c95a0aac4f0ea0af428e3b25fafc3944e72a3d32312dcbb3b685a3df610bb3bb34cb85446228c38b9dc70
7
+ data.tar.gz: 30375296565ff91f64b2545ddfb9d9c7459be83b9a25794f773db1c11999ff217642811456eb5369f6cd6fee29d361b6dd74aa06438c08f6aa0bf5137f0a29fe
@@ -21,7 +21,10 @@ module SvgConform
21
21
  attribute :element_count, :integer, default: 0
22
22
  attribute :max_depth, :integer, default: 0
23
23
 
24
- after_initialize { freeze }
24
+ def initialize(**args)
25
+ super(args)
26
+ freeze
27
+ end
25
28
 
26
29
  # Value equality
27
30
  def ==(other)
@@ -30,7 +30,10 @@ module SvgConform
30
30
  attribute :non_remediable, :integer, default: 0
31
31
 
32
32
  # Ensure immutability after initialization
33
- after_initialize { freeze }
33
+ def initialize(**args)
34
+ super(args)
35
+ freeze
36
+ end
34
37
 
35
38
  # Value equality
36
39
  def ==(other)
@@ -23,7 +23,10 @@ module SvgConform
23
23
  attribute :has_clip_paths, :boolean, default: false
24
24
  attribute :has_external_refs, :boolean, default: false
25
25
 
26
- after_initialize { freeze }
26
+ def initialize(**args)
27
+ super(args)
28
+ freeze
29
+ end
27
30
 
28
31
  # Value equality
29
32
  def ==(other)
@@ -34,7 +34,10 @@ module SvgConform
34
34
  attribute :content_health, :symbol
35
35
  attribute :size_category, :symbol
36
36
 
37
- after_initialize { freeze }
37
+ def initialize(**args)
38
+ super(args)
39
+ freeze
40
+ end
38
41
 
39
42
  # Value equality
40
43
  def ==(other)
@@ -18,7 +18,10 @@ module SvgConform
18
18
 
19
19
  LEVELS = %i[excellent good fair poor critical].freeze
20
20
 
21
- after_initialize { freeze }
21
+ def initialize(**args)
22
+ super(args)
23
+ freeze
24
+ end
22
25
 
23
26
  # Value equality
24
27
  def ==(other)
@@ -82,7 +82,9 @@ module SvgConform
82
82
  # Array case
83
83
  attributes.each do |attr|
84
84
  if should_remove_moxml_attribute?(attr, node, removed_namespaces)
85
- attr_name = attr.respond_to?(:name) ? attr.name : attr.to_s
85
+ local_name = attr.respond_to?(:name) ? attr.name : attr.to_s
86
+ ns_prefix = attr.respond_to?(:namespace) && attr.namespace.respond_to?(:prefix) ? attr.namespace.prefix : nil
87
+ attr_name = ns_prefix && !ns_prefix.empty? ? "#{ns_prefix}:#{local_name}" : local_name
86
88
  attributes_to_remove << attr_name
87
89
  end
88
90
  end
@@ -59,7 +59,10 @@ module SvgConform
59
59
 
60
60
  node.attributes.each do |attr_name, attr_value|
61
61
  # Handle both string keys and Moxml::Attribute objects
62
- name_str = attr_name.respond_to?(:name) ? attr_name.name : attr_name.to_s
62
+ local_name = attr_name.respond_to?(:name) ? attr_name.name : attr_name.to_s
63
+ # Include namespace prefix for namespaced attributes (e.g. "custom:id")
64
+ ns_prefix = attr_name.respond_to?(:namespace) && attr_name.namespace.respond_to?(:prefix) ? attr_name.namespace.prefix : nil
65
+ name_str = ns_prefix && !ns_prefix.empty? ? "#{ns_prefix}:#{local_name}" : local_name
63
66
 
64
67
  # For root SVG element, remove xmlns declarations for disallowed namespaces
65
68
  if remove_declarations && node.name == "svg" && name_str.start_with?("xmlns:")
@@ -73,6 +73,11 @@ module SvgConform
73
73
  map "allow_rdf_metadata", to: :allow_rdf_metadata
74
74
  end
75
75
 
76
+ def initialize(**args)
77
+ super(args)
78
+ after_initialize
79
+ end
80
+
76
81
  def after_initialize
77
82
  build_element_config_index if element_configs&.any?
78
83
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SvgConform
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.2"
5
5
  end
@@ -34,7 +34,7 @@ RSpec.describe "IdReferenceRequirement" do
34
34
 
35
35
  # Verify first validation caught the error
36
36
  expect(result1.errors.map(&:message)).to include(
37
- match(/Reference to undefined ID 'missing_id'/),
37
+ include("Reference to undefined ID 'missing_id'"),
38
38
  )
39
39
 
40
40
  # Second validation: SVG without reference errors
@@ -68,7 +68,7 @@ RSpec.describe "IdReferenceRequirement" do
68
68
  if i.even?
69
69
  # Should have error (svg_with_error)
70
70
  expect(result.errors.map(&:message)).to include(
71
- match(/Reference to undefined ID 'missing_id'/),
71
+ include("Reference to undefined ID 'missing_id'"),
72
72
  )
73
73
  else
74
74
  # Should NOT have error about missing_id (svg_without_error)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svg_conform
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-04-11 00:00:00.000000000 Z
11
+ date: 2026-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lutaml-model