prawn-svg 0.16.0 → 0.16.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: 2d7cbba75e8c3a5128d1c5136977b4b91d091407
4
- data.tar.gz: e1996ddcb667032eae7777fea1decb58b470a600
3
+ metadata.gz: 2449844e10f3fe6f77f03c24f71b85dc6499335e
4
+ data.tar.gz: f793df7dcc8504d0fa38b24e9dbd1a253e323aba
5
5
  SHA512:
6
- metadata.gz: 3fc7f25cb50723695bcb95485daad73b89e158662f5c0af06f10a062395d8c903b8bea7447c7dca2b4ed15c58bcbcc8115e3dc564b62ae8b6b22af62d2907f9b
7
- data.tar.gz: 312b2b093fec372fa444c61175b843592cac404c233f54cd3ec156ea85f4615337b5e8d7bb1372819c457df9476fca1ece3fbefff41a3415ae733676e92706c6
6
+ metadata.gz: 6974bd07c2dcb81694b5b24ab4401ac6cedb8667806f808c8766a974d93dbdb16f3246d2dfa76aebb491866a8fc18e609fa736b153a9b8df95cb00899aa174a3
7
+ data.tar.gz: 89f35cac3ee7551995f7fd3dbba228157c9651a1a213a535bc226c378238715b18d6359050c96adff5418088fbc131ccecc391938c5c6be44235f2d20739ecc0
@@ -57,12 +57,13 @@ class Prawn::Svg::Element
57
57
  draw_types = parse_fill_and_stroke_attributes_and_call
58
58
  parse_stroke_width_attribute_and_call
59
59
  parse_font_attributes_and_call
60
+ parse_display_attribute
60
61
  apply_drawing_call(draw_types)
61
62
  end
62
63
 
63
64
  def apply_drawing_call(draw_types)
64
65
  if !@state[:disable_drawing] && !container?
65
- if draw_types.empty?
66
+ if draw_types.empty? || @state[:display] == "none"
66
67
  add_call_and_enter("end_path")
67
68
  else
68
69
  add_call_and_enter(draw_types.join("_and_"))
@@ -193,6 +194,9 @@ class Prawn::Svg::Element
193
194
  end
194
195
  end
195
196
 
197
+ def parse_display_attribute
198
+ @state[:display] = @attributes['display'].strip if @attributes['display']
199
+ end
196
200
 
197
201
  def parse_css_method_calls(string)
198
202
  string.scan(/\s*(\w+)\(([^)]+)\)\s*/).collect do |call|
@@ -18,6 +18,8 @@ class Prawn::Svg::Parser::Image
18
18
  end
19
19
 
20
20
  def parse(element)
21
+ return if element.state[:display] == "none"
22
+
21
23
  attrs = element.attributes
22
24
  url = attrs['xlink:href'] || attrs['href']
23
25
  if url.nil?
@@ -173,6 +173,8 @@ module Prawn
173
173
  rx, ry, phi, fa, fs, x2, y2 = (1..7).collect {values.shift}
174
174
  x1, y1 = @last_point
175
175
 
176
+ return if rx.zero? && ry.zero?
177
+
176
178
  if relative
177
179
  x2 += x1
178
180
  y2 += y1
@@ -6,6 +6,8 @@ class Prawn::Svg::Parser::Text
6
6
 
7
7
  protected
8
8
  def internal_parse(element, x_positions, y_positions, relative)
9
+ return if element.state[:display] == "none"
10
+
9
11
  attrs = element.attributes
10
12
 
11
13
  if attrs['x'] || attrs['y']
@@ -123,26 +123,35 @@ class Prawn::Svg::Parser
123
123
  element.add_call "polygon", *points
124
124
 
125
125
  when 'circle'
126
+ xy, r = [x(attrs['cx'] || "0"), y(attrs['cy'] || "0")], distance(attrs['r'])
127
+
128
+ return if zero_argument?(r)
129
+
126
130
  if USE_NEW_CIRCLE_CALL
127
- element.add_call "circle",
128
- [x(attrs['cx'] || "0"), y(attrs['cy'] || "0")], distance(attrs['r'])
131
+ element.add_call "circle", xy, r
129
132
  else
130
- element.add_call "circle_at",
131
- [x(attrs['cx'] || "0"), y(attrs['cy'] || "0")], :radius => distance(attrs['r'])
133
+ element.add_call "circle_at", xy, :radius => r
132
134
  end
133
135
 
134
136
  when 'ellipse'
135
- element.add_call USE_NEW_ELLIPSE_CALL ? "ellipse" : "ellipse_at",
136
- [x(attrs['cx'] || "0"), y(attrs['cy'] || "0")], distance(attrs['rx']), distance(attrs['ry'])
137
+ xy, rx, ry = [x(attrs['cx'] || "0"), y(attrs['cy'] || "0")], distance(attrs['rx']), distance(attrs['ry'])
138
+
139
+ return if zero_argument?(rx, ry)
140
+
141
+ element.add_call USE_NEW_ELLIPSE_CALL ? "ellipse" : "ellipse_at", xy, rx, ry
137
142
 
138
143
  when 'rect'
139
- radius = distance(attrs['rx'] || attrs['ry'])
140
- args = [[x(attrs['x'] || '0'), y(attrs['y'] || '0')], distance(attrs['width']), distance(attrs['height'])]
144
+ xy = [x(attrs['x'] || '0'), y(attrs['y'] || '0')]
145
+ width, height = distance(attrs['width']), distance(attrs['height'])
146
+ radius = distance(attrs['rx'] || attrs['ry'])
147
+
148
+ return if zero_argument?(width, height)
149
+
141
150
  if radius
142
151
  # n.b. does not support both rx and ry being specified with different values
143
- element.add_call "rounded_rectangle", *(args + [radius])
152
+ element.add_call "rounded_rectangle", xy, width, height, radius
144
153
  else
145
- element.add_call "rectangle", *args
154
+ element.add_call "rectangle", xy, width, height
146
155
  end
147
156
 
148
157
  when 'path'
@@ -240,6 +249,10 @@ class Prawn::Svg::Parser
240
249
  missing_attrs.empty?
241
250
  end
242
251
 
252
+ def zero_argument?(*args)
253
+ args.any? {|arg| arg.nil? || arg <= 0}
254
+ end
255
+
243
256
  %w(x y distance).each do |method|
244
257
  define_method(method) {|*a| @document.send(method, *a)}
245
258
  end
@@ -1,5 +1,5 @@
1
1
  module Prawn
2
2
  module Svg
3
- VERSION = '0.16.0'
3
+ VERSION = '0.16.1'
4
4
  end
5
5
  end
data/prawn-svg.gemspec CHANGED
@@ -5,7 +5,7 @@ spec = Gem::Specification.new do |gem|
5
5
  gem.name = 'prawn-svg'
6
6
  gem.version = Prawn::Svg::VERSION
7
7
  gem.summary = "SVG renderer for Prawn PDF library"
8
- gem.description = "SVG renderer for Prawn PDF library"
8
+ gem.description = "This gem allows you to render SVG directly into a PDF using the 'prawn' gem. Since PDF is vector-based, you'll get nice scaled graphics if you use SVG instead of an image."
9
9
  gem.has_rdoc = false
10
10
  gem.author = "Roger Nesbitt"
11
11
  gem.email = "roger@seriousorange.com"
@@ -18,7 +18,7 @@ spec = Gem::Specification.new do |gem|
18
18
  gem.name = "prawn-svg"
19
19
  gem.require_paths = ["lib"]
20
20
 
21
- gem.add_dependency "prawn", ">= 0.8.4"
22
- gem.add_development_dependency "rspec", "~> 2.14.1"
23
- gem.add_development_dependency "rake"
21
+ gem.add_runtime_dependency "prawn", ">= 0.8.4", "< 2"
22
+ gem.add_development_dependency "rspec", "~> 2.14"
23
+ gem.add_development_dependency "rake", "~> 10.1"
24
24
  end
@@ -0,0 +1,7 @@
1
+ <svg xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" style="font-family:'lucida grande', 'lucida sans unicode', arial, helvetica, sans-serif;font-size:12px;" xmlns="http://www.w3.org/2000/svg" width="850" height="300">
2
+ <g transform="translate(10,10) scale(1 1)">
3
+ <path fill="#009ACB" d="M 414.97698492798247 39.00000234377684 A 113 113 0 1 1 311.39206002954353
4
+ 197.10426559737175 L 415 152 A 0 0 0 1 0 415 152 Z" stroke="#FFFFFF" stroke-width="1" stroke-linejoin="round"
5
+ transform="translate(0,0)"></path>
6
+ </g>
7
+ </svg>
metadata CHANGED
@@ -1,65 +1,73 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prawn-svg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.16.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: 2014-07-05 00:00:00.000000000 Z
11
+ date: 2014-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prawn
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.8.4
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '2'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - '>='
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: 0.8.4
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '2'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: rspec
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
- - - ~>
37
+ - - "~>"
32
38
  - !ruby/object:Gem::Version
33
- version: 2.14.1
39
+ version: '2.14'
34
40
  type: :development
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
- - - ~>
44
+ - - "~>"
39
45
  - !ruby/object:Gem::Version
40
- version: 2.14.1
46
+ version: '2.14'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: rake
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
- - - '>='
51
+ - - "~>"
46
52
  - !ruby/object:Gem::Version
47
- version: '0'
53
+ version: '10.1'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
- - - '>='
58
+ - - "~>"
53
59
  - !ruby/object:Gem::Version
54
- version: '0'
55
- description: SVG renderer for Prawn PDF library
60
+ version: '10.1'
61
+ description: This gem allows you to render SVG directly into a PDF using the 'prawn'
62
+ gem. Since PDF is vector-based, you'll get nice scaled graphics if you use SVG
63
+ instead of an image.
56
64
  email: roger@seriousorange.com
57
65
  executables: []
58
66
  extensions: []
59
67
  extra_rdoc_files: []
60
68
  files:
61
- - .gitignore
62
- - .rspec
69
+ - ".gitignore"
70
+ - ".rspec"
63
71
  - Gemfile
64
72
  - LICENSE
65
73
  - README.md
@@ -115,6 +123,7 @@ files:
115
123
  - spec/sample_svg/negminy.svg
116
124
  - spec/sample_svg/omnigraffle.svg
117
125
  - spec/sample_svg/opacity01.svg
126
+ - spec/sample_svg/pie_piece.svg
118
127
  - spec/sample_svg/polygon01.svg
119
128
  - spec/sample_svg/polyline01.svg
120
129
  - spec/sample_svg/quad01.svg
@@ -144,17 +153,17 @@ require_paths:
144
153
  - lib
145
154
  required_ruby_version: !ruby/object:Gem::Requirement
146
155
  requirements:
147
- - - '>='
156
+ - - ">="
148
157
  - !ruby/object:Gem::Version
149
158
  version: '0'
150
159
  required_rubygems_version: !ruby/object:Gem::Requirement
151
160
  requirements:
152
- - - '>='
161
+ - - ">="
153
162
  - !ruby/object:Gem::Version
154
163
  version: '0'
155
164
  requirements: []
156
165
  rubyforge_project:
157
- rubygems_version: 2.1.11
166
+ rubygems_version: 2.2.2
158
167
  signing_key:
159
168
  specification_version: 4
160
169
  summary: SVG renderer for Prawn PDF library
@@ -193,6 +202,7 @@ test_files:
193
202
  - spec/sample_svg/negminy.svg
194
203
  - spec/sample_svg/omnigraffle.svg
195
204
  - spec/sample_svg/opacity01.svg
205
+ - spec/sample_svg/pie_piece.svg
196
206
  - spec/sample_svg/polygon01.svg
197
207
  - spec/sample_svg/polyline01.svg
198
208
  - spec/sample_svg/quad01.svg