svg_conform 0.2.9 → 0.2.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/.github/workflows/release.yml +3 -0
- data/Gemfile +0 -1
- data/Gemfile.lock +52 -51
- data/config/profiles/metanorma-sample.yml +7 -7
- data/config/profiles/svg_1_2_rfc.yml +18 -0
- data/lib/svg_conform/document.rb +5 -6
- data/lib/svg_conform/remediations/disallowed_attribute_remediation.rb +42 -0
- data/lib/svg_conform/remediations/namespace_attribute_remediation.rb +30 -24
- data/lib/svg_conform/remediations.rb +2 -0
- data/lib/svg_conform/requirements/namespace_attributes_requirement.rb +3 -12
- data/lib/svg_conform/requirements/svg_1_1_document_requirement.rb +14 -13
- data/lib/svg_conform/semantic_comparator.rb +1 -1
- data/lib/svg_conform/validation/svg_1_1_document_conformance.rb +185 -23
- data/lib/svg_conform/validator.rb +10 -2
- data/lib/svg_conform/version.rb +1 -1
- data/lib/svg_conform.rb +30 -1
- data/spec/svg_conform/external_checkers/svgcheck/parser_spec.rb +52 -0
- data/spec/svg_conform/gemspec_spec.rb +5 -1
- data/spec/svg_conform/profiles/metanorma_profile_spec.rb +34 -0
- data/spec/svg_conform/profiles_plantuml_spec.rb +14 -5
- data/spec/svg_conform/quality_metrics/configuration_spec.rb +0 -4
- data/spec/svg_conform/remediations/disallowed_attribute_remediation_spec.rb +78 -0
- data/spec/svg_conform/validator_input_types_spec.rb +36 -0
- data/spec/svg_conform/yaml_backend_spec.rb +103 -0
- data/svg_conform.gemspec +1 -1
- metadata +15 -11
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
require "yeptris/psych"
|
|
5
|
+
|
|
6
|
+
RSpec.describe "SvgConform" do
|
|
7
|
+
it "uses yeptris for lutaml-model YAML serialization" do
|
|
8
|
+
expect(Lutaml::Model::Config.yaml_adapter_type).to eq(:yeptris)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
Dir.glob(File.join(SvgConform::Profile::PROFILES_DIR, "*.yml")).each do |path|
|
|
12
|
+
it "loads the bundled #{File.basename(path)} profile through yeptris" do
|
|
13
|
+
expect(Lutaml::Yaml::Adapter::YeptrisAdapter).to receive(:parse).and_call_original
|
|
14
|
+
|
|
15
|
+
profile = SvgConform::Profile.load_from_file(path)
|
|
16
|
+
expected = Psych.safe_load_file(path)
|
|
17
|
+
|
|
18
|
+
expect(profile.name).to eq(expected.fetch("name"))
|
|
19
|
+
expect(profile.requirements.map(&:id))
|
|
20
|
+
.to eq(expected.fetch("requirements", []).map { |requirement| requirement.fetch("id") })
|
|
21
|
+
expect(Array(profile.remediations).map(&:id))
|
|
22
|
+
.to eq(expected.fetch("remediations", []).map { |remediation| remediation.fetch("id") })
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "loads conformance reports through yeptris" do
|
|
27
|
+
expect(Lutaml::Yaml::Adapter::YeptrisAdapter).to receive(:parse).and_call_original
|
|
28
|
+
|
|
29
|
+
report = SvgConform::ConformanceReport.from_yaml(<<~YAML)
|
|
30
|
+
filename: example.svg
|
|
31
|
+
valid: false
|
|
32
|
+
errors:
|
|
33
|
+
total_count: 1
|
|
34
|
+
by_requirement:
|
|
35
|
+
viewbox_required: 1
|
|
36
|
+
issues:
|
|
37
|
+
- requirement_id: viewbox_required
|
|
38
|
+
message: Missing viewBox
|
|
39
|
+
line: 2
|
|
40
|
+
YAML
|
|
41
|
+
|
|
42
|
+
expect(report.filename).to eq("example.svg")
|
|
43
|
+
expect(report.valid).to be(false)
|
|
44
|
+
expect(report.errors.total_count).to eq(1)
|
|
45
|
+
expect(report.errors.by_requirement).to eq("viewbox_required" => 1)
|
|
46
|
+
expect(report.errors.issues.first.message).to eq("Missing viewBox")
|
|
47
|
+
expect(report.errors.issues.first.line).to eq(2)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "rejects non-permitted Ruby object tags in model YAML" do
|
|
51
|
+
yaml = "filename: !ruby/object:OpenStruct {}\nvalid: false\n"
|
|
52
|
+
|
|
53
|
+
expect { SvgConform::ConformanceReport.from_yaml(yaml) }
|
|
54
|
+
.to raise_error(Yeptris::Psych::DisallowedClass, /OpenStruct/)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "decodes binary values in model YAML" do
|
|
58
|
+
report = SvgConform::ConformanceReport.from_yaml("filename: !!binary aGVsbG8=\n")
|
|
59
|
+
|
|
60
|
+
expect(report.filename).to eq("hello")
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "wraps malformed profile YAML in lutaml-model's format error" do
|
|
64
|
+
expect { SvgConform::Profile.from_yaml("name: [unclosed\n") }
|
|
65
|
+
.to raise_error(Lutaml::Model::InvalidFormatError)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "wraps malformed conformance report YAML in lutaml-model's format error" do
|
|
69
|
+
expect { SvgConform::ConformanceReport.from_yaml("filename: \"x\n valid: : :\n") }
|
|
70
|
+
.to raise_error(Lutaml::Model::InvalidFormatError)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it "preserves the Psych alias rejection class for model YAML" do
|
|
74
|
+
expect do
|
|
75
|
+
SvgConform::ConformanceReport.from_yaml("a: &x foo.svg\nfilename: *x\n")
|
|
76
|
+
end.to raise_error(Psych::AliasesNotEnabled)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it "preserves the standard adapter's emitted bytes for non-ASCII model text" do
|
|
80
|
+
report = SvgConform::ConformanceReport.new(filename: "émoji 🚀")
|
|
81
|
+
expected = Lutaml::Model::Config.with_adapter(yaml: :standard_yaml) do
|
|
82
|
+
report.to_yaml
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
expect(report.to_yaml).to eq(expected)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
it "keeps lib free of yaml requires and bare YAML or Psych calls" do
|
|
89
|
+
lib_dir = File.expand_path("../../lib", __dir__)
|
|
90
|
+
forbidden = /\brequire\s*(?:\(\s*)?["']yaml["']|(?<![\w:])(?:::)?(?:YAML|Psych)\s*\./
|
|
91
|
+
violations = Dir.glob("#{lib_dir}/**/*").select { |path| File.file?(path) }
|
|
92
|
+
.flat_map do |path|
|
|
93
|
+
File.readlines(path).each_with_index.filter_map do |line, index|
|
|
94
|
+
next unless line.match?(forbidden)
|
|
95
|
+
|
|
96
|
+
"#{path.delete_prefix("#{lib_dir}/")}:#{index + 1}: #{line.strip}"
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
expect(violations).to be_empty,
|
|
101
|
+
"Use SvgConform::YamlIO or Yeptris::Psych in lib/:\n#{violations.join("\n")}"
|
|
102
|
+
end
|
|
103
|
+
end
|
data/svg_conform.gemspec
CHANGED
|
@@ -35,9 +35,9 @@ Gem::Specification.new do |spec|
|
|
|
35
35
|
# crashed on strict bundler deployments, claricle/svg_conform#130).
|
|
36
36
|
# lens_core 0.1.0 is published, so the 0.2.5-era optionality is obsolete.
|
|
37
37
|
spec.add_dependency "lens_core", "~> 0.1"
|
|
38
|
+
spec.add_dependency "leptris", "~> 1.9"
|
|
38
39
|
spec.add_dependency "lutaml-model", "~> 0.8.155"
|
|
39
40
|
spec.add_dependency "moxml", "~> 0.6.0"
|
|
40
|
-
spec.add_dependency "nokogiri", "~> 1.16"
|
|
41
41
|
spec.add_dependency "rainbow"
|
|
42
42
|
spec.add_dependency "table_tennis"
|
|
43
43
|
spec.add_dependency "thor"
|
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.
|
|
4
|
+
version: 0.2.11
|
|
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-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: lens_core
|
|
@@ -25,47 +25,47 @@ dependencies:
|
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '0.1'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
28
|
+
name: leptris
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version:
|
|
33
|
+
version: '1.9'
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version:
|
|
40
|
+
version: '1.9'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
42
|
+
name: lutaml-model
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
45
|
- - "~>"
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: 0.
|
|
47
|
+
version: 0.8.155
|
|
48
48
|
type: :runtime
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
52
|
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: 0.
|
|
54
|
+
version: 0.8.155
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
56
|
+
name: moxml
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
59
|
- - "~>"
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version:
|
|
61
|
+
version: 0.6.0
|
|
62
62
|
type: :runtime
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
66
|
- - "~>"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version:
|
|
68
|
+
version: 0.6.0
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: rainbow
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -252,6 +252,7 @@ files:
|
|
|
252
252
|
- lib/svg_conform/remediations.rb
|
|
253
253
|
- lib/svg_conform/remediations/base_remediation.rb
|
|
254
254
|
- lib/svg_conform/remediations/color_remediation.rb
|
|
255
|
+
- lib/svg_conform/remediations/disallowed_attribute_remediation.rb
|
|
255
256
|
- lib/svg_conform/remediations/font_embedding_remediation.rb
|
|
256
257
|
- lib/svg_conform/remediations/font_remediation.rb
|
|
257
258
|
- lib/svg_conform/remediations/image_embedding_remediation.rb
|
|
@@ -553,6 +554,7 @@ files:
|
|
|
553
554
|
- spec/svg_conform/conformance_report_spec.rb
|
|
554
555
|
- spec/svg_conform/diagnostics/lens_core_adapter_spec.rb
|
|
555
556
|
- spec/svg_conform/errors/validation_issue_spec.rb
|
|
557
|
+
- spec/svg_conform/external_checkers/svgcheck/parser_spec.rb
|
|
556
558
|
- spec/svg_conform/gemspec_spec.rb
|
|
557
559
|
- spec/svg_conform/profiles/base_profile_spec.rb
|
|
558
560
|
- spec/svg_conform/profiles/lucid_fix_profile_spec.rb
|
|
@@ -570,6 +572,7 @@ files:
|
|
|
570
572
|
- spec/svg_conform/references/reference_classifier_spec.rb
|
|
571
573
|
- spec/svg_conform/references/reference_manifest_spec.rb
|
|
572
574
|
- spec/svg_conform/remediations/color_remediation_spec.rb
|
|
575
|
+
- spec/svg_conform/remediations/disallowed_attribute_remediation_spec.rb
|
|
573
576
|
- spec/svg_conform/remediations/font_embedding_remediation_spec.rb
|
|
574
577
|
- spec/svg_conform/remediations/font_remediation_spec.rb
|
|
575
578
|
- spec/svg_conform/remediations/image_embedding_remediation_spec.rb
|
|
@@ -605,6 +608,7 @@ files:
|
|
|
605
608
|
- spec/svg_conform/validation_context_spec.rb
|
|
606
609
|
- spec/svg_conform/validation_result_spec.rb
|
|
607
610
|
- spec/svg_conform/validator_input_types_spec.rb
|
|
611
|
+
- spec/svg_conform/yaml_backend_spec.rb
|
|
608
612
|
- spec/svg_conform/yaml_io_spec.rb
|
|
609
613
|
- spec/svg_conform_spec.rb
|
|
610
614
|
- spec/svgcheck_compatibility_spec.rb
|