svg_conform 0.2.8 → 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 +36 -36
- 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 +15 -0
- data/spec/svg_conform/profiles/metanorma_profile_spec.rb +90 -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)
|
|
@@ -40,21 +40,21 @@ GEM
|
|
|
40
40
|
json (3.1.0)
|
|
41
41
|
language_server-protocol (3.17.0.6)
|
|
42
42
|
lens_core (0.1.0)
|
|
43
|
-
leptris (1.9.
|
|
43
|
+
leptris (1.9.417.0-aarch64-linux)
|
|
44
44
|
ffi (~> 1.15)
|
|
45
|
-
leptris (1.9.
|
|
45
|
+
leptris (1.9.417.0-aarch64-linux-musl)
|
|
46
46
|
ffi (~> 1.15)
|
|
47
|
-
leptris (1.9.
|
|
47
|
+
leptris (1.9.417.0-arm-linux)
|
|
48
48
|
ffi (~> 1.15)
|
|
49
|
-
leptris (1.9.
|
|
49
|
+
leptris (1.9.417.0-arm-linux-musl)
|
|
50
50
|
ffi (~> 1.15)
|
|
51
|
-
leptris (1.9.
|
|
51
|
+
leptris (1.9.417.0-arm64-darwin)
|
|
52
52
|
ffi (~> 1.15)
|
|
53
|
-
leptris (1.9.
|
|
53
|
+
leptris (1.9.417.0-x86_64-darwin)
|
|
54
54
|
ffi (~> 1.15)
|
|
55
|
-
leptris (1.9.
|
|
55
|
+
leptris (1.9.417.0-x86_64-linux)
|
|
56
56
|
ffi (~> 1.15)
|
|
57
|
-
leptris (1.9.
|
|
57
|
+
leptris (1.9.417.0-x86_64-linux-musl)
|
|
58
58
|
ffi (~> 1.15)
|
|
59
59
|
lint_roller (1.1.0)
|
|
60
60
|
liquid (5.14.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)
|
|
@@ -161,21 +161,21 @@ GEM
|
|
|
161
161
|
unicode-name (1.15.1)
|
|
162
162
|
unicode-types (~> 1.12)
|
|
163
163
|
unicode-types (1.12.0)
|
|
164
|
-
yeptris (0.6.62.
|
|
164
|
+
yeptris (0.6.62.2-aarch64-linux)
|
|
165
165
|
ffi (~> 1.15)
|
|
166
|
-
yeptris (0.6.62.
|
|
166
|
+
yeptris (0.6.62.2-aarch64-linux-musl)
|
|
167
167
|
ffi (~> 1.15)
|
|
168
|
-
yeptris (0.6.62.
|
|
168
|
+
yeptris (0.6.62.2-arm-linux-eabihf)
|
|
169
169
|
ffi (~> 1.15)
|
|
170
|
-
yeptris (0.6.62.
|
|
170
|
+
yeptris (0.6.62.2-arm-linux-musleabihf)
|
|
171
171
|
ffi (~> 1.15)
|
|
172
|
-
yeptris (0.6.62.
|
|
172
|
+
yeptris (0.6.62.2-arm64-darwin)
|
|
173
173
|
ffi (~> 1.15)
|
|
174
|
-
yeptris (0.6.62.
|
|
174
|
+
yeptris (0.6.62.2-x86_64-darwin)
|
|
175
175
|
ffi (~> 1.15)
|
|
176
|
-
yeptris (0.6.62.
|
|
176
|
+
yeptris (0.6.62.2-x86_64-linux)
|
|
177
177
|
ffi (~> 1.15)
|
|
178
|
-
yeptris (0.6.62.
|
|
178
|
+
yeptris (0.6.62.2-x86_64-linux-musl)
|
|
179
179
|
ffi (~> 1.15)
|
|
180
180
|
|
|
181
181
|
PLATFORMS
|
|
@@ -228,19 +228,19 @@ CHECKSUMS
|
|
|
228
228
|
json (3.1.0) sha256=3ce7ccf8fde58960177a3a756c31f292a4c1e1dedee884547096a5b0604e3bd8
|
|
229
229
|
language_server-protocol (3.17.0.6) sha256=5ef2c0c138f8267e1bc631d3328347d354f96724b0af22f2c79516120443b7f0
|
|
230
230
|
lens_core (0.1.0) sha256=9481ce7721be1b9ddb08e0edde349775849614d40a78ff05ec5887de2aa9e2b6
|
|
231
|
-
leptris (1.9.
|
|
232
|
-
leptris (1.9.
|
|
233
|
-
leptris (1.9.
|
|
234
|
-
leptris (1.9.
|
|
235
|
-
leptris (1.9.
|
|
236
|
-
leptris (1.9.
|
|
237
|
-
leptris (1.9.
|
|
238
|
-
leptris (1.9.
|
|
231
|
+
leptris (1.9.417.0-aarch64-linux) sha256=dba75a31e71573b14f0c9247db99cbc7888c315738c435989aac1352c4a94e56
|
|
232
|
+
leptris (1.9.417.0-aarch64-linux-musl) sha256=011a67588f22d397a98d5a52fb32d40cdfd1456caaae68a5b646a11d851c8e44
|
|
233
|
+
leptris (1.9.417.0-arm-linux) sha256=6eff14e2d464cc95d7671833b485eaf5ceef45663ef3d7b0024d2c3dca414ca4
|
|
234
|
+
leptris (1.9.417.0-arm-linux-musl) sha256=b862cd5cf644f107a536f9c4a72e4346bcf221522c4a54747232155c4aa19862
|
|
235
|
+
leptris (1.9.417.0-arm64-darwin) sha256=cb40ee5c4f1b6c507a626e5a1fe35cf81265c470ff48ce7e6cb51336bc3572bc
|
|
236
|
+
leptris (1.9.417.0-x86_64-darwin) sha256=f48f3b8ea5e395633cf0925106e1196831a9b8666217d8b1289d7b9b865ddcd1
|
|
237
|
+
leptris (1.9.417.0-x86_64-linux) sha256=ea69ee2a4e4b6f22d85d890adf6b03a2e791f7cc7a9f267140c5d12b0c2bfe34
|
|
238
|
+
leptris (1.9.417.0-x86_64-linux-musl) sha256=ec4ba05b66afb308a770f842312cd3346b9117be0b0c0812d6be13851a1368a9
|
|
239
239
|
lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87
|
|
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,21 +279,21 @@ 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
|
|
286
286
|
unicode-emoji (4.3.0) sha256=11c02fa73290378c066bb0562cd4c87d8e1b706fbbe0059ca12746a4244de8ce
|
|
287
287
|
unicode-name (1.15.1) sha256=b8f2e3ca14bc24799f84a4f74d43a3612d02a051700d88bc6ca8e3bd53cda3f6
|
|
288
288
|
unicode-types (1.12.0) sha256=7e26a4352cecc2a50325a3793df834b732581ca9f25c5e29f46f3378934363f6
|
|
289
|
-
yeptris (0.6.62.
|
|
290
|
-
yeptris (0.6.62.
|
|
291
|
-
yeptris (0.6.62.
|
|
292
|
-
yeptris (0.6.62.
|
|
293
|
-
yeptris (0.6.62.
|
|
294
|
-
yeptris (0.6.62.
|
|
295
|
-
yeptris (0.6.62.
|
|
296
|
-
yeptris (0.6.62.
|
|
289
|
+
yeptris (0.6.62.2-aarch64-linux) sha256=9dd3bc757f24dad7ca0c939787be1014aa60a06e6457b0eab5688b8b2710631e
|
|
290
|
+
yeptris (0.6.62.2-aarch64-linux-musl) sha256=0571ebfe60beefaa43bfbb7761e3116d62f14bc3cfbfe526b64bb06c536cb327
|
|
291
|
+
yeptris (0.6.62.2-arm-linux-eabihf) sha256=0390680ed96caa7d86de4adeb8af6f9b519c3bc7f64e32b6ae9bcef1c1a6a36e
|
|
292
|
+
yeptris (0.6.62.2-arm-linux-musleabihf) sha256=54f2fe3926320d5f2fdf25d582408f23557cb0b4e5cc537dc70aa1ba6ebfd745
|
|
293
|
+
yeptris (0.6.62.2-arm64-darwin) sha256=aaf5669775735ac1e26c55d6087348976534fbccd8b04b4abf7f73016173dc05
|
|
294
|
+
yeptris (0.6.62.2-x86_64-darwin) sha256=24fd9cdfb1eed94349f8db421a8563b5f2979d3a48b609959977ec4c8099a0d3
|
|
295
|
+
yeptris (0.6.62.2-x86_64-linux) sha256=84ff1b20ce25ae0dd2ec65ea1abc14d881310ab0efef65ddc89e1384cd50a745
|
|
296
|
+
yeptris (0.6.62.2-x86_64-linux-musl) sha256=dd093c8ae7699fd3040fb006be34833412a207edf58b4885ec4f1de8eb4b271b
|
|
297
297
|
|
|
298
298
|
BUNDLED WITH
|
|
299
299
|
4.0.24
|
|
@@ -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", "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", "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", "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", "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
|
@@ -34,4 +34,19 @@ RSpec.describe "svg_conform.gemspec" do # rubocop:disable RSpec/DescribeClass
|
|
|
34
34
|
expect(SvgConform).to respond_to(:lens_core_available?)
|
|
35
35
|
expect(SvgConform.lens_core_available?).to be_truthy.or be_falsey
|
|
36
36
|
end
|
|
37
|
+
|
|
38
|
+
it "keeps the committed lockfile in sync with the gem version" do
|
|
39
|
+
# The release flow (metanorma/ci rubygems-release) deletes the lock and
|
|
40
|
+
# bumps version.rb without restoring it: staleness is this repo's own
|
|
41
|
+
# guard (ci's words). Without this check, every post-release PR fails
|
|
42
|
+
# bundler 4's frozen install ("gemspecs for path gems changed") before
|
|
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
|
+
|
|
48
|
+
lock = File.read("Gemfile.lock")
|
|
49
|
+
path_version = lock[/\APATH\n remote: \.\n specs:\n svg_conform \(([^)]+)\)/, 1]
|
|
50
|
+
expect(path_version).to eq(SvgConform::VERSION)
|
|
51
|
+
end
|
|
37
52
|
end
|
|
@@ -6,10 +6,26 @@ 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" }
|
|
12
23
|
|
|
24
|
+
let(:validator) { SvgConform::Validator.new(mode: :sax, profile: profile) }
|
|
25
|
+
let(:profile) do
|
|
26
|
+
SvgConform::Profile.load_from_file("config/profiles/metanorma-sample.yml")
|
|
27
|
+
end
|
|
28
|
+
|
|
13
29
|
describe "profile loading" do
|
|
14
30
|
it "loads the Metanorma profile successfully" do
|
|
15
31
|
profile = SvgConform::Profile.load_from_file(metanorma_sample_profile_path)
|
|
@@ -106,5 +122,79 @@ RSpec.describe "Metanorma Profile" do
|
|
|
106
122
|
end
|
|
107
123
|
end
|
|
108
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
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def shape_geometry(tag)
|
|
151
|
+
case tag
|
|
152
|
+
when "path" then 'd="M2,6 H38"'
|
|
153
|
+
when "line" then 'x1="2" y1="6" x2="38" y2="6"'
|
|
154
|
+
else 'points="2,6 20,6 38,6"'
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def marker_svg(shape_attrs)
|
|
159
|
+
<<~SVG
|
|
160
|
+
<svg xmlns="http://www.w3.org/2000/svg" version="1.2" baseProfile="tiny" width="40" height="12" viewBox="0 0 40 12">
|
|
161
|
+
<defs>
|
|
162
|
+
<marker id="a" markerWidth="4" markerHeight="4" refX="2" refY="2" orient="auto">
|
|
163
|
+
<path d="M0,0 L4,2 L0,4"/>
|
|
164
|
+
</marker>
|
|
165
|
+
</defs>
|
|
166
|
+
<g>#{shape_attrs}</g>
|
|
167
|
+
</svg>
|
|
168
|
+
SVG
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
# claricle/svg_conform#128: the profile listed the marker element but
|
|
172
|
+
# none of the marker presentation attributes on the shapes, so
|
|
173
|
+
# marker-end="url(...)" failed while the same marker in a style
|
|
174
|
+
# attribute passed.
|
|
175
|
+
%w[path line polyline polygon].each do |tag|
|
|
176
|
+
it "allows marker-end on #{tag}" do
|
|
177
|
+
svg = marker_svg(
|
|
178
|
+
%(<#{tag} #{shape_geometry(tag)} marker-end="url(#a)"/>),
|
|
179
|
+
)
|
|
180
|
+
result = validator.validate(svg, profile: profile)
|
|
181
|
+
attribute_errors = result.errors.select { |e| e.message.include?("marker-end") }
|
|
182
|
+
expect(attribute_errors).to be_empty
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
it "allows marker-start and marker-mid on #{tag}" do
|
|
186
|
+
svg = marker_svg(
|
|
187
|
+
%(<#{tag} #{shape_geometry(tag)} marker-start="url(#a)" marker-mid="url(#a)" marker-end="url(#a)"/>),
|
|
188
|
+
)
|
|
189
|
+
result = validator.validate(svg, profile: profile)
|
|
190
|
+
attribute_errors = result.errors.select { |e| e.message.include?("marker") }
|
|
191
|
+
expect(attribute_errors).to be_empty
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
it "still rejects marker attributes on rect, where SVG does not define them" do
|
|
196
|
+
svg = marker_svg(%(<rect x="2" y="2" width="36" height="8" marker-end="url(#a)"/>))
|
|
197
|
+
result = validator.validate(svg, profile: profile)
|
|
198
|
+
expect(result.errors.map(&:message).join).to include("marker-end")
|
|
109
199
|
end
|
|
110
200
|
end
|
|
@@ -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
|