prawn-svg 0.16.2 → 0.17.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
  SHA1:
3
- metadata.gz: aa682df73b98546f5b1bb627b79cdc21151b0b2c
4
- data.tar.gz: e1a1f7f04ca5d3c3954fbd9e4c3ddb36aaafd2f5
3
+ metadata.gz: 84d18077060035c9ff8e187e66224d5f8096442f
4
+ data.tar.gz: 5f5dfebe80da4952bb7abf990dae113ab6964f5e
5
5
  SHA512:
6
- metadata.gz: 1e139a25230e0402cde88e8f5271f767d2bc3a0f2d34e52b0524de70b6a7e981ac53abbd3a4c2b5e7f868b75c825565b2fed697e2153dbf0f98da53524704407
7
- data.tar.gz: 3c0864a2d2b56460c62014f06d9cb5d90911a6aed2a22c81966f1fdbf66ba7c11c631e0aa8e8c3f1d5357c2f81d76831646fa57e3237787e439b81d98bfe93c4
6
+ metadata.gz: 138d046a81065b80ac7ee63d249d4874deae0e4bfeb18630b2ff117ee93392823cb675b1fc21372f16a199c0efc7ae68f45e3236c0c8559c33c07423a7a31e8d
7
+ data.tar.gz: 477eb736af2b1b0f4cbd1789d1afb5e0807cac8a5d578790c99d5aaa75787c2413ebb571920e42b4004261401163684e82dd34be1c31af6a4434d85ec573c8b0
@@ -105,19 +105,17 @@ class Prawn::Svg::Parser
105
105
  element.add_call 'line', x(attrs['x1'] || '0'), y(attrs['y1'] || '0'), x(attrs['x2'] || '0'), y(attrs['y2'] || '0')
106
106
 
107
107
  when 'polyline'
108
- points = attrs['points'].split(/\s+/)
109
- return unless base_point = points.shift
110
- x, y = base_point.split(",")
108
+ points = parse_points(attrs['points'])
109
+ return unless points.length > 0
110
+ x, y = points.shift
111
111
  element.add_call 'move_to', x(x), y(y)
112
112
  element.add_call_and_enter 'stroke'
113
- points.each do |point|
114
- x, y = point.split(",")
113
+ points.each do |x, y|
115
114
  element.add_call "line_to", x(x), y(y)
116
115
  end
117
116
 
118
117
  when 'polygon'
119
- points = attrs['points'].split(/\s+/).collect do |point|
120
- x, y = point.split(",")
118
+ points = parse_points(attrs['points']).collect do |x, y|
121
119
  [x(x), y(y)]
122
120
  end
123
121
  element.add_call "polygon", *points
@@ -256,4 +254,14 @@ class Prawn::Svg::Parser
256
254
  %w(x y distance).each do |method|
257
255
  define_method(method) {|*a| @document.send(method, *a)}
258
256
  end
257
+
258
+ def parse_points(points_string)
259
+ points_string.
260
+ to_s.
261
+ strip.
262
+ gsub(/(\d)-(\d)/, '\1 -\2').
263
+ split(/(?:\s+,?\s*|,\s*)/).
264
+ each_slice(2).
265
+ to_a
266
+ end
259
267
  end
@@ -1,5 +1,5 @@
1
1
  module Prawn
2
2
  module Svg
3
- VERSION = '0.16.2'
3
+ VERSION = '0.17.0'
4
4
  end
5
5
  end
data/prawn-svg.gemspec CHANGED
@@ -19,6 +19,7 @@ spec = Gem::Specification.new do |gem|
19
19
  gem.require_paths = ["lib"]
20
20
 
21
21
  gem.add_runtime_dependency "prawn", ">= 0.8.4", "< 3"
22
+ gem.add_runtime_dependency "css_parser", "~> 1.3"
22
23
  gem.add_development_dependency "rspec", "~> 2.14"
23
24
  gem.add_development_dependency "rake", "~> 10.1"
24
25
  end
@@ -0,0 +1,36 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="205pt" style="width:362px;height:205px;" version="1.1" viewBox="0 0 362 205" width="362pt">
3
+ <g>
4
+ <line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 5.0,5.0;" x1="146" x2="146" y1="35.4883" y2="204.041"/>
5
+ <line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 5.0,5.0;" x1="204" x2="204" y1="35.4883" y2="204.041"/>
6
+ <rect fill="#FEFECE" height="30.4883" style="stroke: #A80036; stroke-width: 1.5;" width="47" x="121" y="0"/>
7
+ <text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="33" x="128" y="20.5352">Alice</text>
8
+ <rect fill="#FEFECE" height="30.4883" style="stroke: #A80036; stroke-width: 1.5;" width="40" x="182" y="0"/>
9
+ <text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="26" x="189" y="20.5352">Bob</text>
10
+ <polygon fill="#A80036" points="192,67.4883,202,71.4883,192,75.4883,196,71.4883" style="stroke: #A80036; stroke-width: 1.0;"/>
11
+ <line style="stroke: #A80036; stroke-width: 1.0;" x1="146.5" x2="198" y1="71.4883" y2="71.4883"/>
12
+ <text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="31" x="153.5" y="67.0566">hello</text>
13
+ <polygon fill="#FBFB77" points="5,50.4883,5,75.4883,138,75.4883,138,60.4883,128,50.4883,5,50.4883" style="stroke: #A80036; stroke-width: 1.0;"/>
14
+ <line style="stroke: #A80036; stroke-width: 1.0;" x1="128" x2="128" y1="50.4883" y2="60.4883"/>
15
+ <line style="stroke: #A80036; stroke-width: 1.0;" x1="138" x2="128" y1="60.4883" y2="60.4883"/>
16
+ <text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="112" x="11" y="68.0566">this is a first note</text>
17
+ <polygon fill="#A80036" points="157.5,106.7988,147.5,110.7988,157.5,114.7988,153.5,110.7988" style="stroke: #A80036; stroke-width: 1.0;"/>
18
+ <line style="stroke: #A80036; stroke-width: 1.0;" x1="151.5" x2="203" y1="110.7988" y2="110.7988"/>
19
+ <text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="16" x="163.5" y="106.3672">ok</text>
20
+ <polygon fill="#FBFB77" points="209,89.7988,209,114.7988,353,114.7988,353,99.7988,343,89.7988,209,89.7988" style="stroke: #A80036; stroke-width: 1.0;"/>
21
+ <line style="stroke: #A80036; stroke-width: 1.0;" x1="343" x2="343" y1="89.7988" y2="99.7988"/>
22
+ <line style="stroke: #A80036; stroke-width: 1.0;" x1="353" x2="343" y1="99.7988" y2="99.7988"/>
23
+ <text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="123" x="215" y="107.3672">this is another note</text>
24
+ <line style="stroke: #A80036; stroke-width: 1.0;" x1="204" x2="246" y1="159.2305" y2="159.2305"/>
25
+ <line style="stroke: #A80036; stroke-width: 1.0;" x1="246" x2="246" y1="159.2305" y2="172.2305"/>
26
+ <line style="stroke: #A80036; stroke-width: 1.0;" x1="205" x2="246" y1="172.2305" y2="172.2305"/>
27
+ <polygon fill="#A80036" points="215,168.2305,205,172.2305,215,176.2305,211,172.2305" style="stroke: #A80036; stroke-width: 1.0;"/>
28
+ <text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="84" x="211" y="154.4883">I am thinking</text>
29
+ <polygon fill="#FBFB77" points="52,129.1094,52,184.1094,195,184.1094,195,139.1094,185,129.1094,52,129.1094" style="stroke: #A80036; stroke-width: 1.0;"/>
30
+ <line style="stroke: #A80036; stroke-width: 1.0;" x1="185" x2="185" y1="129.1094" y2="139.1094"/>
31
+ <line style="stroke: #A80036; stroke-width: 1.0;" x1="195" x2="185" y1="139.1094" y2="139.1094"/>
32
+ <text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="39" x="58" y="146.6777">a note</text>
33
+ <text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="122" x="58" y="161.9883">can also be defined</text>
34
+ <text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="98" x="58" y="177.2988">on several lines</text>
35
+ </g>
36
+ </svg>
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.16.2
4
+ version: 0.17.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: 2015-03-11 00:00:00.000000000 Z
11
+ date: 2015-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prawn
@@ -30,6 +30,20 @@ dependencies:
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '3'
33
+ - !ruby/object:Gem::Dependency
34
+ name: css_parser
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.3'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.3'
33
47
  - !ruby/object:Gem::Dependency
34
48
  name: rspec
35
49
  requirement: !ruby/object:Gem::Requirement
@@ -112,6 +126,7 @@ files:
112
126
  - spec/sample_svg/cubic02.svg
113
127
  - spec/sample_svg/display_none.svg
114
128
  - spec/sample_svg/ellipse01.svg
129
+ - spec/sample_svg/gistfile1.svg
115
130
  - spec/sample_svg/google_charts.svg
116
131
  - spec/sample_svg/hidden_paths.svg
117
132
  - spec/sample_svg/highcharts.svg
@@ -192,6 +207,7 @@ test_files:
192
207
  - spec/sample_svg/cubic02.svg
193
208
  - spec/sample_svg/display_none.svg
194
209
  - spec/sample_svg/ellipse01.svg
210
+ - spec/sample_svg/gistfile1.svg
195
211
  - spec/sample_svg/google_charts.svg
196
212
  - spec/sample_svg/hidden_paths.svg
197
213
  - spec/sample_svg/highcharts.svg