svg_conform 0.2.6 → 0.2.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/.github/workflows/rake.yml +1 -1
- data/Gemfile +2 -3
- data/Gemfile.lock +103 -76
- data/README.adoc +7 -0
- data/config/profiles/{metanorma.yml → metanorma-sample.yml} +4 -4
- data/docs/api_reference.adoc +21 -21
- data/docs/cli_guide.adoc +41 -41
- data/docs/profiles.adoc +8 -2
- data/docs/reference_manifest.adoc +3 -3
- data/lib/svg_conform/cli.rb +4 -5
- data/lib/svg_conform/errors/validation_issue.rb +6 -1
- data/lib/svg_conform/external_checkers/svgcheck/parser.rb +1 -3
- data/lib/svg_conform/quality_metrics/configuration.rb +4 -2
- data/lib/svg_conform/references/reference_manifest.rb +1 -2
- data/lib/svg_conform/validation/error_tracker.rb +37 -8
- data/lib/svg_conform/validation/svg_1_1_document_conformance.rb +0 -1
- data/lib/svg_conform/version.rb +1 -1
- data/lib/svg_conform/yaml_io.rb +20 -0
- data/lib/svg_conform.rb +1 -0
- data/spec/fixtures/quality_metrics/aliases.yml +7 -0
- data/spec/svg_conform/errors/validation_issue_spec.rb +53 -0
- data/spec/svg_conform/gemspec_spec.rb +23 -7
- data/spec/svg_conform/profiles/metanorma_profile_spec.rb +55 -7
- data/spec/svg_conform/profiles_plantuml_spec.rb +1 -1
- data/spec/svg_conform/quality_metrics/configuration_spec.rb +82 -0
- data/spec/svg_conform/references/integration_spec.rb +1 -1
- data/spec/svg_conform/requirements/id_reference_state_spec.rb +5 -5
- data/spec/svg_conform/requirements/text_as_path_requirement_spec.rb +15 -11
- data/spec/svg_conform/validator_input_types_spec.rb +11 -11
- data/spec/svg_conform/yaml_io_spec.rb +41 -0
- data/spec/svg_conform_spec.rb +3 -3
- data/svg_conform.gemspec +7 -0
- metadata +36 -3
|
@@ -2,18 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
require "spec_helper"
|
|
4
4
|
|
|
5
|
+
# Container elements take the clip-path and mask presentation attributes
|
|
6
|
+
# per SVG (metanorma-pdfa#106).
|
|
7
|
+
METANORMA_PROFILE_CONTAINER_TAGS = %w[g a defs].freeze
|
|
8
|
+
METANORMA_PROFILE_CLIP_ATTRIBUTES = %w[clip-path mask].freeze
|
|
9
|
+
|
|
5
10
|
RSpec.describe "Metanorma Profile" do
|
|
6
|
-
let(:
|
|
11
|
+
let(:metanorma_sample_profile_path) { "config/profiles/metanorma-sample.yml" }
|
|
7
12
|
|
|
8
13
|
describe "profile loading" do
|
|
9
14
|
it "loads the Metanorma profile successfully" do
|
|
10
|
-
profile = SvgConform::Profile.load_from_file(
|
|
15
|
+
profile = SvgConform::Profile.load_from_file(metanorma_sample_profile_path)
|
|
11
16
|
expect(profile).not_to be_nil
|
|
12
|
-
expect(profile.name).to eq("metanorma")
|
|
17
|
+
expect(profile.name).to eq("metanorma-sample")
|
|
13
18
|
end
|
|
14
19
|
|
|
15
20
|
it "includes external resource requirements" do
|
|
16
|
-
profile = SvgConform::Profile.load_from_file(
|
|
21
|
+
profile = SvgConform::Profile.load_from_file(metanorma_sample_profile_path)
|
|
17
22
|
requirement_ids = profile.requirements.map(&:id)
|
|
18
23
|
expect(requirement_ids).to include("no_external_css")
|
|
19
24
|
expect(requirement_ids).to include("no_external_fonts")
|
|
@@ -21,7 +26,7 @@ RSpec.describe "Metanorma Profile" do
|
|
|
21
26
|
end
|
|
22
27
|
|
|
23
28
|
it "includes comprehensive element support" do
|
|
24
|
-
profile = SvgConform::Profile.load_from_file(
|
|
29
|
+
profile = SvgConform::Profile.load_from_file(metanorma_sample_profile_path)
|
|
25
30
|
requirement_ids = profile.requirements.map(&:id)
|
|
26
31
|
expect(requirement_ids).to include("allowed_elements")
|
|
27
32
|
end
|
|
@@ -36,7 +41,7 @@ RSpec.describe "Metanorma Profile" do
|
|
|
36
41
|
SVG
|
|
37
42
|
|
|
38
43
|
document = SvgConform::Document.from_content(svg_with_colors)
|
|
39
|
-
profile = SvgConform::Profile.load_from_file(
|
|
44
|
+
profile = SvgConform::Profile.load_from_file(metanorma_sample_profile_path)
|
|
40
45
|
|
|
41
46
|
result = profile.validate(document)
|
|
42
47
|
color_errors = result.errors.select do |e|
|
|
@@ -53,10 +58,53 @@ RSpec.describe "Metanorma Profile" do
|
|
|
53
58
|
SVG
|
|
54
59
|
|
|
55
60
|
document = SvgConform::Document.from_content(svg_with_image)
|
|
56
|
-
profile = SvgConform::Profile.load_from_file(
|
|
61
|
+
profile = SvgConform::Profile.load_from_file(metanorma_sample_profile_path)
|
|
57
62
|
|
|
58
63
|
result = profile.validate(document)
|
|
59
64
|
expect(result).to respond_to(:valid?)
|
|
60
65
|
end
|
|
61
66
|
end
|
|
67
|
+
|
|
68
|
+
describe "clip-path and mask on container elements" do
|
|
69
|
+
# SVG applies the clip-path and mask properties to container elements and
|
|
70
|
+
# graphics elements alike; rejecting them on containers rejects
|
|
71
|
+
# schema-valid documents (metanorma-pdfa#106).
|
|
72
|
+
let(:profile) { SvgConform::Profile.load_from_file(metanorma_sample_profile_path) }
|
|
73
|
+
let(:validator) { SvgConform::Validator.new(mode: :sax) }
|
|
74
|
+
|
|
75
|
+
def svg_with_clip_assets(inner)
|
|
76
|
+
<<~SVG
|
|
77
|
+
<svg xmlns="http://www.w3.org/2000/svg" version="1.2" baseProfile="tiny" viewBox="0 0 100 100">
|
|
78
|
+
<defs>
|
|
79
|
+
<clipPath id="clip1">
|
|
80
|
+
<rect x="0" y="0" width="50" height="50"/>
|
|
81
|
+
</clipPath>
|
|
82
|
+
<mask id="mask1">
|
|
83
|
+
<rect x="0" y="0" width="50" height="50" fill="white"/>
|
|
84
|
+
</mask>
|
|
85
|
+
</defs>
|
|
86
|
+
#{inner}
|
|
87
|
+
</svg>
|
|
88
|
+
SVG
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
METANORMA_PROFILE_CONTAINER_TAGS.each do |tag|
|
|
92
|
+
METANORMA_PROFILE_CLIP_ATTRIBUTES.each do |attribute|
|
|
93
|
+
it "allows #{attribute} on #{tag}" do
|
|
94
|
+
svg = svg_with_clip_assets(
|
|
95
|
+
"<#{tag} #{attribute}=\"url(##{attribute == 'clip-path' ? 'clip1' : 'mask1'})\">" \
|
|
96
|
+
"<rect x=\"10\" y=\"10\" width=\"30\" height=\"30\" fill=\"red\"/>" \
|
|
97
|
+
"</#{tag}>",
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
result = validator.validate(svg, profile: profile)
|
|
101
|
+
attribute_errors = result.errors.select do |e|
|
|
102
|
+
e.message.include?("'#{attribute}'")
|
|
103
|
+
end
|
|
104
|
+
expect(attribute_errors).to be_empty
|
|
105
|
+
expect(result).to be_valid
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
62
110
|
end
|
|
@@ -5,7 +5,7 @@ require "nokogiri"
|
|
|
5
5
|
|
|
6
6
|
RSpec.describe SvgConform::Profiles do
|
|
7
7
|
let(:validator) { SvgConform::Validator.new(mode: :sax) }
|
|
8
|
-
let(:profile) { described_class.get(:metanorma) }
|
|
8
|
+
let(:profile) { described_class.get(:"metanorma-sample") }
|
|
9
9
|
let(:plantuml_attributes) { %w[contentstyletype zoomandpan title textlength lengthadjust] }
|
|
10
10
|
let(:svg) do
|
|
11
11
|
<<~SVG
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
require "svg_conform/quality_metrics/configuration"
|
|
5
|
+
require "psych"
|
|
6
|
+
require "tempfile"
|
|
7
|
+
|
|
8
|
+
RSpec.describe SvgConform::QualityMetrics::Configuration do
|
|
9
|
+
describe ".default" do
|
|
10
|
+
let(:hash) { described_class.default.instance_variable_get(:@hash) }
|
|
11
|
+
|
|
12
|
+
it "loads bundled violation types as Symbols" do
|
|
13
|
+
types = hash.fetch("severity_levels").values.flat_map do |level|
|
|
14
|
+
level.fetch("violation_types")
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
expect(types).to include(:reference_violation)
|
|
18
|
+
expect(types).to all(be_a(Symbol))
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "preserves the entire Psych-loaded configuration" do
|
|
22
|
+
expected = Psych.safe_load_file(described_class::DEFAULT_CONFIG_PATH,
|
|
23
|
+
permitted_classes: [Symbol],
|
|
24
|
+
permitted_symbols: [], aliases: true)
|
|
25
|
+
|
|
26
|
+
expect(hash).to eq(expected)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe ".from_yaml" do
|
|
31
|
+
def load_yaml(source)
|
|
32
|
+
Tempfile.create(["quality_metrics", ".yml"]) do |file|
|
|
33
|
+
file.write(source)
|
|
34
|
+
file.flush
|
|
35
|
+
described_class.from_yaml(file.path)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "preserves quoted Symbol values" do
|
|
40
|
+
pending "yeptris differs from Psych: quoted Symbols retain quotes; upstream issue to be filed, see PR description"
|
|
41
|
+
|
|
42
|
+
config = load_yaml('a: :"x y"')
|
|
43
|
+
|
|
44
|
+
expect(config.instance_variable_get(:@hash)).to eq("a" => :"x y")
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "rejects disallowed dates with the yeptris error naming Date" do
|
|
48
|
+
expect { load_yaml("f: 2024-01-02\n") }
|
|
49
|
+
.to raise_error(Yeptris::Psych::DisallowedClass, /Date/)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "rejects disallowed times with the yeptris error naming Time" do
|
|
53
|
+
pending "yeptris differs from Psych: disallowed Time is reported as Date; upstream issue to be filed, see PR description"
|
|
54
|
+
|
|
55
|
+
expect { load_yaml("f: 2024-01-02 10:00:00\n") }
|
|
56
|
+
.to raise_error(Yeptris::Psych::DisallowedClass, /Time/)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it "rejects invalid YAML with the yeptris syntax error" do
|
|
60
|
+
expect { load_yaml("a: [\n") }.to raise_error(Yeptris::Psych::SyntaxError)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "resolves anchors and aliases" do
|
|
64
|
+
path = File.expand_path("../../fixtures/quality_metrics/aliases.yml", __dir__)
|
|
65
|
+
hash = described_class.from_yaml(path).instance_variable_get(:@hash)
|
|
66
|
+
|
|
67
|
+
expect(hash.fetch("remediable_types")).to eq([:reference_violation])
|
|
68
|
+
expect(hash.dig("severity_levels", "critical", "violation_types"))
|
|
69
|
+
.to eq(hash.fetch("remediable_types"))
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it "rejects a non-permitted class with the yeptris error" do
|
|
73
|
+
Tempfile.create(["quality_metrics", ".yml"]) do |file|
|
|
74
|
+
file.write("--- !ruby/object:Object {}\n")
|
|
75
|
+
file.flush
|
|
76
|
+
|
|
77
|
+
expect { described_class.from_yaml(file.path) }
|
|
78
|
+
.to raise_error(Yeptris::Psych::DisallowedClass)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
require "spec_helper"
|
|
4
4
|
|
|
5
5
|
RSpec.describe "Reference Manifest Integration" do
|
|
6
|
-
let(:validator) { SvgConform::Validator.new(profile: "metanorma") }
|
|
6
|
+
let(:validator) { SvgConform::Validator.new(profile: "metanorma-sample") }
|
|
7
7
|
|
|
8
8
|
describe "complete reference manifest generation" do
|
|
9
9
|
let(:svg_content) do
|
|
@@ -30,7 +30,7 @@ RSpec.describe "IdReferenceRequirement" do
|
|
|
30
30
|
|
|
31
31
|
it "does not leak state from first validation to second validation" do
|
|
32
32
|
# First validation: SVG with reference error
|
|
33
|
-
result1 = validator.validate(svg_with_error, profile: :metanorma)
|
|
33
|
+
result1 = validator.validate(svg_with_error, profile: :"metanorma-sample")
|
|
34
34
|
|
|
35
35
|
# Verify first validation caught the error
|
|
36
36
|
expect(result1.errors.map(&:message)).to include(
|
|
@@ -38,7 +38,7 @@ RSpec.describe "IdReferenceRequirement" do
|
|
|
38
38
|
)
|
|
39
39
|
|
|
40
40
|
# Second validation: SVG without reference errors
|
|
41
|
-
result2 = validator.validate(svg_without_error, profile: :metanorma)
|
|
41
|
+
result2 = validator.validate(svg_without_error, profile: :"metanorma-sample")
|
|
42
42
|
|
|
43
43
|
# Verify second validation does NOT report errors from first validation
|
|
44
44
|
error_messages = result2.errors.map(&:message).join("\n")
|
|
@@ -59,8 +59,8 @@ RSpec.describe "IdReferenceRequirement" do
|
|
|
59
59
|
|
|
60
60
|
# Alternate between error and no-error SVGs
|
|
61
61
|
3.times do
|
|
62
|
-
results << validator.validate(svg_with_error, profile: :metanorma)
|
|
63
|
-
results << validator.validate(svg_without_error, profile: :metanorma)
|
|
62
|
+
results << validator.validate(svg_with_error, profile: :"metanorma-sample")
|
|
63
|
+
results << validator.validate(svg_without_error, profile: :"metanorma-sample")
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
# Check that error pattern is consistent
|
|
@@ -80,7 +80,7 @@ RSpec.describe "IdReferenceRequirement" do
|
|
|
80
80
|
|
|
81
81
|
it "resets state when using the same profile instance" do
|
|
82
82
|
# Get profile instance
|
|
83
|
-
profile = SvgConform::Profiles.get(:metanorma)
|
|
83
|
+
profile = SvgConform::Profiles.get(:"metanorma-sample")
|
|
84
84
|
|
|
85
85
|
# Run two validations using the same profile
|
|
86
86
|
validator.validate(svg_with_error, profile: profile)
|
|
@@ -55,13 +55,17 @@ RSpec.describe SvgConform::Requirements::TextAsPathRequirement do
|
|
|
55
55
|
</svg>
|
|
56
56
|
SVG
|
|
57
57
|
|
|
58
|
-
result = validator.validate(svg, profile: :metanorma)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
expect(
|
|
64
|
-
expect(
|
|
58
|
+
result = validator.validate(svg, profile: :"metanorma-sample")
|
|
59
|
+
|
|
60
|
+
# Text-as-path is a quality advisory declared with severity: warning:
|
|
61
|
+
# it must surface as a warning, never as an error, so that schema-valid
|
|
62
|
+
# documents are not reported as invalid (metanorma-pdfa#106).
|
|
63
|
+
expect(result.errors).to be_empty
|
|
64
|
+
expect(result.warnings.map(&:message)).to include(
|
|
65
|
+
a_string_including("rendered as paths"),
|
|
66
|
+
)
|
|
67
|
+
expect(result.warnings.first.severity).to eq(:warning)
|
|
68
|
+
expect(result).to be_valid
|
|
65
69
|
end
|
|
66
70
|
|
|
67
71
|
it "does not flag SVG with native text elements" do
|
|
@@ -72,7 +76,7 @@ RSpec.describe SvgConform::Requirements::TextAsPathRequirement do
|
|
|
72
76
|
</svg>
|
|
73
77
|
SVG
|
|
74
78
|
|
|
75
|
-
result = validator.validate(svg, profile: :metanorma)
|
|
79
|
+
result = validator.validate(svg, profile: :"metanorma-sample")
|
|
76
80
|
text_as_path_errors = result.errors.select do |e|
|
|
77
81
|
e.message.include?("rendered as paths")
|
|
78
82
|
end
|
|
@@ -88,7 +92,7 @@ RSpec.describe SvgConform::Requirements::TextAsPathRequirement do
|
|
|
88
92
|
</svg>
|
|
89
93
|
SVG
|
|
90
94
|
|
|
91
|
-
result = validator.validate(svg, profile: :metanorma)
|
|
95
|
+
result = validator.validate(svg, profile: :"metanorma-sample")
|
|
92
96
|
text_as_path_errors = result.errors.select do |e|
|
|
93
97
|
e.message.include?("rendered as paths")
|
|
94
98
|
end
|
|
@@ -103,7 +107,7 @@ RSpec.describe SvgConform::Requirements::TextAsPathRequirement do
|
|
|
103
107
|
</svg>
|
|
104
108
|
SVG
|
|
105
109
|
|
|
106
|
-
result = validator.validate(svg, profile: :metanorma)
|
|
110
|
+
result = validator.validate(svg, profile: :"metanorma-sample")
|
|
107
111
|
text_as_path_errors = result.errors.select do |e|
|
|
108
112
|
e.message.include?("rendered as paths")
|
|
109
113
|
end
|
|
@@ -118,7 +122,7 @@ RSpec.describe SvgConform::Requirements::TextAsPathRequirement do
|
|
|
118
122
|
</svg>
|
|
119
123
|
SVG
|
|
120
124
|
|
|
121
|
-
result = validator.validate(svg, profile: :metanorma)
|
|
125
|
+
result = validator.validate(svg, profile: :"metanorma-sample")
|
|
122
126
|
text_as_path_errors = result.errors.select do |e|
|
|
123
127
|
e.message.include?("rendered as paths")
|
|
124
128
|
end
|
|
@@ -16,7 +16,7 @@ RSpec.describe SvgConform::Validator do
|
|
|
16
16
|
describe "#validate with different input types" do
|
|
17
17
|
context "with String input (backward compatibility)" do
|
|
18
18
|
it "validates XML string successfully" do
|
|
19
|
-
result = validator.validate(simple_svg, profile: :metanorma)
|
|
19
|
+
result = validator.validate(simple_svg, profile: :"metanorma-sample")
|
|
20
20
|
|
|
21
21
|
expect(result).to be_a(SvgConform::ValidationResult)
|
|
22
22
|
expect(result.valid?).to be true
|
|
@@ -37,7 +37,7 @@ RSpec.describe SvgConform::Validator do
|
|
|
37
37
|
moxml_doc = Moxml.new.parse(simple_svg)
|
|
38
38
|
|
|
39
39
|
# Validate using the document object
|
|
40
|
-
result = validator.validate(moxml_doc, profile: :metanorma)
|
|
40
|
+
result = validator.validate(moxml_doc, profile: :"metanorma-sample")
|
|
41
41
|
|
|
42
42
|
expect(result).to be_a(SvgConform::ValidationResult)
|
|
43
43
|
expect(result.valid?).to be true
|
|
@@ -50,7 +50,7 @@ RSpec.describe SvgConform::Validator do
|
|
|
50
50
|
# (SAX mode is safe for large files, unlike DOM)
|
|
51
51
|
expect(moxml_doc).to receive(:to_xml).once.and_call_original
|
|
52
52
|
|
|
53
|
-
validator.validate(moxml_doc, profile: :metanorma)
|
|
53
|
+
validator.validate(moxml_doc, profile: :"metanorma-sample")
|
|
54
54
|
end
|
|
55
55
|
end
|
|
56
56
|
|
|
@@ -59,7 +59,7 @@ RSpec.describe SvgConform::Validator do
|
|
|
59
59
|
moxml_doc = Moxml.new.parse(simple_svg)
|
|
60
60
|
svg_element = moxml_doc.root
|
|
61
61
|
|
|
62
|
-
result = validator.validate(svg_element, profile: :metanorma)
|
|
62
|
+
result = validator.validate(svg_element, profile: :"metanorma-sample")
|
|
63
63
|
|
|
64
64
|
expect(result).to be_a(SvgConform::ValidationResult)
|
|
65
65
|
expect(result.valid?).to be true
|
|
@@ -70,7 +70,7 @@ RSpec.describe SvgConform::Validator do
|
|
|
70
70
|
it "validates a leptris document" do
|
|
71
71
|
leptris_doc = Leptris::XML.parse(simple_svg)
|
|
72
72
|
|
|
73
|
-
result = validator.validate(leptris_doc, profile: :metanorma)
|
|
73
|
+
result = validator.validate(leptris_doc, profile: :"metanorma-sample")
|
|
74
74
|
|
|
75
75
|
expect(result).to be_a(SvgConform::ValidationResult)
|
|
76
76
|
expect(result.valid?).to be true
|
|
@@ -81,7 +81,7 @@ RSpec.describe SvgConform::Validator do
|
|
|
81
81
|
svg_element = leptris_doc.root
|
|
82
82
|
|
|
83
83
|
# This is the metanorma use case - passing element directly
|
|
84
|
-
result = validator.validate(svg_element, profile: :metanorma)
|
|
84
|
+
result = validator.validate(svg_element, profile: :"metanorma-sample")
|
|
85
85
|
|
|
86
86
|
expect(result).to be_a(SvgConform::ValidationResult)
|
|
87
87
|
expect(result.valid?).to be true
|
|
@@ -95,20 +95,20 @@ RSpec.describe SvgConform::Validator do
|
|
|
95
95
|
# (SAX mode is memory-safe for large SVGs)
|
|
96
96
|
expect(svg_element).to receive(:to_xml).once.and_call_original
|
|
97
97
|
|
|
98
|
-
validator.validate(svg_element, profile: :metanorma)
|
|
98
|
+
validator.validate(svg_element, profile: :"metanorma-sample")
|
|
99
99
|
end
|
|
100
100
|
end
|
|
101
101
|
|
|
102
102
|
context "with invalid input" do
|
|
103
103
|
it "raises ArgumentError for unsupported input type" do
|
|
104
104
|
expect do
|
|
105
|
-
validator.validate(12345, profile: :metanorma)
|
|
105
|
+
validator.validate(12345, profile: :"metanorma-sample")
|
|
106
106
|
end.to raise_error(ArgumentError, /Invalid input type/)
|
|
107
107
|
end
|
|
108
108
|
|
|
109
109
|
it "raises ArgumentError for nil input" do
|
|
110
110
|
expect do
|
|
111
|
-
validator.validate(nil, profile: :metanorma)
|
|
111
|
+
validator.validate(nil, profile: :"metanorma-sample")
|
|
112
112
|
end.to raise_error(ArgumentError, /Invalid input type/)
|
|
113
113
|
end
|
|
114
114
|
end
|
|
@@ -130,7 +130,7 @@ RSpec.describe SvgConform::Validator do
|
|
|
130
130
|
leptris_doc = Leptris::XML.parse(svg_with_refs)
|
|
131
131
|
svg_element = leptris_doc.root
|
|
132
132
|
|
|
133
|
-
result = validator.validate(svg_element, profile: :metanorma)
|
|
133
|
+
result = validator.validate(svg_element, profile: :"metanorma-sample")
|
|
134
134
|
|
|
135
135
|
expect(result.reference_manifest).not_to be_nil
|
|
136
136
|
expect(result.available_ids.map(&:id_value)).to include("box")
|
|
@@ -140,7 +140,7 @@ RSpec.describe SvgConform::Validator do
|
|
|
140
140
|
it "builds reference manifest from Moxml document" do
|
|
141
141
|
moxml_doc = Moxml.new.parse(svg_with_refs)
|
|
142
142
|
|
|
143
|
-
result = validator.validate(moxml_doc, profile: :metanorma)
|
|
143
|
+
result = validator.validate(moxml_doc, profile: :"metanorma-sample")
|
|
144
144
|
|
|
145
145
|
expect(result.reference_manifest).not_to be_nil
|
|
146
146
|
expect(result.available_ids.map(&:id_value)).to include("box")
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
require "tmpdir"
|
|
5
|
+
|
|
6
|
+
RSpec.describe SvgConform::YamlIO do
|
|
7
|
+
def with_yaml(text)
|
|
8
|
+
Dir.mktmpdir do |dir|
|
|
9
|
+
path = File.join(dir, "t.yml")
|
|
10
|
+
File.write(path, text)
|
|
11
|
+
yield path
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
let(:aliased) { "a: &x {k: 1}\nb: *x\nc: :sym\n" }
|
|
16
|
+
|
|
17
|
+
it "loads aliases and permitted Symbols like Psych" do
|
|
18
|
+
with_yaml(aliased) do |path|
|
|
19
|
+
expect(described_class.safe_load_file(
|
|
20
|
+
path, permitted_classes: [Symbol], aliases: true
|
|
21
|
+
)).to eq("a" => { "k" => 1 }, "b" => { "k" => 1 }, "c" => :sym)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "rejects aliases unless aliases: true" do
|
|
26
|
+
with_yaml(aliased) do |path|
|
|
27
|
+
expect do
|
|
28
|
+
described_class.safe_load_file(path, permitted_classes: [Symbol])
|
|
29
|
+
end.to raise_error(Yeptris::Psych::AliasesError)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "loads the bundled quality config through Configuration" do
|
|
34
|
+
expect(SvgConform::QualityMetrics::Configuration.default).not_to be_nil
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "dumps byte-identical to Psych for a manifest-like hash" do
|
|
38
|
+
h = { "a" => :b, "c" => [1, "x: y", nil], "d" => { "e" => 1.5 } }
|
|
39
|
+
expect(described_class.dump(h)).to eq(Psych.dump(h))
|
|
40
|
+
end
|
|
41
|
+
end
|
data/spec/svg_conform_spec.rb
CHANGED
|
@@ -48,7 +48,7 @@ RSpec.describe SvgConform do
|
|
|
48
48
|
validator = SvgConform::Validator.new(mode: :sax)
|
|
49
49
|
|
|
50
50
|
# First validation with metanorma profile
|
|
51
|
-
profile_meta = SvgConform::Profiles.get("metanorma")
|
|
51
|
+
profile_meta = SvgConform::Profiles.get("metanorma-sample")
|
|
52
52
|
result_meta1 = validator.validate(svg_with_invalid_ref,
|
|
53
53
|
profile: profile_meta)
|
|
54
54
|
first_meta_count = result_meta1.errors.count
|
|
@@ -97,7 +97,7 @@ RSpec.describe SvgConform do
|
|
|
97
97
|
it "handles interleaved profile validations correctly" do
|
|
98
98
|
validator = SvgConform::Validator.new(mode: :sax)
|
|
99
99
|
|
|
100
|
-
profile_meta = SvgConform::Profiles.get("metanorma")
|
|
100
|
+
profile_meta = SvgConform::Profiles.get("metanorma-sample")
|
|
101
101
|
profile_rfc = SvgConform::Profiles.get("svg_1_2_rfc")
|
|
102
102
|
|
|
103
103
|
# Interleave validations
|
|
@@ -165,7 +165,7 @@ RSpec.describe SvgConform do
|
|
|
165
165
|
validator = SvgConform::Validator.new(mode: :sax)
|
|
166
166
|
|
|
167
167
|
# Validate with metanorma (should have 0 errors - more permissive)
|
|
168
|
-
profile_meta = SvgConform::Profiles.get("metanorma")
|
|
168
|
+
profile_meta = SvgConform::Profiles.get("metanorma-sample")
|
|
169
169
|
result_meta = validator.validate(svg_with_styles, profile: profile_meta)
|
|
170
170
|
meta_errors = result_meta.errors.count
|
|
171
171
|
|
data/svg_conform.gemspec
CHANGED
|
@@ -29,10 +29,17 @@ Gem::Specification.new do |spec|
|
|
|
29
29
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
30
30
|
spec.require_paths = ["lib"]
|
|
31
31
|
|
|
32
|
+
# The diagnostics adapter and the CLI's json/yaml output paths are built
|
|
33
|
+
# on lens_core (svg_conform.rb guards the require, but the guard's
|
|
34
|
+
# rescue LoadError misses Bundler::GemNotFound — undeclared, the CLI
|
|
35
|
+
# crashed on strict bundler deployments, claricle/svg_conform#130).
|
|
36
|
+
# lens_core 0.1.0 is published, so the 0.2.5-era optionality is obsolete.
|
|
37
|
+
spec.add_dependency "lens_core", "~> 0.1"
|
|
32
38
|
spec.add_dependency "lutaml-model", "~> 0.8.155"
|
|
33
39
|
spec.add_dependency "moxml", "~> 0.6.0"
|
|
34
40
|
spec.add_dependency "nokogiri", "~> 1.16"
|
|
35
41
|
spec.add_dependency "rainbow"
|
|
36
42
|
spec.add_dependency "table_tennis"
|
|
37
43
|
spec.add_dependency "thor"
|
|
44
|
+
spec.add_dependency "yeptris", "~> 0.6.36"
|
|
38
45
|
end
|
metadata
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: svg_conform
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: lens_core
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0.1'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0.1'
|
|
13
27
|
- !ruby/object:Gem::Dependency
|
|
14
28
|
name: lutaml-model
|
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -94,6 +108,20 @@ dependencies:
|
|
|
94
108
|
- - ">="
|
|
95
109
|
- !ruby/object:Gem::Version
|
|
96
110
|
version: '0'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: yeptris
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - "~>"
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: 0.6.36
|
|
118
|
+
type: :runtime
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - "~>"
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: 0.6.36
|
|
97
125
|
description:
|
|
98
126
|
email:
|
|
99
127
|
- open.source@ribose.com
|
|
@@ -126,7 +154,7 @@ files:
|
|
|
126
154
|
- benchmark/performance_comparison.rb
|
|
127
155
|
- config/profiles/base.yml
|
|
128
156
|
- config/profiles/lucid_fix.yml
|
|
129
|
-
- config/profiles/metanorma.yml
|
|
157
|
+
- config/profiles/metanorma-sample.yml
|
|
130
158
|
- config/profiles/no_external_css.yml
|
|
131
159
|
- config/profiles/svg_1_1_full_static.yml
|
|
132
160
|
- config/profiles/svg_1_2_rfc.yml
|
|
@@ -272,6 +300,7 @@ files:
|
|
|
272
300
|
- lib/svg_conform/validation_result.rb
|
|
273
301
|
- lib/svg_conform/validator.rb
|
|
274
302
|
- lib/svg_conform/version.rb
|
|
303
|
+
- lib/svg_conform/yaml_io.rb
|
|
275
304
|
- lib/tasks/fixtures.rake
|
|
276
305
|
- lib/tasks/svgcheck.rake
|
|
277
306
|
- reference-docs/SVG-1.2-RFC.rnc.txt
|
|
@@ -346,6 +375,7 @@ files:
|
|
|
346
375
|
- spec/fixtures/profiles/svg_2_secure_static/valid/same-document-fragment.svg
|
|
347
376
|
- spec/fixtures/profiles/svg_2_secure_static/valid/svg-base64.svg
|
|
348
377
|
- spec/fixtures/profiles/svg_2_secure_static/valid/svg-percent.svg
|
|
378
|
+
- spec/fixtures/quality_metrics/aliases.yml
|
|
349
379
|
- spec/fixtures/style/inputs/basic_violations.svg
|
|
350
380
|
- spec/fixtures/style/repair/basic_violations.svg
|
|
351
381
|
- spec/fixtures/style_promotion/inputs/basic_test.svg
|
|
@@ -522,6 +552,7 @@ files:
|
|
|
522
552
|
- spec/svg_conform/commands/svgcheck_generate_command_spec.rb
|
|
523
553
|
- spec/svg_conform/conformance_report_spec.rb
|
|
524
554
|
- spec/svg_conform/diagnostics/lens_core_adapter_spec.rb
|
|
555
|
+
- spec/svg_conform/errors/validation_issue_spec.rb
|
|
525
556
|
- spec/svg_conform/gemspec_spec.rb
|
|
526
557
|
- spec/svg_conform/profiles/base_profile_spec.rb
|
|
527
558
|
- spec/svg_conform/profiles/lucid_fix_profile_spec.rb
|
|
@@ -533,6 +564,7 @@ files:
|
|
|
533
564
|
- spec/svg_conform/profiles/svg_1_2_rfc_with_rdf_profile_spec.rb
|
|
534
565
|
- spec/svg_conform/profiles/svg_2_secure_static_profile_spec.rb
|
|
535
566
|
- spec/svg_conform/profiles_plantuml_spec.rb
|
|
567
|
+
- spec/svg_conform/quality_metrics/configuration_spec.rb
|
|
536
568
|
- spec/svg_conform/references/data_uri_reference_spec.rb
|
|
537
569
|
- spec/svg_conform/references/integration_spec.rb
|
|
538
570
|
- spec/svg_conform/references/reference_classifier_spec.rb
|
|
@@ -573,6 +605,7 @@ files:
|
|
|
573
605
|
- spec/svg_conform/validation_context_spec.rb
|
|
574
606
|
- spec/svg_conform/validation_result_spec.rb
|
|
575
607
|
- spec/svg_conform/validator_input_types_spec.rb
|
|
608
|
+
- spec/svg_conform/yaml_io_spec.rb
|
|
576
609
|
- spec/svg_conform_spec.rb
|
|
577
610
|
- spec/svgcheck_compatibility_spec.rb
|
|
578
611
|
- svg_conform.gemspec
|