prawn-svg 0.31.0 → 0.32.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ed78a64dc94709fc5e53f1d6f521f93e3bf41196c29dde616c6139743c9c889
4
- data.tar.gz: 7a0a5683370d3478e8b9717069e0f4012337aaf6250106065dfd5ad9b4458a91
3
+ metadata.gz: d054ded3422dc4cd1cb870dc09549c0a82c1e2813e314565c7a3aec70d95d188
4
+ data.tar.gz: 123a00b97f78f284a8e11fad37fed42cbec06d678675ec15ff7dafbcfe6505d5
5
5
  SHA512:
6
- metadata.gz: a58fd3f4508d486b3632f2e337f5e2fe97ef8c2baeeeda9b4f53f816ff18eb10b3e8879c98ea10c645becb29c8351a7addc6867c22abfeda77a7edf654607f44
7
- data.tar.gz: 3bdbbc06f25405d3f51de30e81c39406f7ccf535e507bb36b43df3939d1a4931b763cb5308bde72674ab3f2ffcb55171b958f93a3b603bf5cf17a1bbd24d44b4
6
+ metadata.gz: 4ece284ced16e7b6f4d7562c17a97780375f4e255eb4199d489cfb1fa473dc1f65e6b9fa48894079f0756b42a749cc58f34c00507e19ccdfddab55723c82311d
7
+ data.tar.gz: 8826f6f457372cc7df38869e6448974f5731fdee1040bca44b8446b71c57e0713340481a3400705c8fd11ec5d13959dcd99f24a0fe8820c89a37ca725545656c
@@ -0,0 +1,18 @@
1
+ name: test
2
+ on: [push, pull_request]
3
+ jobs:
4
+ rake:
5
+ runs-on: ubuntu-latest
6
+ strategy:
7
+ fail-fast: false
8
+ matrix:
9
+ ruby: [2.3, 2.4, 2.5, 2.6, 2.7, '3.0']
10
+ steps:
11
+ - uses: actions/checkout@v2
12
+ - name: Set up Ruby
13
+ uses: ruby/setup-ruby@v1
14
+ with:
15
+ bundler-cache: true
16
+ ruby-version: ${{ matrix.ruby }}
17
+ - name: Run tests
18
+ run: bundle exec rake
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # prawn-svg
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/prawn-svg.svg)](https://badge.fury.io/rb/prawn-svg)
4
- [![Build Status](https://travis-ci.org/mogest/prawn-svg.svg?branch=master)](https://travis-ci.org/mogest/prawn-svg)
4
+ ![Build Status](https://github.com/mogest/prawn-svg/actions/workflows/test.yml/badge.svg?branch=master)
5
5
 
6
6
  An SVG renderer for the Prawn PDF library.
7
7
 
@@ -10,7 +10,7 @@ This will take an SVG document as input and render it into your PDF. Find out m
10
10
  http://github.com/prawnpdf/prawn
11
11
 
12
12
  prawn-svg is compatible with all versions of Prawn from 0.11.1 onwards, including the 1.x and 2.x series.
13
- The minimum Ruby version required is 2.1.0.
13
+ The minimum Ruby version required is 2.3.0.
14
14
 
15
15
  ## Using prawn-svg
16
16
 
@@ -91,12 +91,12 @@ class Prawn::SVG::Elements::Base
91
91
  parse_xml_space_attribute
92
92
  end
93
93
 
94
- def add_call(name, *arguments)
95
- @calls << [name.to_s, arguments, []]
94
+ def add_call(name, *arguments, **kwarguments)
95
+ @calls << [name.to_s, arguments, kwarguments, []]
96
96
  end
97
97
 
98
- def add_call_and_enter(name, *arguments)
99
- @calls << [name.to_s, arguments, []]
98
+ def add_call_and_enter(name, *arguments, **kwarguments)
99
+ @calls << [name.to_s, arguments, kwarguments, []]
100
100
  @calls = @calls.last.last
101
101
  end
102
102
 
@@ -168,7 +168,7 @@ class Prawn::SVG::Elements::Base
168
168
  command = stroke ? 'fill_and_stroke' : 'fill'
169
169
 
170
170
  if computed_properties.fill_rule == 'evenodd'
171
- add_call_and_enter(command, {fill_rule: :even_odd})
171
+ add_call_and_enter(command, fill_rule: :even_odd)
172
172
  else
173
173
  add_call_and_enter(command)
174
174
  end
@@ -12,7 +12,7 @@ module Prawn::SVG::Elements::CallDuplicator
12
12
  end
13
13
 
14
14
  def duplicate_call(call)
15
- [call[0], duplicate_array(call[1]), duplicate_calls(call[2])]
15
+ [call[0], duplicate_array(call[1]), duplicate_hash(call[2]), duplicate_calls(call[3])]
16
16
  end
17
17
 
18
18
  def duplicate_array(array)
@@ -146,10 +146,10 @@ class Prawn::SVG::Elements::TextComponent < Prawn::SVG::Elements::DepthFirstBase
146
146
  end
147
147
 
148
148
  if remaining
149
- add_call 'draw_text', text[0..0], opts.dup
149
+ add_call 'draw_text', text[0..0], **opts.dup
150
150
  text = text[1..-1]
151
151
  else
152
- add_call 'draw_text', text, opts.dup
152
+ add_call 'draw_text', text, **opts.dup
153
153
 
154
154
  # we can get to this path with rotations still pending
155
155
  # solve this by shifting them out by the number of
@@ -109,10 +109,10 @@ module Prawn
109
109
  end
110
110
 
111
111
  def issue_prawn_command(prawn, calls)
112
- calls.each do |call, arguments, children|
112
+ calls.each do |call, arguments, kwarguments, children|
113
113
  skip = false
114
114
 
115
- rewrite_call_arguments(prawn, call, arguments) do
115
+ rewrite_call_arguments(prawn, call, arguments, kwarguments) do
116
116
  issue_prawn_command(prawn, children) if children.any?
117
117
  skip = true
118
118
  end
@@ -120,21 +120,29 @@ module Prawn
120
120
  if skip
121
121
  # the call has been overridden
122
122
  elsif children.empty? && call != 'transparent' # some prawn calls complain if they aren't supplied a block
123
- prawn.send(call, *arguments)
123
+ if RUBY_VERSION >= '2.7' || !kwarguments.empty?
124
+ prawn.send(call, *arguments, **kwarguments)
125
+ else
126
+ prawn.send(call, *arguments)
127
+ end
124
128
  else
125
- prawn.send(call, *arguments, &proc_creator(prawn, children))
129
+ if RUBY_VERSION >= '2.7' || !kwarguments.empty?
130
+ prawn.send(call, *arguments, **kwarguments, &proc_creator(prawn, children))
131
+ else
132
+ prawn.send(call, *arguments, &proc_creator(prawn, children))
133
+ end
126
134
  end
127
135
  end
128
136
  end
129
137
 
130
- def rewrite_call_arguments(prawn, call, arguments)
138
+ def rewrite_call_arguments(prawn, call, arguments, kwarguments)
131
139
  case call
132
140
  when 'text_group'
133
141
  @cursor = [0, document.sizing.output_height]
134
142
  yield
135
143
 
136
144
  when 'draw_text'
137
- text, options = arguments
145
+ text, options = arguments.first, kwarguments
138
146
 
139
147
  at = options.fetch(:at)
140
148
 
@@ -208,7 +216,7 @@ module Prawn
208
216
  # prawn (as at 2.0.1 anyway) uses 'b' for its fill_and_stroke. 'b' is 'h' (closepath) + 'B', and we
209
217
  # never want closepath to be automatically run as it stuffs up many drawing operations, such as dashes
210
218
  # and line caps, and makes paths close that we didn't ask to be closed when fill is specified.
211
- even_odd = arguments[0].is_a?(Hash) && arguments[0][:fill_rule] == :even_odd
219
+ even_odd = kwarguments[:fill_rule] == :even_odd
212
220
  content = even_odd ? 'B*' : 'B'
213
221
  prawn.add_content content
214
222
 
@@ -1,5 +1,5 @@
1
1
  module Prawn
2
2
  module SVG
3
- VERSION = '0.31.0'
3
+ VERSION = '0.32.0'
4
4
  end
5
5
  end
data/prawn-svg.gemspec CHANGED
@@ -17,10 +17,11 @@ Gem::Specification.new do |gem|
17
17
  gem.name = "prawn-svg"
18
18
  gem.require_paths = ["lib"]
19
19
 
20
- gem.required_ruby_version = '>= 2.1.0'
20
+ gem.required_ruby_version = '>= 2.3.0'
21
21
 
22
22
  gem.add_runtime_dependency "prawn", ">= 0.11.1", "< 3"
23
23
  gem.add_runtime_dependency "css_parser", "~> 1.6"
24
+ gem.add_runtime_dependency "rexml", "~> 3.2"
24
25
  gem.add_development_dependency "rspec", "~> 3.0"
25
26
  gem.add_development_dependency "rake", "~> 13.0"
26
27
  end
@@ -28,34 +28,34 @@ describe "Integration test" do
28
28
  element.process
29
29
 
30
30
  expect(element.calls).to eq [
31
- ["fill_color", ["000000"], []],
32
- ["transformation_matrix", [1, 0, 0, 1, 0, 0], []],
33
- ["transformation_matrix", [1, 0, 0, 1, 0, 0], []],
34
- ["save", [], []], ["restore", [], []],
35
- ["save", [], []],
36
- ["fill_color", ["0000ff"], []],
37
- ["fill", [], [
38
- ["rectangle", [[0.0, 200.0], 10.0, 10.0], []]
31
+ ["fill_color", ["000000"], {}, []],
32
+ ["transformation_matrix", [1, 0, 0, 1, 0, 0], {}, []],
33
+ ["transformation_matrix", [1, 0, 0, 1, 0, 0], {}, []],
34
+ ["save", [], {}, []], ["restore", [], {}, []],
35
+ ["save", [], {}, []],
36
+ ["fill_color", ["0000ff"], {}, []],
37
+ ["fill", [], {}, [
38
+ ["rectangle", [[0.0, 200.0], 10.0, 10.0], {}, []]
39
39
  ]],
40
- ["restore", [], []],
41
- ["save", [], []],
42
- ["fill_color", ["008000"], []],
43
- ["fill", [], [
44
- ["rectangle", [[10.0, 200.0], 10.0, 10.0], []]
40
+ ["restore", [], {}, []],
41
+ ["save", [], {}, []],
42
+ ["fill_color", ["008000"], {}, []],
43
+ ["fill", [], {}, [
44
+ ["rectangle", [[10.0, 200.0], 10.0, 10.0], {}, []]
45
45
  ]],
46
- ["restore", [], []],
47
- ["save", [], []],
48
- ["fill_color", ["ff0000"], []],
49
- ["fill", [], [
50
- ["rectangle", [[20.0, 200.0], 10.0, 10.0], []]
46
+ ["restore", [], {}, []],
47
+ ["save", [], {}, []],
48
+ ["fill_color", ["ff0000"], {}, []],
49
+ ["fill", [], {}, [
50
+ ["rectangle", [[20.0, 200.0], 10.0, 10.0], {}, []]
51
51
  ]],
52
- ["restore", [], []],
53
- ["save", [], []],
54
- ["fill_color", ["ffff00"], []],
55
- ["fill", [], [
56
- ["rectangle", [[30.0, 200.0], 10.0, 10.0], []]
52
+ ["restore", [], {}, []],
53
+ ["save", [], {}, []],
54
+ ["fill_color", ["ffff00"], {}, []],
55
+ ["fill", [], {}, [
56
+ ["rectangle", [[30.0, 200.0], 10.0, 10.0], {}, []]
57
57
  ]],
58
- ["restore", [], []]
58
+ ["restore", [], {}, []]
59
59
  ]
60
60
  end
61
61
  end
@@ -68,25 +68,7 @@ RSpec.describe Prawn::SVG::CSS::Stylesheets do
68
68
  [4, [["fill", "#ff0000", false], ["fill", "#330000", false], ["fill", "#440000", false], ["fill", "#00ff00", false]]],
69
69
  ]
70
70
 
71
- #
72
- # Under ruby < 2.6, a bug in REXML causes the /following-sibling selector to
73
- # only pick the first matching sibling. This means the + CSS combinator behaves
74
- # incorrectly in the following example:
75
- #
76
- # <a>
77
- # <b a="1" />
78
- # <b a="2" />
79
- # <b a="3" />
80
- # </a>
81
- #
82
- # The css selector `a b + b` will only pick the second <b>, whereas it should
83
- # pick both the second and third <b> elements.
84
- #
85
- if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.6.0')
86
- expected << [5, [["fill", "#ff0000", false], ["fill", "#330000", false], ["fill", "#330000", false], ["fill", "#00ff00", false]]]
87
- else
88
- expected << [5, [["fill", "#ff0000", false], ["fill", "#330000", false], ["fill", "#330000", false], ["fill", "#440000", false], ["fill", "#00ff00", false]]]
89
- end
71
+ expected << [5, [["fill", "#ff0000", false], ["fill", "#330000", false], ["fill", "#330000", false], ["fill", "#440000", false], ["fill", "#00ff00", false]]]
90
72
 
91
73
  expected.concat [
92
74
  [6, [["fill", "#ff0000", false], ["fill", "#441234", false], ["fill", "#0000ff", false]]],
@@ -32,12 +32,12 @@ describe Prawn::SVG::Elements::Base do
32
32
  it "appends the relevant calls" do
33
33
  element.process
34
34
  expect(element.base_calls).to eq [
35
- ["transformation_matrix", [2, 0, 0, 2, 0, 0], [
36
- ["transparent", [0.5, 1], [
37
- ["fill_color", ["ff0000"], []],
38
- ["stroke_color", ["0000ff"], []],
39
- ["line_width", [5.0], []],
40
- ["fill_and_stroke", [], []]
35
+ ["transformation_matrix", [2, 0, 0, 2, 0, 0], {}, [
36
+ ["transparent", [0.5, 1], {}, [
37
+ ["fill_color", ["ff0000"], {}, []],
38
+ ["stroke_color", ["0000ff"], {}, []],
39
+ ["line_width", [5.0], {}, []],
40
+ ["fill_and_stroke", [], {}, []]
41
41
  ]]
42
42
  ]]
43
43
  ]
@@ -50,37 +50,37 @@ describe Prawn::SVG::Elements::Base do
50
50
 
51
51
  context "with neither fill nor stroke" do
52
52
  let(:svg) { '<rect style="fill: none;"></rect>' }
53
- it { is_expected.to eq ['end_path', [], []] }
53
+ it { is_expected.to eq ['end_path', [], {}, []] }
54
54
  end
55
55
 
56
56
  context "with a fill only" do
57
57
  let(:svg) { '<rect style="fill: black;"></rect>' }
58
- it { is_expected.to eq ['fill', [], []] }
58
+ it { is_expected.to eq ['fill', [], {}, []] }
59
59
  end
60
60
 
61
61
  context "with a stroke only" do
62
62
  let(:svg) { '<rect style="fill: none; stroke: black;"></rect>' }
63
- it { is_expected.to eq ['stroke', [], []] }
63
+ it { is_expected.to eq ['stroke', [], {}, []] }
64
64
  end
65
65
 
66
66
  context "with fill and stroke" do
67
67
  let(:svg) { '<rect style="fill: black; stroke: black;"></rect>' }
68
- it { is_expected.to eq ['fill_and_stroke', [], []] }
68
+ it { is_expected.to eq ['fill_and_stroke', [], {}, []] }
69
69
  end
70
70
 
71
71
  context "with fill with evenodd fill rule" do
72
72
  let(:svg) { '<rect style="fill: black; fill-rule: evenodd;"></rect>' }
73
- it { is_expected.to eq ['fill', [{fill_rule: :even_odd}], []] }
73
+ it { is_expected.to eq ['fill', [], {fill_rule: :even_odd}, []] }
74
74
  end
75
75
  end
76
76
 
77
77
  it "appends calls to the parent element" do
78
78
  expect(element).to receive(:apply) do
79
- element.send :add_call, "test", "argument"
79
+ element.send :add_call, "test", "argument", kw: 'argument'
80
80
  end
81
81
 
82
82
  element.process
83
- expect(element.parent_calls).to eq [["fill", [], [["test", ["argument"], []]]]]
83
+ expect(element.parent_calls).to eq [["fill", [], {}, [["test", ["argument"], {kw: 'argument'}, []]]]]
84
84
  end
85
85
 
86
86
  it "quietly absorbs a SkipElementQuietly exception" do
@@ -149,8 +149,8 @@ describe Prawn::SVG::Elements::Base do
149
149
  it "uses the parent's color element if 'currentColor' fill attribute provided" do
150
150
  element.process
151
151
 
152
- expect(flattened_calls).to include ['fill_color', ['ff0000']]
153
- expect(flattened_calls).not_to include ['fill_color', ['00ff00']]
152
+ expect(flattened_calls).to include ['fill_color', ['ff0000'], {}]
153
+ expect(flattened_calls).not_to include ['fill_color', ['00ff00'], {}]
154
154
  end
155
155
  end
156
156
 
@@ -13,10 +13,10 @@ RSpec.describe Prawn::SVG::Elements::Line do
13
13
  it "renders the line" do
14
14
  subject.process
15
15
  expect(subject.base_calls).to eq [
16
- ["stroke_color", ["000000"], []],
17
- ["stroke", [], [
18
- ["move_to", [[5.0, 590.0]], []],
19
- ["line_to", [[15.0, 580.0]], []]]
16
+ ["stroke_color", ["000000"], {}, []],
17
+ ["stroke", [], {}, [
18
+ ["move_to", [[5.0, 590.0]], {}, []],
19
+ ["line_to", [[15.0, 580.0]], {}, []]]
20
20
  ]
21
21
  ]
22
22
  end
@@ -28,9 +28,9 @@ RSpec.describe Prawn::SVG::Elements::Line do
28
28
  it "outlines a path from 0,0 to 0,0" do
29
29
  subject.process
30
30
  expect(subject.base_calls).to eq [
31
- ["end_path", [], [
32
- ["move_to", [[0, 600]], []],
33
- ["line_to", [[0, 600]], []]]
31
+ ["end_path", [], {}, [
32
+ ["move_to", [[0, 600]], {}, []],
33
+ ["line_to", [[0, 600]], {}, []]]
34
34
  ]
35
35
  ]
36
36
  end
@@ -43,11 +43,11 @@ RSpec.describe Prawn::SVG::Elements::Line do
43
43
  subject.process
44
44
 
45
45
  expect(subject.base_calls).to eq [
46
- ["fill_color", ["0000ff"], []],
47
- ["stroke_color", ["ff0000"], []],
48
- ["stroke", [], [
49
- ["move_to", [[0, 600]], []],
50
- ["line_to", [[15.0, 580.0]], []]]
46
+ ["fill_color", ["0000ff"], {}, []],
47
+ ["stroke_color", ["ff0000"], {}, []],
48
+ ["stroke", [], {}, [
49
+ ["move_to", [[0, 600]], {}, []],
50
+ ["line_to", [[15.0, 580.0]], {}, []]]
51
51
  ]
52
52
  ]
53
53
  end
@@ -54,41 +54,41 @@ RSpec.describe Prawn::SVG::Elements::Marker do
54
54
  # in section 11.6.3.
55
55
 
56
56
  expect(line_element.base_calls).to eq [
57
- ["stroke_color", ["000000"], []],
58
- ["line_width", [100.0], []],
59
- ["stroke", [], [
60
- ["move_to", [[0.0, 600.0]], []],
61
- ["line_to", [[10.0, 590.0]], []]
57
+ ["stroke_color", ["000000"], {}, []],
58
+ ["line_width", [100.0], {}, []],
59
+ ["stroke", [], {}, [
60
+ ["move_to", [[0.0, 600.0]], {}, []],
61
+ ["line_to", [[10.0, 590.0]], {}, []]
62
62
  ]
63
63
  ],
64
- ["save", [], []],
65
- ["transformation_matrix", [1, 0, 0, 1, 10, -10], []],
66
- ["rotate", [-45, {origin: [0, 600.0]}], [
67
- ["transformation_matrix", [100.0, 0, 0, 100.0, 0, 0], []],
68
- ["transformation_matrix", [1, 0, 0, 1, -0.0, 1.5], []],
69
- ["rectangle", [[-0.5, 600.0], 4.0, 3.0], []],
70
- ["clip", [], []],
71
- ["transformation_matrix", [0.3, 0, 0, 0.3, 0, 0], []],
72
- ["transparent", [1.0, 1.0], [
73
- ["stroke_color", ["000000"], []],
74
- ["line_width", [100.0], []],
75
- ["cap_style", [:butt], []],
76
- ["undash", [], []],
77
- ["save", [], []],
78
- ["fill", [], [
79
- ["join_style", [:bevel], []],
80
- ["move_to", [[0.0, 600.0]], []],
81
- ["line_to", [[10.0, 595.0]], []],
82
- ["line_to", [[0.0, 590.0]], []],
83
- ["close_path", [], []]
64
+ ["save", [], {}, []],
65
+ ["transformation_matrix", [1, 0, 0, 1, 10, -10], {}, []],
66
+ ["rotate", [-45], {origin: [0, 600.0]}, [
67
+ ["transformation_matrix", [100.0, 0, 0, 100.0, 0, 0], {}, []],
68
+ ["transformation_matrix", [1, 0, 0, 1, -0.0, 1.5], {}, []],
69
+ ["rectangle", [[-0.5, 600.0], 4.0, 3.0], {}, []],
70
+ ["clip", [], {}, []],
71
+ ["transformation_matrix", [0.3, 0, 0, 0.3, 0, 0], {}, []],
72
+ ["transparent", [1.0, 1.0], {}, [
73
+ ["stroke_color", ["000000"], {}, []],
74
+ ["line_width", [100.0], {}, []],
75
+ ["cap_style", [:butt], {}, []],
76
+ ["undash", [], {}, []],
77
+ ["save", [], {}, []],
78
+ ["fill", [], {}, [
79
+ ["join_style", [:bevel], {}, []],
80
+ ["move_to", [[0.0, 600.0]], {}, []],
81
+ ["line_to", [[10.0, 595.0]], {}, []],
82
+ ["line_to", [[0.0, 590.0]], {}, []],
83
+ ["close_path", [], {}, []]
84
84
  ]
85
85
  ],
86
- ["restore", [], []],
86
+ ["restore", [], {}, []],
87
87
  ]
88
88
  ]
89
89
  ]
90
90
  ],
91
- ["restore", [], []]
91
+ ["restore", [], {}, []]
92
92
  ]
93
93
  end
94
94
  end
@@ -13,11 +13,11 @@ RSpec.describe Prawn::SVG::Elements::Polygon do
13
13
  it "renders the polygon" do
14
14
  subject.process
15
15
  expect(subject.base_calls).to eq [
16
- ["fill", [], [
17
- ["move_to", [[10.0, 590.0]], []],
18
- ["line_to", [[20.0, 580.0]], []],
19
- ["line_to", [[30.0, 570.0]], []],
20
- ["close_path", [], []]]
16
+ ["fill", [], {}, [
17
+ ["move_to", [[10.0, 590.0]], {}, []],
18
+ ["line_to", [[20.0, 580.0]], {}, []],
19
+ ["line_to", [[30.0, 570.0]], {}, []],
20
+ ["close_path", [], {}, []]]
21
21
  ]
22
22
  ]
23
23
  end
@@ -29,10 +29,10 @@ RSpec.describe Prawn::SVG::Elements::Polygon do
29
29
  it "ignores the last one" do
30
30
  subject.process
31
31
  expect(subject.base_calls).to eq [
32
- ["fill", [], [
33
- ["move_to", [[10.0, 590.0]], []],
34
- ["line_to", [[20.0, 580.0]], []],
35
- ["close_path", [], []]]
32
+ ["fill", [], {}, [
33
+ ["move_to", [[10.0, 590.0]], {}, []],
34
+ ["line_to", [[20.0, 580.0]], {}, []],
35
+ ["close_path", [], {}, []]]
36
36
  ]
37
37
  ]
38
38
  end
@@ -13,10 +13,10 @@ RSpec.describe Prawn::SVG::Elements::Polyline do
13
13
  it "renders the polyline" do
14
14
  subject.process
15
15
  expect(subject.base_calls).to eq [
16
- ["fill", [], [
17
- ["move_to", [[10.0, 590.0]], []],
18
- ["line_to", [[20.0, 580.0]], []],
19
- ["line_to", [[30.0, 570.0]], []]]
16
+ ["fill", [], {}, [
17
+ ["move_to", [[10.0, 590.0]], {}, []],
18
+ ["line_to", [[20.0, 580.0]], {}, []],
19
+ ["line_to", [[30.0, 570.0]], {}, []]]
20
20
  ]
21
21
  ]
22
22
  end
@@ -28,9 +28,9 @@ RSpec.describe Prawn::SVG::Elements::Polyline do
28
28
  it "ignores the last one" do
29
29
  subject.process
30
30
  expect(subject.base_calls).to eq [
31
- ["fill", [], [
32
- ["move_to", [[10.0, 590.0]], []],
33
- ["line_to", [[20.0, 580.0]], []]]
31
+ ["fill", [], {}, [
32
+ ["move_to", [[10.0, 590.0]], {}, []],
33
+ ["line_to", [[20.0, 580.0]], {}, []]]
34
34
  ]
35
35
  ]
36
36
  end
@@ -15,7 +15,7 @@ describe Prawn::SVG::Elements::Text do
15
15
  it "converts newlines and tabs to spaces, and preserves spaces" do
16
16
  element.process
17
17
 
18
- expect(flatten_calls(element.calls)).to include ["draw_text", ["some text", {:size=>16, :style=>:normal, :text_anchor=>'start', :at=>[:relative, :relative], :offset=>[0,0]}]]
18
+ expect(flatten_calls(element.calls)).to include ["draw_text", ["some text"], {:size=>16, :style=>:normal, :text_anchor=>'start', :at=>[:relative, :relative], :offset=>[0,0]}]
19
19
  end
20
20
  end
21
21
 
@@ -25,7 +25,7 @@ describe Prawn::SVG::Elements::Text do
25
25
  it "strips space" do
26
26
  element.process
27
27
 
28
- expect(flatten_calls(element.calls)).to include ["draw_text", ["some text", {:size=>16, :style=>:normal, :text_anchor=>'start', :at=>[:relative, :relative], :offset=>[0,0]}]]
28
+ expect(flatten_calls(element.calls)).to include ["draw_text", ["some text"], {:size=>16, :style=>:normal, :text_anchor=>'start', :at=>[:relative, :relative], :offset=>[0,0]}]
29
29
  end
30
30
  end
31
31
  end
@@ -78,10 +78,10 @@ Even more
78
78
  element.process
79
79
 
80
80
  expect(element.base_calls).to eq [
81
- ["text_group", [], [
82
- ["font", ["Helvetica", {style: :normal}], []],
83
- ["character_spacing", [5.0], [
84
- ["draw_text", ["spaced", default_style], []]
81
+ ["text_group", [], {}, [
82
+ ["font", ["Helvetica"], {style: :normal}, []],
83
+ ["character_spacing", [5.0], {}, [
84
+ ["draw_text", ["spaced"], default_style, []]
85
85
  ]]
86
86
  ]]
87
87
  ]
@@ -95,9 +95,9 @@ Even more
95
95
  element.process
96
96
 
97
97
  expect(element.base_calls).to eq [
98
- ["text_group", [], [
99
- ["font", ["Helvetica", {:style=>:normal}], []],
100
- ["draw_text", ["underlined", default_style.merge(decoration: 'underline')], []]
98
+ ["text_group", [], {},[
99
+ ["font", ["Helvetica"], {:style=>:normal}, []],
100
+ ["draw_text", ["underlined"], default_style.merge(decoration: 'underline'), []]
101
101
  ]]
102
102
  ]
103
103
  end
@@ -111,11 +111,11 @@ Even more
111
111
  element.process
112
112
 
113
113
  expect(element.base_calls).to eq [
114
- ["text_group", [], [
115
- ["stroke_color", ["ff0000"], []],
116
- ["font", ["Helvetica", {style: :normal}], []],
117
- ["text_rendering_mode", [:stroke], [
118
- ["draw_text", ["stroked", default_style], []]
114
+ ["text_group", [], {}, [
115
+ ["stroke_color", ["ff0000"], {}, []],
116
+ ["font", ["Helvetica"], {style: :normal}, []],
117
+ ["text_rendering_mode", [:stroke], {}, [
118
+ ["draw_text", ["stroked"], default_style, []]
119
119
  ]]
120
120
  ]]
121
121
  ]
@@ -129,24 +129,24 @@ Even more
129
129
  element.process
130
130
 
131
131
  expect(element.base_calls).to eq [
132
- ["text_group", [], [
133
- ["stroke_color", ["ff0000"], []],
134
- ["font", ["Helvetica", {style: :normal}], []],
135
- ["text_rendering_mode", [:stroke], [
136
- ["draw_text", ["stroked ", default_style], []],
137
- ["save", [], []],
138
- ["fill_color", ["000000"], []],
139
- ["font", ["Helvetica", {style: :normal}], []],
140
- ["text_rendering_mode", [:fill_stroke], [
141
- ["draw_text", ["both", default_style], []]
132
+ ["text_group", [], {}, [
133
+ ["stroke_color", ["ff0000"], {}, []],
134
+ ["font", ["Helvetica"], {style: :normal}, []],
135
+ ["text_rendering_mode", [:stroke], {}, [
136
+ ["draw_text", ["stroked "], default_style, []],
137
+ ["save", [], {}, []],
138
+ ["fill_color", ["000000"], {}, []],
139
+ ["font", ["Helvetica"], {style: :normal}, []],
140
+ ["text_rendering_mode", [:fill_stroke], {}, [
141
+ ["draw_text", ["both"], default_style, []]
142
142
  ]],
143
- ["restore", [], []],
144
- ["save", [], []],
145
- ["font", ["Helvetica", {style: :normal}], []],
146
- ["text_rendering_mode", [:invisible], [
147
- ["draw_text", ["neither", default_style], []]
143
+ ["restore", [], {}, []],
144
+ ["save", [], {}, []],
145
+ ["font", ["Helvetica"], {style: :normal}, []],
146
+ ["text_rendering_mode", [:invisible], {}, [
147
+ ["draw_text", ["neither"], default_style, []]
148
148
  ]],
149
- ["restore", [], []],
149
+ ["restore", [], {}, []],
150
150
  ]]
151
151
  ]]
152
152
  ]
@@ -160,7 +160,7 @@ Even more
160
160
 
161
161
  it "finds the font and uses it" do
162
162
  element.process
163
- expect(flatten_calls(element.base_calls)).to include ['font', ['Courier', {style: :normal}]]
163
+ expect(flatten_calls(element.base_calls)).to include ['font', ['Courier'], {style: :normal}]
164
164
  end
165
165
  end
166
166
 
@@ -169,7 +169,7 @@ Even more
169
169
 
170
170
  it "uses the fallback font" do
171
171
  element.process
172
- expect(flatten_calls(element.base_calls)).to include ['font', ['Times-Roman', {style: :normal}]]
172
+ expect(flatten_calls(element.base_calls)).to include ['font', ['Times-Roman'], {style: :normal}]
173
173
  end
174
174
 
175
175
  context "when there is no fallback font" do
@@ -191,9 +191,9 @@ Even more
191
191
  it "references the text" do
192
192
  element.process
193
193
  expect(flatten_calls(element.base_calls)[9..11]).to eq [
194
- ["fill_color", ["ff0000"]],
195
- ["font", ["Helvetica", {:style=>:normal}]],
196
- ["draw_text", ["my reference text", {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[10.0, :relative], :offset=>[0,0]}]],
194
+ ["fill_color", ["ff0000"], {}],
195
+ ["font", ["Helvetica"], {:style=>:normal}],
196
+ ["draw_text", ["my reference text"], {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[10.0, :relative], :offset=>[0,0]}],
197
197
  ]
198
198
  end
199
199
  end
@@ -205,11 +205,11 @@ Even more
205
205
  element.process
206
206
 
207
207
  expect(flatten_calls(element.base_calls)).to eq [
208
- ["text_group", []],
209
- ["font", ["Helvetica", {:style=>:normal}]],
210
- ["draw_text", ["H", {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[10.0, :relative], :offset=>[30.0, 2.0]}]],
211
- ["draw_text", ["i", {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[20.0, :relative], :offset=>[50.0, 0]}]],
212
- ["draw_text", [" there, this is a good test", {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[80.0, 0]}]]
208
+ ["text_group", [], {}],
209
+ ["font", ["Helvetica"], {:style=>:normal}],
210
+ ["draw_text", ["H"], {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[10.0, :relative], :offset=>[30.0, 2.0]}],
211
+ ["draw_text", ["i"], {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[20.0, :relative], :offset=>[50.0, 0]}],
212
+ ["draw_text", [" there, this is a good test"], {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[80.0, 0]}]
213
213
  ]
214
214
  end
215
215
  end
@@ -221,19 +221,19 @@ Even more
221
221
  element.process
222
222
 
223
223
  expect(flatten_calls(element.base_calls)).to eq [
224
- ["text_group", []],
225
- ["font", ["Helvetica", {:style=>:normal}]],
226
- ["draw_text", ["H", {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[0, 0], :rotate=>-10.0}]],
227
- ["draw_text", ["i", {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[0, 0], :rotate=>-20.0}]],
228
- ["draw_text", [" ", {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[0, 0], :rotate=>-30.0}]],
229
- ["save", []],
230
- ["font", ["Helvetica", {:style=>:normal}]],
231
- ["draw_text", ["this", {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[0, 0]}]],
232
- ["restore", []],
233
- ["draw_text", [" ", {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[0, 0], :rotate=>-80.0}]],
234
- ["draw_text", ["o", {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[0, 0], :rotate=>-90.0}]],
235
- ["draw_text", ["k", {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[0, 0], :rotate=>-100.0}]],
236
- ["draw_text", ["!", {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[0, 0], :rotate=>-100.0}]]
224
+ ["text_group", [], {}],
225
+ ["font", ["Helvetica"], {:style=>:normal}],
226
+ ["draw_text", ["H"], {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[0, 0], :rotate=>-10.0}],
227
+ ["draw_text", ["i"], {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[0, 0], :rotate=>-20.0}],
228
+ ["draw_text", [" "], {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[0, 0], :rotate=>-30.0}],
229
+ ["save", [], {}],
230
+ ["font", ["Helvetica"], {:style=>:normal}],
231
+ ["draw_text", ["this"], {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[0, 0]}],
232
+ ["restore", [], {}],
233
+ ["draw_text", [" "], {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[0, 0], :rotate=>-80.0}],
234
+ ["draw_text", ["o"], {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[0, 0], :rotate=>-90.0}],
235
+ ["draw_text", ["k"], {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[0, 0], :rotate=>-100.0}],
236
+ ["draw_text", ["!"], {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[0, 0], :rotate=>-100.0}]
237
237
  ]
238
238
  end
239
239
  end
@@ -40,10 +40,10 @@ RSpec.describe Prawn::SVG::Pathable do
40
40
  subject.apply_commands
41
41
 
42
42
  expect(subject.base_calls).to eq [
43
- ["move_to", [[10.0, 590.0]], []],
44
- ["line_to", [[20.0, 580.0]], []],
45
- ["curve_to", [[30.0, 570.0], {bounds: [[25.0, 580.0], [25.0, 575.0]]}], []],
46
- ["close_path", [], []]
43
+ ["move_to", [[10.0, 590.0]], {}, []],
44
+ ["line_to", [[20.0, 580.0]], {}, []],
45
+ ["curve_to", [[30.0, 570.0]], {bounds: [[25.0, 580.0], [25.0, 575.0]]}, []],
46
+ ["close_path", [], {}, []]
47
47
  ]
48
48
  end
49
49
  end
data/spec/spec_helper.rb CHANGED
@@ -10,8 +10,8 @@ module Support
10
10
  [].tap do |flattened_calls|
11
11
  add = -> (local_calls) do
12
12
  local_calls.each do |call|
13
- flattened_calls << call[0..1]
14
- add.call call[2]
13
+ flattened_calls << call[0..2]
14
+ add.call call[3]
15
15
  end
16
16
  end
17
17
 
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.31.0
4
+ version: 0.32.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roger Nesbitt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-24 00:00:00.000000000 Z
11
+ date: 2021-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prawn
@@ -44,6 +44,20 @@ dependencies:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '1.6'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rexml
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '3.2'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '3.2'
47
61
  - !ruby/object:Gem::Dependency
48
62
  name: rspec
49
63
  requirement: !ruby/object:Gem::Requirement
@@ -80,9 +94,9 @@ executables: []
80
94
  extensions: []
81
95
  extra_rdoc_files: []
82
96
  files:
97
+ - ".github/workflows/test.yml"
83
98
  - ".gitignore"
84
99
  - ".rspec"
85
- - ".travis.yml"
86
100
  - Gemfile
87
101
  - LICENSE
88
102
  - README.md
@@ -256,14 +270,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
256
270
  requirements:
257
271
  - - ">="
258
272
  - !ruby/object:Gem::Version
259
- version: 2.1.0
273
+ version: 2.3.0
260
274
  required_rubygems_version: !ruby/object:Gem::Requirement
261
275
  requirements:
262
276
  - - ">="
263
277
  - !ruby/object:Gem::Version
264
278
  version: '0'
265
279
  requirements: []
266
- rubygems_version: 3.0.3
280
+ rubygems_version: 3.2.3
267
281
  signing_key:
268
282
  specification_version: 4
269
283
  summary: SVG renderer for Prawn PDF library
data/.travis.yml DELETED
@@ -1,8 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.2.10
4
- - 2.3.8
5
- - 2.4.10
6
- - 2.5.8
7
- - 2.6.6
8
- - 2.7.1