prawn-svg 0.40.2 → 0.40.4
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 +1 -1
- data/Gemfile.lock +6 -4
- data/lib/prawn/svg/elements/anchor.rb +2 -1
- data/lib/prawn/svg/renderer.rb +7 -0
- data/lib/prawn/svg/version.rb +1 -1
- data/prawn-svg.gemspec +1 -1
- data/spec/prawn/svg/elements/anchor_spec.rb +43 -0
- data/spec/prawn/svg/interface_spec.rb +9 -0
- metadata +7 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 37f7a560005c2271a73fe47fd533915d785ac1752a3325f501d554915acf3e96
|
|
4
|
+
data.tar.gz: b9e16e8a36bcc9bf583509804a14544f9f905be0ce8e9416be73f5990c232e12
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dbc3cea5b1574d57feac632dbe7b18243c4071900e8f410494cb00baf52eec6624e2661b58df3038b859dc1ab3147a387bf046b41040ea508068ad58ad6fd96d
|
|
7
|
+
data.tar.gz: 7e39ddd55b35c633c03b2a9d8b791789090fa813518816986dc6547e22a06288a9ad254d5398a0b4fbbfa0ab730a46454ffeefb912f7f7dafb08ab4b8b1480ab
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
prawn-svg (0.40.
|
|
5
|
-
css_parser (>= 1.
|
|
4
|
+
prawn-svg (0.40.4)
|
|
5
|
+
css_parser (>= 1.17.1, < 4)
|
|
6
6
|
matrix (~> 0.4.2)
|
|
7
7
|
prawn (>= 0.11.1, < 3)
|
|
8
8
|
rexml (>= 3.4.2, < 4)
|
|
9
9
|
|
|
10
10
|
GEM
|
|
11
|
-
remote:
|
|
11
|
+
remote: https://rubygems.org/
|
|
12
12
|
specs:
|
|
13
13
|
addressable (2.9.0)
|
|
14
14
|
public_suffix (>= 2.0.2, < 8.0)
|
|
15
15
|
ast (2.4.2)
|
|
16
16
|
bigdecimal (3.1.8)
|
|
17
|
-
css_parser (
|
|
17
|
+
css_parser (3.0.0)
|
|
18
18
|
addressable
|
|
19
|
+
ssrf_filter (~> 1.5)
|
|
19
20
|
diff-lcs (1.5.1)
|
|
20
21
|
json (2.7.2)
|
|
21
22
|
language_server-protocol (3.17.0.3)
|
|
@@ -62,6 +63,7 @@ GEM
|
|
|
62
63
|
rubocop-ast (1.31.3)
|
|
63
64
|
parser (>= 3.3.1.0)
|
|
64
65
|
ruby-progressbar (1.13.0)
|
|
66
|
+
ssrf_filter (1.5.0)
|
|
65
67
|
ttfunk (1.8.0)
|
|
66
68
|
bigdecimal (~> 3.1)
|
|
67
69
|
unicode-display_width (2.5.0)
|
data/lib/prawn/svg/renderer.rb
CHANGED
|
@@ -143,6 +143,13 @@ module Prawn
|
|
|
143
143
|
arguments[4] += left - ((left * arguments[0]) + (top * arguments[2]))
|
|
144
144
|
arguments[5] += top - ((left * arguments[1]) + (top * arguments[3]))
|
|
145
145
|
|
|
146
|
+
when 'curve_to'
|
|
147
|
+
# Prawn appends the destination to bounds, mutating bounds.
|
|
148
|
+
# Preserve it for path replay by passing a .dup instead.
|
|
149
|
+
# See: https://github.com/prawnpdf/prawn/issues/1401
|
|
150
|
+
prawn.curve_to(arguments.first, **kwarguments.merge(bounds: kwarguments[:bounds].dup))
|
|
151
|
+
yield
|
|
152
|
+
|
|
146
153
|
when 'miter_limit'
|
|
147
154
|
prawn.add_content("#{arguments.first} M")
|
|
148
155
|
yield
|
data/lib/prawn/svg/version.rb
CHANGED
data/prawn-svg.gemspec
CHANGED
|
@@ -19,7 +19,7 @@ Gem::Specification.new do |gem|
|
|
|
19
19
|
|
|
20
20
|
gem.required_ruby_version = '>= 2.7.0'
|
|
21
21
|
|
|
22
|
-
gem.add_dependency 'css_parser', '>= 1.
|
|
22
|
+
gem.add_dependency 'css_parser', '>= 1.17.1', '< 4'
|
|
23
23
|
gem.add_dependency 'matrix', '~> 0.4.2'
|
|
24
24
|
gem.add_dependency 'prawn', '>= 0.11.1', '< 3'
|
|
25
25
|
gem.add_dependency 'rexml', '>= 3.4.2', '< 4'
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Prawn::SVG::Elements::Anchor do
|
|
4
|
+
let(:document) do
|
|
5
|
+
Prawn::SVG::Document.new(svg, [800, 600], { enable_web_requests: false },
|
|
6
|
+
font_registry: Prawn::SVG::FontRegistry.new('Helvetica' => { normal: nil }))
|
|
7
|
+
end
|
|
8
|
+
let(:element) { Prawn::SVG::Elements::Anchor.new(document, document.root.elements.first, [], fake_state) }
|
|
9
|
+
|
|
10
|
+
before { element.process }
|
|
11
|
+
|
|
12
|
+
context 'with a non-empty href' do
|
|
13
|
+
let(:svg) { '<svg><a href="http://example.com"><rect width="10" height="10"/></a></svg>' }
|
|
14
|
+
|
|
15
|
+
it 'sets the anchor_href and adds a link annotation' do
|
|
16
|
+
expect(flatten_calls(element.base_calls).map(&:first)).to include('svg:add_link')
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
context 'with an empty href' do
|
|
21
|
+
let(:svg) { '<svg><a href=""><rect width="10" height="10"/></a></svg>' }
|
|
22
|
+
|
|
23
|
+
it 'does not add a link annotation' do
|
|
24
|
+
expect(flatten_calls(element.base_calls).map(&:first)).not_to include('svg:add_link')
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
context 'with a whitespace-only href' do
|
|
29
|
+
let(:svg) { '<svg><a href=" "><rect width="10" height="10"/></a></svg>' }
|
|
30
|
+
|
|
31
|
+
it 'does not add a link annotation' do
|
|
32
|
+
expect(flatten_calls(element.base_calls).map(&:first)).not_to include('svg:add_link')
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
context 'with no href' do
|
|
37
|
+
let(:svg) { '<svg><a><rect width="10" height="10"/></a></svg>' }
|
|
38
|
+
|
|
39
|
+
it 'does not add a link annotation' do
|
|
40
|
+
expect(flatten_calls(element.base_calls).map(&:first)).not_to include('svg:add_link')
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -22,6 +22,15 @@ describe Prawn::SVG::Interface do
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
describe '#draw' do
|
|
25
|
+
it 'emits six operands for both fill and stroke Bezier curves' do
|
|
26
|
+
pdf = Prawn::Document.new
|
|
27
|
+
pdf.svg('<svg width="100" height="100"><path d="M 10 10 C 20 20 30 30 40 10 Z" fill="red" stroke="black"/></svg>',
|
|
28
|
+
enable_web_requests: false)
|
|
29
|
+
|
|
30
|
+
curves = pdf.state.page.content.stream.filtered_stream.lines.grep(/ c$/)
|
|
31
|
+
expect(curves.map { |line| line.split.length - 1 }).to eq [6, 6]
|
|
32
|
+
end
|
|
33
|
+
|
|
25
34
|
context 'when the sizing object indicates the sizes are invalid' do
|
|
26
35
|
let(:interface) { Prawn::SVG::Interface.new('<svg width="0"></svg>', prawn, { enable_web_requests: false }) }
|
|
27
36
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: prawn-svg
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.40.
|
|
4
|
+
version: 0.40.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mog Nesbitt
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-09-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: css_parser
|
|
@@ -16,20 +16,20 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
19
|
+
version: 1.17.1
|
|
20
20
|
- - "<"
|
|
21
21
|
- !ruby/object:Gem::Version
|
|
22
|
-
version: '
|
|
22
|
+
version: '4'
|
|
23
23
|
type: :runtime
|
|
24
24
|
prerelease: false
|
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
26
26
|
requirements:
|
|
27
27
|
- - ">="
|
|
28
28
|
- !ruby/object:Gem::Version
|
|
29
|
-
version:
|
|
29
|
+
version: 1.17.1
|
|
30
30
|
- - "<"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '
|
|
32
|
+
version: '4'
|
|
33
33
|
- !ruby/object:Gem::Dependency
|
|
34
34
|
name: matrix
|
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -197,6 +197,7 @@ files:
|
|
|
197
197
|
- spec/prawn/svg/css/stylesheets_spec.rb
|
|
198
198
|
- spec/prawn/svg/css/values_parser_spec.rb
|
|
199
199
|
- spec/prawn/svg/document_spec.rb
|
|
200
|
+
- spec/prawn/svg/elements/anchor_spec.rb
|
|
200
201
|
- spec/prawn/svg/elements/base_spec.rb
|
|
201
202
|
- spec/prawn/svg/elements/gradient_spec.rb
|
|
202
203
|
- spec/prawn/svg/elements/image_spec.rb
|