svg_conform 0.1.6 → 0.1.8
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 +79 -13
- data/Gemfile +2 -2
- data/docs/sax_validation_mode.adoc +576 -0
- data/lib/svg_conform/document.rb +25 -1
- data/lib/svg_conform/document_analyzer.rb +118 -0
- data/lib/svg_conform/errors/base.rb +58 -0
- data/lib/svg_conform/errors/validation_issue.rb +245 -0
- data/lib/svg_conform/errors/validation_notice.rb +30 -0
- data/lib/svg_conform/interfaces/requirement_interface.rb +177 -0
- data/lib/svg_conform/node_helpers.rb +72 -0
- data/lib/svg_conform/remediations/base_remediation.rb +5 -35
- data/lib/svg_conform/remediations/namespace_remediation.rb +61 -0
- data/lib/svg_conform/requirements/base_requirement.rb +21 -41
- data/lib/svg_conform/requirements/color_restrictions_requirement.rb +19 -61
- data/lib/svg_conform/requirements/font_family_requirement.rb +14 -24
- data/lib/svg_conform/requirements/no_external_css_requirement.rb +19 -77
- data/lib/svg_conform/requirements/viewbox_required_requirement.rb +16 -72
- data/lib/svg_conform/sax_validation_handler.rb +15 -7
- data/lib/svg_conform/validation/error_tracker.rb +103 -0
- data/lib/svg_conform/validation/node_id_manager.rb +35 -0
- data/lib/svg_conform/validation/structural_invalidity_tracker.rb +63 -0
- data/lib/svg_conform/validation_context.rb +112 -459
- data/lib/svg_conform/validation_issue.rb +12 -0
- data/lib/svg_conform/version.rb +1 -1
- data/lib/svg_conform.rb +2 -0
- metadata +13 -3
- data/lib/svg_conform/fast_document_analyzer.rb +0 -82
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.1.
|
|
4
|
+
version: 0.1.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-01-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: lutaml-model
|
|
@@ -105,6 +105,7 @@ files:
|
|
|
105
105
|
- docs/reference_manifest.adoc
|
|
106
106
|
- docs/remediation.adoc
|
|
107
107
|
- docs/requirements.adoc
|
|
108
|
+
- docs/sax_validation_mode.adoc
|
|
108
109
|
- examples/demo.rb
|
|
109
110
|
- examples/document_input_demo.rb
|
|
110
111
|
- examples/readme_usage.rb
|
|
@@ -133,7 +134,11 @@ files:
|
|
|
133
134
|
- lib/svg_conform/constants.rb
|
|
134
135
|
- lib/svg_conform/css_color.rb
|
|
135
136
|
- lib/svg_conform/document.rb
|
|
137
|
+
- lib/svg_conform/document_analyzer.rb
|
|
136
138
|
- lib/svg_conform/element_proxy.rb
|
|
139
|
+
- lib/svg_conform/errors/base.rb
|
|
140
|
+
- lib/svg_conform/errors/validation_issue.rb
|
|
141
|
+
- lib/svg_conform/errors/validation_notice.rb
|
|
137
142
|
- lib/svg_conform/external_checkers.rb
|
|
138
143
|
- lib/svg_conform/external_checkers/svgcheck.rb
|
|
139
144
|
- lib/svg_conform/external_checkers/svgcheck/compatibility_engine.rb
|
|
@@ -142,8 +147,9 @@ files:
|
|
|
142
147
|
- lib/svg_conform/external_checkers/svgcheck/report_comparator.rb
|
|
143
148
|
- lib/svg_conform/external_checkers/svgcheck/report_generator.rb
|
|
144
149
|
- lib/svg_conform/external_checkers/svgcheck/validation_pipeline.rb
|
|
145
|
-
- lib/svg_conform/fast_document_analyzer.rb
|
|
146
150
|
- lib/svg_conform/fixer.rb
|
|
151
|
+
- lib/svg_conform/interfaces/requirement_interface.rb
|
|
152
|
+
- lib/svg_conform/node_helpers.rb
|
|
147
153
|
- lib/svg_conform/node_index_builder.rb
|
|
148
154
|
- lib/svg_conform/profile.rb
|
|
149
155
|
- lib/svg_conform/profiles.rb
|
|
@@ -190,7 +196,11 @@ files:
|
|
|
190
196
|
- lib/svg_conform/sax_document.rb
|
|
191
197
|
- lib/svg_conform/sax_validation_handler.rb
|
|
192
198
|
- lib/svg_conform/semantic_comparator.rb
|
|
199
|
+
- lib/svg_conform/validation/error_tracker.rb
|
|
200
|
+
- lib/svg_conform/validation/node_id_manager.rb
|
|
201
|
+
- lib/svg_conform/validation/structural_invalidity_tracker.rb
|
|
193
202
|
- lib/svg_conform/validation_context.rb
|
|
203
|
+
- lib/svg_conform/validation_issue.rb
|
|
194
204
|
- lib/svg_conform/validation_result.rb
|
|
195
205
|
- lib/svg_conform/validator.rb
|
|
196
206
|
- lib/svg_conform/version.rb
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module SvgConform
|
|
4
|
-
# Fast document analyzer that pre-computes node relationships and IDs
|
|
5
|
-
# in a single pass to avoid repeated expensive traversals
|
|
6
|
-
#
|
|
7
|
-
# IMPORTANT: Stores paths indexed by the path itself (not object_id)
|
|
8
|
-
# since node object_ids change between traversals
|
|
9
|
-
class FastDocumentAnalyzer
|
|
10
|
-
attr_reader :path_cache
|
|
11
|
-
|
|
12
|
-
def initialize(document)
|
|
13
|
-
@document = document
|
|
14
|
-
@path_cache = {}
|
|
15
|
-
|
|
16
|
-
analyze_document
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
# Get cached path-based ID for a node by computing its path once
|
|
20
|
-
def get_node_id(node)
|
|
21
|
-
return nil unless node.respond_to?(:name) && node.name
|
|
22
|
-
|
|
23
|
-
# Compute path for this node (fast with forward traversal counting)
|
|
24
|
-
compute_path_forward(node)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
private
|
|
28
|
-
|
|
29
|
-
def analyze_document
|
|
30
|
-
# Pre-populate cache is not needed since we compute on demand
|
|
31
|
-
# The optimization comes from forward-counting siblings instead of backward
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def compute_path_forward(node)
|
|
35
|
-
path_parts = []
|
|
36
|
-
current = node
|
|
37
|
-
|
|
38
|
-
while current
|
|
39
|
-
if current.respond_to?(:name) && current.name
|
|
40
|
-
# Count position among siblings by iterating forward from parent
|
|
41
|
-
position = calculate_position_fast(current)
|
|
42
|
-
path_parts.unshift("#{current.name}[#{position}]")
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
break unless current.respond_to?(:parent)
|
|
46
|
-
|
|
47
|
-
begin
|
|
48
|
-
current = current.parent
|
|
49
|
-
rescue NoMethodError
|
|
50
|
-
break
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
break unless current
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
"/#{path_parts.join('/')}"
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def calculate_position_fast(node)
|
|
60
|
-
return 1 unless node.respond_to?(:parent)
|
|
61
|
-
|
|
62
|
-
parent = begin
|
|
63
|
-
node.parent
|
|
64
|
-
rescue NoMethodError
|
|
65
|
-
nil
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
return 1 unless parent.respond_to?(:children)
|
|
69
|
-
|
|
70
|
-
# Count this node's position among siblings with same name
|
|
71
|
-
position = 0
|
|
72
|
-
parent.children.each do |child|
|
|
73
|
-
next unless child.respond_to?(:name) && child.name == node.name
|
|
74
|
-
|
|
75
|
-
position += 1
|
|
76
|
-
break if child.equal?(node)
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
position
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
end
|