prawn-svg 0.25.0 → 0.25.1

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
  SHA1:
3
- metadata.gz: bcd6cefab7e10066561afcaee2e9aeed78c9b30f
4
- data.tar.gz: dbe371b99f2cf4953de90e892a3f95718abdd02e
3
+ metadata.gz: 920f166e2e978e119012447d12239650468aa192
4
+ data.tar.gz: 4a55b681c5c4907dbf9e938da0ccd41217d1623f
5
5
  SHA512:
6
- metadata.gz: 7c567a3f24cebf73c40ec247799f78e730b5f3479be3b486791b7bba9cf7140611db88b00e49422b6bb151613a09296e167e08b30b9f2bd73acf34a9ff49f193
7
- data.tar.gz: b2e8135844d8e09dbabdf153794775531c6f3b15a6ca796b7a3a765a135b16837fa9127d5d88c616d07709868d296210eba044605540afe010d68e42a63e36c7
6
+ metadata.gz: 7934d9a7adaf305002aaea55e2d0acd58ff1d2a3307797f18f2bdb69281cebbcafb4acb16efce262643d28154e28cf160ad0a298e76c83e0913139ef37aebf6e
7
+ data.tar.gz: a032d3e73d64fb48f3cffefb83a16b059fce5bbd491d73c90512c50056e590758ee0acfde004ae8892f1dc1b7dc50f00bc0ef3aa53393aa2842b3b1480b35e4e
@@ -2,6 +2,8 @@ module Prawn::SVG::Elements
2
2
  COMMA_WSP_REGEXP = /(?:\s+,?\s*|,\s*)/
3
3
  end
4
4
 
5
+ require 'prawn/svg/elements/call_duplicator'
6
+
5
7
  %w(base depth_first_base root container viewport style text text_component line polyline polygon circle ellipse rect path use image gradient marker ignored).each do |filename|
6
8
  require "prawn/svg/elements/#{filename}"
7
9
  end
@@ -1,6 +1,8 @@
1
1
  class Prawn::SVG::Elements::Base
2
2
  extend Forwardable
3
3
 
4
+ include Prawn::SVG::Elements::CallDuplicator
5
+
4
6
  include Prawn::SVG::Calculators::Pixels
5
7
 
6
8
  include Prawn::SVG::Attributes::Transform
@@ -106,7 +108,7 @@ class Prawn::SVG::Elements::Base
106
108
  end
107
109
 
108
110
  def add_calls_from_element(other)
109
- @calls.concat other.base_calls
111
+ @calls.concat duplicate_calls(other.base_calls)
110
112
  end
111
113
 
112
114
  def new_call_context_from_base
@@ -0,0 +1,37 @@
1
+ #
2
+ # Unfortunately, prawn mutates arguments passed in to it.
3
+ # When we make a copy of one of the call stacks, we need to make a deep
4
+ # duplicate of it so that the first time prawn mutates the arguments, it
5
+ # won't affect the subsequent calls.
6
+ #
7
+ module Prawn::SVG::Elements::CallDuplicator
8
+ private
9
+
10
+ def duplicate_calls(calls)
11
+ calls.map { |call| duplicate_call(call) }
12
+ end
13
+
14
+ def duplicate_call(call)
15
+ [call[0], duplicate_array(call[1]), duplicate_calls(call[2])]
16
+ end
17
+
18
+ def duplicate_array(array)
19
+ array.map do |value|
20
+ case value
21
+ when Array then duplicate_array(value)
22
+ when Hash then duplicate_hash(value)
23
+ else value
24
+ end
25
+ end
26
+ end
27
+
28
+ def duplicate_hash(hash)
29
+ hash.each.with_object({}) do |(key, value), result|
30
+ result[key] = case value
31
+ when Array then duplicate_array(value)
32
+ when Hash then duplicate_hash(value)
33
+ else value
34
+ end
35
+ end
36
+ end
37
+ end
@@ -184,12 +184,12 @@ module Prawn
184
184
  end
185
185
 
186
186
  def clip_rectangle(x, y, width, height)
187
- prawn.move_to x, y
188
- prawn.line_to x + width, y
189
- prawn.line_to x + width, y + height
190
- prawn.line_to x, y + height
191
- prawn.close_path
192
- prawn.add_content "W n" # clip to path
187
+ prawn.move_to x, y
188
+ prawn.line_to x + width, y
189
+ prawn.line_to x + width, y + height
190
+ prawn.line_to x, y + height
191
+ prawn.close_path
192
+ prawn.add_content "W n" # clip to path
193
193
  end
194
194
  end
195
195
  end
@@ -1,5 +1,5 @@
1
1
  module Prawn
2
2
  module SVG
3
- VERSION = '0.25.0'
3
+ VERSION = '0.25.1'
4
4
  end
5
5
  end
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.25.0
4
+ version: 0.25.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roger Nesbitt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-29 00:00:00.000000000 Z
11
+ date: 2016-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prawn
@@ -103,6 +103,7 @@ files:
103
103
  - lib/prawn/svg/document.rb
104
104
  - lib/prawn/svg/elements.rb
105
105
  - lib/prawn/svg/elements/base.rb
106
+ - lib/prawn/svg/elements/call_duplicator.rb
106
107
  - lib/prawn/svg/elements/circle.rb
107
108
  - lib/prawn/svg/elements/container.rb
108
109
  - lib/prawn/svg/elements/depth_first_base.rb