svg_conform 0.2.9 → 0.2.10
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/Gemfile.lock +4 -4
- data/config/profiles/metanorma-sample.yml +7 -7
- data/lib/svg_conform/validator.rb +10 -2
- data/lib/svg_conform/version.rb +1 -1
- data/spec/svg_conform/gemspec_spec.rb +4 -0
- data/spec/svg_conform/profiles/metanorma_profile_spec.rb +34 -0
- data/spec/svg_conform/validator_input_types_spec.rb +36 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a98a255cfd05daa747f6fb0a57ac7073f08a5a1d4fcf92605f0d07a6bbc15f1d
|
|
4
|
+
data.tar.gz: 6090500381531d8dba8d286d331a0db7ae5de241afb9555860926c7ce7bcb735
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 41f637b73125016607e79e0c4196208edde2efa2c54ad498a7fea32837b4b378f40f224582a0302ff9ecb6eee687dfb1b14512201c1b7de62edad0c59d280a09
|
|
7
|
+
data.tar.gz: a1c98f687632c433dd2cb3057f65ac8b2336167de6c80675079bde8c436655e66140c663bed81249bb12b4e72aa22459c180a0b762b50c1070c1bcbe89fdd0a0
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
svg_conform (0.2.
|
|
4
|
+
svg_conform (0.2.9)
|
|
5
5
|
lens_core (~> 0.1)
|
|
6
6
|
lutaml-model (~> 0.8.155)
|
|
7
7
|
moxml (~> 0.6.0)
|
|
@@ -71,7 +71,7 @@ GEM
|
|
|
71
71
|
rubyzip (~> 3.7)
|
|
72
72
|
thor (~> 1.4)
|
|
73
73
|
memo_wise (1.13.0)
|
|
74
|
-
moxml (0.6.
|
|
74
|
+
moxml (0.6.5)
|
|
75
75
|
nokogiri (1.19.7-aarch64-linux-gnu)
|
|
76
76
|
racc (~> 1.4)
|
|
77
77
|
nokogiri (1.19.7-aarch64-linux-musl)
|
|
@@ -240,7 +240,7 @@ CHECKSUMS
|
|
|
240
240
|
liquid (5.14.0) sha256=e1020c2b2ee58c7a4d3bfdc7a331537bd27a783353748bff0bf27c6ac0c17065
|
|
241
241
|
lutaml-model (0.8.174) sha256=d8e92d630a5972fe98bf5fe3f778db47afa328fb36a712c71531e6f82b49d110
|
|
242
242
|
memo_wise (1.13.0) sha256=30220c38c4cef410849bc73553c58664dc2c91c6379e4a1df22aea02358b716b
|
|
243
|
-
moxml (0.6.
|
|
243
|
+
moxml (0.6.5) sha256=bd2671d47c10f19eae3f5d5750aa419304c51cac5ac3ca906044c149429950f4
|
|
244
244
|
nokogiri (1.19.7-aarch64-linux-gnu) sha256=8f5e15d299602456406e1f03a9f3456cceb33a0722811e818d2ee2214eb4c84a
|
|
245
245
|
nokogiri (1.19.7-aarch64-linux-musl) sha256=efe0c3602e6e54521bc21c681930ce5568e2d11203de17400710b2b3ca2e4cb4
|
|
246
246
|
nokogiri (1.19.7-arm-linux-gnu) sha256=7fd1907125691aa89e838cc91161761c758b4e17bb32f0dd9b5515a82cc759af
|
|
@@ -279,7 +279,7 @@ CHECKSUMS
|
|
|
279
279
|
ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33
|
|
280
280
|
rubyzip (3.7.0) sha256=65c19294da75297a939006f3516deacc33185fbd721ff1954f7a231db6d3e121
|
|
281
281
|
strscan (3.1.8) sha256=aae2db611a225559f21ffbb71765c9a4e60fd262534a9ea84f4f11c7f32f679e
|
|
282
|
-
svg_conform (0.2.
|
|
282
|
+
svg_conform (0.2.9)
|
|
283
283
|
table_tennis (1.0.0) sha256=955f76ca4debd42ee88682af8d4554a74d533c89de4f1581bc37855b15faa956
|
|
284
284
|
thor (1.5.0) sha256=e3a9e55fe857e44859ce104a84675ab6e8cd59c650a49106a05f55f136425e73
|
|
285
285
|
unicode-display_width (3.3.0) sha256=4b7aa66a4b11db50f6f7e98411215cd0dd10eaecb665d36eec5bcacb3fa0b613
|
|
@@ -34,25 +34,25 @@ requirements:
|
|
|
34
34
|
attributes: ["id", "role", "shape-rendering", "text-rendering", "buffered-rendering", "visibility", "base", "lang", "class", "rel", "rev", "typeof", "content", "datatype", "resource", "about", "property", "space", "fill-rule"]
|
|
35
35
|
allowed_children: ["text"]
|
|
36
36
|
- tag: "path"
|
|
37
|
-
attributes: ["d", "pathLength", "stroke-miterlimit", "id", "role", "fill", "style", "transform", "font-size", "fill-rule", "base", "lang", "class", "rel", "rev", "typeof", "content", "datatype", "resource", "about", "property", "space", "marker-start", "marker-mid", "marker-end", "clip-path", "mask"]
|
|
37
|
+
attributes: ["d", "pathLength", "stroke-miterlimit", "id", "role", "fill", "style", "transform", "font-size", "fill-rule", "base", "lang", "class", "rel", "rev", "typeof", "content", "datatype", "resource", "about", "property", "space", "marker-start", "marker-mid", "marker-end", "clip-path", "clip-rule", "mask", "opacity"]
|
|
38
38
|
allowed_children: ["title", "desc"]
|
|
39
39
|
- tag: "rect"
|
|
40
|
-
attributes: ["x", "y", "width", "height", "rx", "ry", "stroke-miterlimit", "id", "role", "fill", "style", "transform", "fill-rule", "base", "lang", "class", "rel", "rev", "typeof", "content", "datatype", "resource", "about", "property", "space", "clip-path", "mask"]
|
|
40
|
+
attributes: ["x", "y", "width", "height", "rx", "ry", "stroke-miterlimit", "id", "role", "fill", "style", "transform", "fill-rule", "base", "lang", "class", "rel", "rev", "typeof", "content", "datatype", "resource", "about", "property", "space", "clip-path", "clip-rule", "mask", "opacity"]
|
|
41
41
|
allowed_children: ["title", "desc"]
|
|
42
42
|
- tag: "circle"
|
|
43
|
-
attributes: ["cx", "cy", "r", "id", "role", "fill", "style", "transform", "fill-rule", "base", "lang", "class", "rel", "rev", "typeof", "content", "datatype", "resource", "about", "property", "space", "clip-path", "mask"]
|
|
43
|
+
attributes: ["cx", "cy", "r", "id", "role", "fill", "style", "transform", "fill-rule", "base", "lang", "class", "rel", "rev", "typeof", "content", "datatype", "resource", "about", "property", "space", "clip-path", "clip-rule", "mask", "opacity"]
|
|
44
44
|
allowed_children: ["title", "desc"]
|
|
45
45
|
- tag: "line"
|
|
46
|
-
attributes: ["x1", "y1", "x2", "y2", "id", "role", "fill", "transform", "fill-rule", "base", "lang", "class", "rel", "rev", "typeof", "content", "datatype", "resource", "about", "property", "space", "marker-start", "marker-mid", "marker-end", "clip-path", "mask"]
|
|
46
|
+
attributes: ["x1", "y1", "x2", "y2", "id", "role", "fill", "transform", "fill-rule", "base", "lang", "class", "rel", "rev", "typeof", "content", "datatype", "resource", "about", "property", "space", "marker-start", "marker-mid", "marker-end", "clip-path", "clip-rule", "mask", "opacity"]
|
|
47
47
|
allowed_children: ["title", "desc"]
|
|
48
48
|
- tag: "ellipse"
|
|
49
|
-
attributes: ["cx", "cy", "rx", "ry", "id", "role", "fill", "style", "transform", "fill-rule", "base", "lang", "class", "rel", "rev", "typeof", "content", "datatype", "resource", "about", "property", "space", "clip-path", "mask"]
|
|
49
|
+
attributes: ["cx", "cy", "rx", "ry", "id", "role", "fill", "style", "transform", "fill-rule", "base", "lang", "class", "rel", "rev", "typeof", "content", "datatype", "resource", "about", "property", "space", "clip-path", "clip-rule", "mask", "opacity"]
|
|
50
50
|
allowed_children: ["title", "desc"]
|
|
51
51
|
- tag: "polyline"
|
|
52
|
-
attributes: ["points", "id", "role", "fill", "transform", "fill-rule", "base", "lang", "class", "rel", "rev", "typeof", "content", "datatype", "resource", "about", "property", "space", "marker-start", "marker-mid", "marker-end", "clip-path", "mask"]
|
|
52
|
+
attributes: ["points", "id", "role", "fill", "transform", "fill-rule", "base", "lang", "class", "rel", "rev", "typeof", "content", "datatype", "resource", "about", "property", "space", "marker-start", "marker-mid", "marker-end", "clip-path", "clip-rule", "mask", "opacity"]
|
|
53
53
|
allowed_children: ["title", "desc"]
|
|
54
54
|
- tag: "polygon"
|
|
55
|
-
attributes: ["points", "id", "role", "fill", "style", "transform", "fill-rule", "base", "lang", "class", "rel", "rev", "typeof", "content", "datatype", "resource", "about", "property", "space", "marker-start", "marker-mid", "marker-end", "clip-path", "mask"]
|
|
55
|
+
attributes: ["points", "id", "role", "fill", "style", "transform", "fill-rule", "base", "lang", "class", "rel", "rev", "typeof", "content", "datatype", "resource", "about", "property", "space", "marker-start", "marker-mid", "marker-end", "clip-path", "clip-rule", "mask", "opacity"]
|
|
56
56
|
allowed_children: ["title", "desc"]
|
|
57
57
|
- tag: "solidColor"
|
|
58
58
|
attributes: ["id", "role", "fill", "fill-rule", "base", "lang", "class", "rel", "rev", "typeof", "content", "datatype", "resource", "about", "property", "space", "clip-path", "mask"]
|
|
@@ -215,8 +215,16 @@ module SvgConform
|
|
|
215
215
|
def resolve_profile(profile)
|
|
216
216
|
case profile
|
|
217
217
|
when Symbol, String
|
|
218
|
-
|
|
219
|
-
|
|
218
|
+
# A path to a profile file wins over a bundled name: a custom
|
|
219
|
+
# profile ends in .yml and exists on disk, while bundled names
|
|
220
|
+
# never do (claricle/svg_conform#137 - the CLI previously
|
|
221
|
+
# concatenated such paths into config/profiles).
|
|
222
|
+
if profile.to_s.end_with?(".yml") && File.exist?(profile.to_s)
|
|
223
|
+
SvgConform::Profile.load_from_file(profile.to_s)
|
|
224
|
+
else
|
|
225
|
+
SvgConform::Profiles.get(profile) || raise(ProfileError,
|
|
226
|
+
"Unknown profile: #{profile}")
|
|
227
|
+
end
|
|
220
228
|
when Profile
|
|
221
229
|
profile
|
|
222
230
|
else
|
data/lib/svg_conform/version.rb
CHANGED
|
@@ -41,6 +41,10 @@ RSpec.describe "svg_conform.gemspec" do # rubocop:disable RSpec/DescribeClass
|
|
|
41
41
|
# guard (ci's words). Without this check, every post-release PR fails
|
|
42
42
|
# bundler 4's frozen install ("gemspecs for path gems changed") before
|
|
43
43
|
# anyone sees why.
|
|
44
|
+
# The release flow deletes the lock before bumping; the guard applies
|
|
45
|
+
# only where the committed lock exists (normal CI and dev trees).
|
|
46
|
+
skip "no committed lockfile (release context)" unless File.exist?("Gemfile.lock")
|
|
47
|
+
|
|
44
48
|
lock = File.read("Gemfile.lock")
|
|
45
49
|
path_version = lock[/\APATH\n remote: \.\n specs:\n svg_conform \(([^)]+)\)/, 1]
|
|
46
50
|
expect(path_version).to eq(SvgConform::VERSION)
|
|
@@ -6,6 +6,17 @@ require "spec_helper"
|
|
|
6
6
|
# per SVG (metanorma-pdfa#106).
|
|
7
7
|
METANORMA_PROFILE_CONTAINER_TAGS = %w[g a defs].freeze
|
|
8
8
|
METANORMA_PROFILE_CLIP_ATTRIBUTES = %w[clip-path mask].freeze
|
|
9
|
+
METANORMA_PROFILE_SHAPE_TAGS = %w[path rect circle ellipse line polyline polygon].freeze
|
|
10
|
+
METANORMA_PROFILE_SHAPE_QUALITY_ATTRIBUTES = %w[clip-rule opacity].freeze
|
|
11
|
+
METANORMA_PROFILE_SHAPE_GEOMETRY = {
|
|
12
|
+
"path" => 'd="M20,20 H50 V50"',
|
|
13
|
+
"rect" => 'x="20" y="20" width="30" height="30"',
|
|
14
|
+
"circle" => 'cx="35" cy="35" r="15"',
|
|
15
|
+
"ellipse" => 'cx="35" cy="35" rx="15" ry="10"',
|
|
16
|
+
"line" => 'x1="20" y1="35" x2="50" y2="35"',
|
|
17
|
+
"polyline" => 'points="20,35 35,20 50,35"',
|
|
18
|
+
"polygon" => 'points="20,35 35,20 50,35"',
|
|
19
|
+
}.freeze
|
|
9
20
|
|
|
10
21
|
RSpec.describe "Metanorma Profile" do
|
|
11
22
|
let(:metanorma_sample_profile_path) { "config/profiles/metanorma-sample.yml" }
|
|
@@ -111,6 +122,29 @@ RSpec.describe "Metanorma Profile" do
|
|
|
111
122
|
end
|
|
112
123
|
end
|
|
113
124
|
end
|
|
125
|
+
|
|
126
|
+
# claricle/svg_conform#136: drawing exports carry clip-rule and
|
|
127
|
+
# opacity on every graphics element, not only containers; the sample
|
|
128
|
+
# mirrors the owned baseline (metanorma-standoc#1362).
|
|
129
|
+
METANORMA_PROFILE_SHAPE_TAGS.each do |tag|
|
|
130
|
+
METANORMA_PROFILE_SHAPE_QUALITY_ATTRIBUTES.each do |attribute|
|
|
131
|
+
it "accepts #{attribute} on the shape #{tag}" do
|
|
132
|
+
svg = <<~SVG
|
|
133
|
+
<svg xmlns="http://www.w3.org/2000/svg" version="1.2" baseProfile="tiny" width="70" height="70" viewBox="0 0 70 70">
|
|
134
|
+
<clipPath id="cp">
|
|
135
|
+
<path d="M10,10 H60 V60"/>
|
|
136
|
+
</clipPath>
|
|
137
|
+
<g>
|
|
138
|
+
<#{tag} #{METANORMA_PROFILE_SHAPE_GEOMETRY[tag]} fill="red" #{attribute}="#{attribute == 'clip-rule' ? 'evenodd' : '0.85'}" clip-path="url(#cp)"/>
|
|
139
|
+
</g>
|
|
140
|
+
</svg>
|
|
141
|
+
SVG
|
|
142
|
+
result = validator.validate(svg, profile: profile)
|
|
143
|
+
attribute_errors = result.errors.select { |e| e.message.include?("'#{attribute}'") }
|
|
144
|
+
expect(attribute_errors).to be_empty
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
end
|
|
114
148
|
end
|
|
115
149
|
|
|
116
150
|
def shape_geometry(tag)
|
|
@@ -169,4 +169,40 @@ RSpec.describe SvgConform::Validator do
|
|
|
169
169
|
# Remediation should have been attempted
|
|
170
170
|
end
|
|
171
171
|
end
|
|
172
|
+
|
|
173
|
+
context "with a profile file path (claricle/svg_conform#137)" do
|
|
174
|
+
# the name lookup, so a profile file path was joined onto config/
|
|
175
|
+
# profiles and always failed. An existing .yml path now loads as a
|
|
176
|
+
# profile; anything else keeps the name semantics (including the
|
|
177
|
+
# not-found error listing available profiles).
|
|
178
|
+
describe "profile resolution from a file path" do
|
|
179
|
+
let(:profile_path) do
|
|
180
|
+
File.expand_path("../../config/profiles/metanorma-sample.yml", __dir__)
|
|
181
|
+
end
|
|
182
|
+
let(:tiny_svg) do
|
|
183
|
+
<<~SVG
|
|
184
|
+
<svg xmlns="http://www.w3.org/2000/svg" version="1.2" baseProfile="tiny" width="70" height="70" viewBox="0 0 70 70">
|
|
185
|
+
<rect x="20" y="20" width="30" height="30" fill="red"/>
|
|
186
|
+
</svg>
|
|
187
|
+
SVG
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
it "loads an existing .yml path instead of treating it as a name" do
|
|
191
|
+
validator = described_class.new(mode: :sax, profile: profile_path)
|
|
192
|
+
result = validator.validate(tiny_svg)
|
|
193
|
+
expect(result).to be_valid
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
it "keeps name semantics when the value is not a path on disk" do
|
|
197
|
+
validator = described_class.new(mode: :sax, profile: :"metanorma-sample")
|
|
198
|
+
expect(validator.validate(tiny_svg)).to be_valid
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
it "raises the not-found error, listing profiles, for a missing path" do
|
|
202
|
+
validator = described_class.new(mode: :sax, profile: "/tmp/definitely-missing-9f2.yml")
|
|
203
|
+
expect { validator.validate(tiny_svg) }
|
|
204
|
+
.to raise_error(SvgConform::ProfileError, /not found/i)
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
end
|
|
172
208
|
end
|
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.10
|
|
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-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: lens_core
|