prawn-svg 0.40.3 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a722b87f2dac916a1fc7fce607cb246425548bb262cb26238162aec7544fe68
4
- data.tar.gz: 9ee7ce4ea0644038f0f3d6ab621cdab1c229c1d622cd10fd9109a4ae3527905d
3
+ metadata.gz: 37f7a560005c2271a73fe47fd533915d785ac1752a3325f501d554915acf3e96
4
+ data.tar.gz: b9e16e8a36bcc9bf583509804a14544f9f905be0ce8e9416be73f5990c232e12
5
5
  SHA512:
6
- metadata.gz: 727bbade7ba666cb469c7f678c877c7a430dd7e4cd595dea148406e69043f39a7682f4a857f0806e1ad73ea2695624a2a35a40bbbfece7792ae66ba50d1ec497
7
- data.tar.gz: eedab0c67b6c0c4e3d3d5557daa7ca56b8ba61b8c48a93289654679775749056db00b3b9abd219aa7dc734c900889c3f9cffb23138ddfc7a37a7da25b9936a1a
6
+ metadata.gz: dbc3cea5b1574d57feac632dbe7b18243c4071900e8f410494cb00baf52eec6624e2661b58df3038b859dc1ab3147a387bf046b41040ea508068ad58ad6fd96d
7
+ data.tar.gz: 7e39ddd55b35c633c03b2a9d8b791789090fa813518816986dc6547e22a06288a9ad254d5398a0b4fbbfa0ab730a46454ffeefb912f7f7dafb08ab4b8b1480ab
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'http://rubygems.org'
1
+ source 'https://rubygems.org'
2
2
 
3
3
  # Declare your gem's dependencies in prawn-svg.gemspec.
4
4
  # Bundler will treat runtime dependencies like base dependencies, and
data/Gemfile.lock CHANGED
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- prawn-svg (0.40.3)
4
+ prawn-svg (0.40.4)
5
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: http://rubygems.org/
11
+ remote: https://rubygems.org/
12
12
  specs:
13
13
  addressable (2.9.0)
14
14
  public_suffix (>= 2.0.2, < 8.0)
@@ -1,6 +1,7 @@
1
1
  class Prawn::SVG::Elements::Anchor < Prawn::SVG::Elements::Base
2
2
  def parse
3
- state.anchor_href = href_attribute
3
+ href = href_attribute
4
+ state.anchor_href = href unless href.nil? || href.strip.empty?
4
5
  end
5
6
 
6
7
  def container?
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Prawn
2
2
  module SVG
3
- VERSION = '0.40.3'.freeze
3
+ VERSION = '0.40.4'.freeze
4
4
  end
5
5
  end
@@ -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.3
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-06-30 00:00:00.000000000 Z
11
+ date: 2026-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: css_parser
@@ -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