prawn-svg 0.34.2 → 0.35.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/lint.yml +19 -0
  3. data/.github/workflows/test.yml +14 -27
  4. data/.gitignore +0 -1
  5. data/.rubocop.yml +86 -0
  6. data/.rubocop_todo.yml +51 -0
  7. data/Gemfile +4 -3
  8. data/Gemfile.lock +81 -0
  9. data/README.md +1 -1
  10. data/Rakefile +1 -1
  11. data/lib/prawn/svg/attributes/clip_path.rb +3 -3
  12. data/lib/prawn/svg/attributes/opacity.rb +3 -3
  13. data/lib/prawn/svg/attributes/stroke.rb +9 -9
  14. data/lib/prawn/svg/attributes/transform.rb +2 -2
  15. data/lib/prawn/svg/attributes.rb +1 -1
  16. data/lib/prawn/svg/calculators/arc_to_bezier_curve.rb +17 -15
  17. data/lib/prawn/svg/calculators/aspect_ratio.rb +16 -14
  18. data/lib/prawn/svg/calculators/document_sizing.rb +9 -10
  19. data/lib/prawn/svg/calculators/pixels.rb +8 -5
  20. data/lib/prawn/svg/color.rb +209 -212
  21. data/lib/prawn/svg/css/font_family_parser.rb +2 -2
  22. data/lib/prawn/svg/css/selector_parser.rb +39 -35
  23. data/lib/prawn/svg/css/stylesheets.rb +24 -24
  24. data/lib/prawn/svg/css/values_parser.rb +68 -0
  25. data/lib/prawn/svg/document.rb +6 -5
  26. data/lib/prawn/svg/elements/base.rb +29 -34
  27. data/lib/prawn/svg/elements/circle.rb +4 -4
  28. data/lib/prawn/svg/elements/clip_path.rb +0 -1
  29. data/lib/prawn/svg/elements/depth_first_base.rb +6 -6
  30. data/lib/prawn/svg/elements/ellipse.rb +3 -4
  31. data/lib/prawn/svg/elements/gradient.rb +49 -51
  32. data/lib/prawn/svg/elements/image.rb +5 -5
  33. data/lib/prawn/svg/elements/marker.rb +5 -5
  34. data/lib/prawn/svg/elements/path.rb +46 -47
  35. data/lib/prawn/svg/elements/polygon.rb +1 -1
  36. data/lib/prawn/svg/elements/polyline.rb +2 -2
  37. data/lib/prawn/svg/elements/rect.rb +3 -3
  38. data/lib/prawn/svg/elements/text.rb +1 -1
  39. data/lib/prawn/svg/elements/text_component.rb +22 -22
  40. data/lib/prawn/svg/elements/use.rb +3 -7
  41. data/lib/prawn/svg/elements/viewport.rb +1 -3
  42. data/lib/prawn/svg/elements.rb +30 -29
  43. data/lib/prawn/svg/extension.rb +2 -1
  44. data/lib/prawn/svg/font.rb +7 -7
  45. data/lib/prawn/svg/font_registry.rb +13 -13
  46. data/lib/prawn/svg/gradients.rb +3 -2
  47. data/lib/prawn/svg/interface.rb +4 -3
  48. data/lib/prawn/svg/loaders/data.rb +2 -2
  49. data/lib/prawn/svg/loaders/file.rb +12 -14
  50. data/lib/prawn/svg/loaders/web.rb +4 -8
  51. data/lib/prawn/svg/pathable.rb +41 -37
  52. data/lib/prawn/svg/properties.rb +34 -33
  53. data/lib/prawn/svg/renderer.rb +7 -7
  54. data/lib/prawn/svg/state.rb +1 -1
  55. data/lib/prawn/svg/transform_parser.rb +5 -5
  56. data/lib/prawn/svg/ttf.rb +21 -17
  57. data/lib/prawn/svg/url_loader.rb +1 -1
  58. data/lib/prawn/svg/version.rb +1 -1
  59. data/lib/prawn-svg.rb +1 -0
  60. data/prawn-svg.gemspec +4 -6
  61. data/spec/integration_spec.rb +77 -70
  62. data/spec/prawn/svg/attributes/opacity_spec.rb +11 -15
  63. data/spec/prawn/svg/attributes/transform_spec.rb +6 -6
  64. data/spec/prawn/svg/calculators/aspect_ratio_spec.rb +50 -50
  65. data/spec/prawn/svg/calculators/document_sizing_spec.rb +35 -35
  66. data/spec/prawn/svg/calculators/pixels_spec.rb +31 -30
  67. data/spec/prawn/svg/color_spec.rb +31 -31
  68. data/spec/prawn/svg/css/font_family_parser_spec.rb +12 -12
  69. data/spec/prawn/svg/css/selector_parser_spec.rb +21 -21
  70. data/spec/prawn/svg/css/stylesheets_spec.rb +51 -45
  71. data/spec/prawn/svg/css/values_parser_spec.rb +16 -0
  72. data/spec/prawn/svg/document_spec.rb +15 -14
  73. data/spec/prawn/svg/elements/base_spec.rb +39 -34
  74. data/spec/prawn/svg/elements/gradient_spec.rb +39 -39
  75. data/spec/prawn/svg/elements/line_spec.rb +22 -22
  76. data/spec/prawn/svg/elements/marker_spec.rb +36 -40
  77. data/spec/prawn/svg/elements/path_spec.rb +134 -110
  78. data/spec/prawn/svg/elements/polygon_spec.rb +18 -18
  79. data/spec/prawn/svg/elements/polyline_spec.rb +16 -16
  80. data/spec/prawn/svg/elements/text_spec.rb +149 -127
  81. data/spec/prawn/svg/font_registry_spec.rb +34 -34
  82. data/spec/prawn/svg/font_spec.rb +4 -4
  83. data/spec/prawn/svg/interface_spec.rb +47 -39
  84. data/spec/prawn/svg/loaders/data_spec.rb +21 -21
  85. data/spec/prawn/svg/loaders/file_spec.rb +43 -40
  86. data/spec/prawn/svg/loaders/web_spec.rb +15 -15
  87. data/spec/prawn/svg/pathable_spec.rb +21 -21
  88. data/spec/prawn/svg/properties_spec.rb +51 -51
  89. data/spec/prawn/svg/transform_parser_spec.rb +12 -12
  90. data/spec/prawn/svg/ttf_spec.rb +5 -5
  91. data/spec/prawn/svg/url_loader_spec.rb +25 -23
  92. data/spec/spec_helper.rb +4 -4
  93. metadata +12 -143
@@ -1,45 +1,45 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Prawn::SVG::Elements::Path do
4
- let(:source) { double(name: "path", attributes: {}) }
4
+ let(:source) { double(name: 'path', attributes: {}) }
5
5
  let(:state) { Prawn::SVG::State.new }
6
6
  let(:path) { Prawn::SVG::Elements::Path.new(nil, source, [], state) }
7
7
 
8
8
  before do
9
- allow(path).to receive(:attributes).and_return("d" => d)
9
+ allow(path).to receive(:attributes).and_return('d' => d)
10
10
  end
11
11
 
12
- describe "command parsing" do
13
- context "with a valid path" do
14
- let(:d) { "m12.34 -56.78 1 2M4 5 12-34 -.5.7+3 2.3e3 4e4 4e+4 L31,-2e-5L 6,7 Z ZZa50 50 0 100 100" }
12
+ describe 'command parsing' do
13
+ context 'with a valid path' do
14
+ let(:d) { 'm12.34 -56.78 1 2M4 5 12-34 -.5.7+3 2.3e3 4e4 4e+4 L31,-2e-5L 6,7 Z ZZa50 50 0 100 100' }
15
15
 
16
- it "correctly parses" do
16
+ it 'correctly parses' do
17
17
  calls = []
18
- allow(path).to receive(:parse_path_command) {|*args| calls << args}
18
+ allow(path).to receive(:parse_path_command) { |*args| calls << args }
19
19
  path.parse
20
20
 
21
21
  expect(calls).to eq [
22
- ["m", [[12.34, -56.78], [1, 2]]],
23
- ["M", [[4, 5], [12, -34], [-0.5, 0.7], [3, 2.3e3], [4e4, 4e4]]],
24
- ["L", [[31, -2e-5]]],
25
- ["L", [[6, 7]]],
26
- ["Z", []],
27
- ["Z", []],
28
- ["Z", []],
29
- ["a", [[50, 50, 0, 1, 0, 0, 100]]],
22
+ ['m', [[12.34, -56.78], [1, 2]]],
23
+ ['M', [[4, 5], [12, -34], [-0.5, 0.7], [3, 2.3e3], [4e4, 4e4]]],
24
+ ['L', [[31, -2e-5]]],
25
+ ['L', [[6, 7]]],
26
+ ['Z', []],
27
+ ['Z', []],
28
+ ['Z', []],
29
+ ['a', [[50, 50, 0, 1, 0, 0, 100]]]
30
30
  ]
31
31
  end
32
32
  end
33
33
 
34
- context "with m and M commands" do
35
- let(:d) { "M 1,2 3,4 m 5,6 7,8" }
34
+ context 'with m and M commands' do
35
+ let(:d) { 'M 1,2 3,4 m 5,6 7,8' }
36
36
 
37
- it "treats subsequent points to m/M command as relative/absolute depending on command" do
37
+ it 'treats subsequent points to m/M command as relative/absolute depending on command' do
38
38
  [
39
- ["M", [[1,2],[3,4]]],
40
- ["L", [[3,4]]],
41
- ["m", [[5,6],[7,8]]],
42
- ["l", [[7,8]]]
39
+ ['M', [[1, 2], [3, 4]]],
40
+ ['L', [[3, 4]]],
41
+ ['m', [[5, 6], [7, 8]]],
42
+ ['l', [[7, 8]]]
43
43
  ].each do |args|
44
44
  expect(path).to receive(:parse_path_command).with(*args).and_call_original
45
45
  end
@@ -48,61 +48,64 @@ describe Prawn::SVG::Elements::Path do
48
48
  end
49
49
  end
50
50
 
51
- context "with an empty path" do
52
- let(:d) { "" }
51
+ context 'with an empty path' do
52
+ let(:d) { '' }
53
53
 
54
- it "correctly parses" do
54
+ it 'correctly parses' do
55
55
  expect(path).not_to receive(:run_path_command)
56
56
  path.parse
57
57
  end
58
58
  end
59
59
 
60
- context "with a path with invalid characters" do
61
- let(:d) { "M 10 % 20" }
60
+ context 'with a path with invalid characters' do
61
+ let(:d) { 'M 10 % 20' }
62
62
 
63
- it "raises" do
63
+ it 'raises' do
64
64
  expect { path.parse }.to raise_error(Prawn::SVG::Elements::Base::SkipElementError)
65
65
  end
66
66
  end
67
67
 
68
- context "with a path with numerical data before a command letter" do
69
- let(:d) { "M 10 % 20" }
68
+ context 'with a path with numerical data before a command letter' do
69
+ let(:d) { 'M 10 % 20' }
70
70
 
71
- it "raises" do
71
+ it 'raises' do
72
72
  expect { path.parse }.to raise_error(Prawn::SVG::Elements::Base::SkipElementError)
73
73
  end
74
74
  end
75
75
  end
76
76
 
77
- context "when given an M path" do
78
- subject { path.parse; path.commands }
77
+ context 'when given an M path' do
78
+ subject do
79
+ path.parse
80
+ path.commands
81
+ end
79
82
 
80
- context "with typical arguments" do
81
- let(:d) { "M 100 200 M 200 300 m 10 20" }
83
+ context 'with typical arguments' do
84
+ let(:d) { 'M 100 200 M 200 300 m 10 20' }
82
85
 
83
- it "issues a move command" do
86
+ it 'issues a move command' do
84
87
  expect(subject).to eq [
85
88
  Prawn::SVG::Elements::Path::Move.new([100.0, 200.0]),
86
89
  Prawn::SVG::Elements::Path::Move.new([200.0, 300.0]),
87
- Prawn::SVG::Elements::Path::Move.new([210.0, 320.0]),
90
+ Prawn::SVG::Elements::Path::Move.new([210.0, 320.0])
88
91
  ]
89
92
  end
90
93
  end
91
94
 
92
- context "with only one argument" do
93
- let(:d) { "M 100 200 M 100" }
95
+ context 'with only one argument' do
96
+ let(:d) { 'M 100 200 M 100' }
94
97
 
95
- it "bails out" do
98
+ it 'bails out' do
96
99
  expect(subject).to eq [
97
100
  Prawn::SVG::Elements::Path::Move.new([100.0, 200.0])
98
101
  ]
99
102
  end
100
103
  end
101
104
 
102
- context "with no arguments" do
103
- let(:d) { "M 100 200 M" }
105
+ context 'with no arguments' do
106
+ let(:d) { 'M 100 200 M' }
104
107
 
105
- it "bails out" do
108
+ it 'bails out' do
106
109
  expect(subject).to eq [
107
110
  Prawn::SVG::Elements::Path::Move.new([100.0, 200.0])
108
111
  ]
@@ -110,25 +113,28 @@ describe Prawn::SVG::Elements::Path do
110
113
  end
111
114
  end
112
115
 
113
- context "when given an L path" do
114
- subject { path.parse; path.commands }
116
+ context 'when given an L path' do
117
+ subject do
118
+ path.parse
119
+ path.commands
120
+ end
115
121
 
116
- context "with typical arguments" do
117
- let(:d) { "M 100 200 L 200 300 l 10 20" }
122
+ context 'with typical arguments' do
123
+ let(:d) { 'M 100 200 L 200 300 l 10 20' }
118
124
 
119
- it "issues a line command" do
125
+ it 'issues a line command' do
120
126
  expect(subject).to eq [
121
127
  Prawn::SVG::Elements::Path::Move.new([100.0, 200.0]),
122
128
  Prawn::SVG::Elements::Path::Line.new([200.0, 300.0]),
123
- Prawn::SVG::Elements::Path::Line.new([210.0, 320.0]),
129
+ Prawn::SVG::Elements::Path::Line.new([210.0, 320.0])
124
130
  ]
125
131
  end
126
132
  end
127
133
 
128
- context "with only one argument" do
129
- let(:d) { "M 100 200 L 100" }
134
+ context 'with only one argument' do
135
+ let(:d) { 'M 100 200 L 100' }
130
136
 
131
- it "bails out" do
137
+ it 'bails out' do
132
138
  expect(subject).to eq [
133
139
  Prawn::SVG::Elements::Path::Move.new([100.0, 200.0])
134
140
  ]
@@ -136,24 +142,27 @@ describe Prawn::SVG::Elements::Path do
136
142
  end
137
143
  end
138
144
 
139
- context "when given a C path" do
140
- subject { path.parse; path.commands }
145
+ context 'when given a C path' do
146
+ subject do
147
+ path.parse
148
+ path.commands
149
+ end
141
150
 
142
- context "with typical arguments" do
143
- let(:d) { "M 100 200 C 10 20 30 40 200 300" }
151
+ context 'with typical arguments' do
152
+ let(:d) { 'M 100 200 C 10 20 30 40 200 300' }
144
153
 
145
- it "issues a curve command" do
154
+ it 'issues a curve command' do
146
155
  expect(subject).to eq [
147
156
  Prawn::SVG::Elements::Path::Move.new([100.0, 200.0]),
148
- Prawn::SVG::Elements::Path::Curve.new([200.0, 300.0], [10, 20], [30, 40]),
157
+ Prawn::SVG::Elements::Path::Curve.new([200.0, 300.0], [10, 20], [30, 40])
149
158
  ]
150
159
  end
151
160
  end
152
161
 
153
- context "with incomplete arguments" do
154
- let(:d) { "M 100 200 C 10 20 30 40 50" }
162
+ context 'with incomplete arguments' do
163
+ let(:d) { 'M 100 200 C 10 20 30 40 50' }
155
164
 
156
- it "bails out" do
165
+ it 'bails out' do
157
166
  expect(subject).to eq [
158
167
  Prawn::SVG::Elements::Path::Move.new([100.0, 200.0])
159
168
  ]
@@ -161,24 +170,27 @@ describe Prawn::SVG::Elements::Path do
161
170
  end
162
171
  end
163
172
 
164
- context "when given an S path" do
165
- subject { path.parse; path.commands }
173
+ context 'when given an S path' do
174
+ subject do
175
+ path.parse
176
+ path.commands
177
+ end
166
178
 
167
- context "with typical arguments" do
168
- let(:d) { "M 100 200 S 30 40 200 300" }
179
+ context 'with typical arguments' do
180
+ let(:d) { 'M 100 200 S 30 40 200 300' }
169
181
 
170
- it "issues a curve command" do
182
+ it 'issues a curve command' do
171
183
  expect(subject).to eq [
172
184
  Prawn::SVG::Elements::Path::Move.new([100.0, 200.0]),
173
- Prawn::SVG::Elements::Path::Curve.new([200.0, 300.0], [100, 200], [30, 40]),
185
+ Prawn::SVG::Elements::Path::Curve.new([200.0, 300.0], [100, 200], [30, 40])
174
186
  ]
175
187
  end
176
188
  end
177
189
 
178
- context "with incomplete arguments" do
179
- let(:d) { "M 100 200 S 30 40 50" }
190
+ context 'with incomplete arguments' do
191
+ let(:d) { 'M 100 200 S 30 40 50' }
180
192
 
181
- it "bails out" do
193
+ it 'bails out' do
182
194
  expect(subject).to eq [
183
195
  Prawn::SVG::Elements::Path::Move.new([100.0, 200.0])
184
196
  ]
@@ -186,13 +198,16 @@ describe Prawn::SVG::Elements::Path do
186
198
  end
187
199
  end
188
200
 
189
- context "when given a Q path" do
190
- subject { path.parse; path.commands }
201
+ context 'when given a Q path' do
202
+ subject do
203
+ path.parse
204
+ path.commands
205
+ end
191
206
 
192
- context "with typical arguments" do
193
- let(:d) { "M 0 0 Q 600 300 300 600" }
207
+ context 'with typical arguments' do
208
+ let(:d) { 'M 0 0 Q 600 300 300 600' }
194
209
 
195
- it "issues a curve command" do
210
+ it 'issues a curve command' do
196
211
  expect(subject).to eq [
197
212
  Prawn::SVG::Elements::Path::Move.new([0, 0]),
198
213
  Prawn::SVG::Elements::Path::Curve.new([300.0, 600.0], [400, 200], [500, 400])
@@ -200,10 +215,10 @@ describe Prawn::SVG::Elements::Path do
200
215
  end
201
216
  end
202
217
 
203
- context "with incomplete arguments" do
204
- let(:d) { "M 100 200 Q 30 40 50" }
218
+ context 'with incomplete arguments' do
219
+ let(:d) { 'M 100 200 Q 30 40 50' }
205
220
 
206
- it "bails out" do
221
+ it 'bails out' do
207
222
  expect(subject).to eq [
208
223
  Prawn::SVG::Elements::Path::Move.new([100.0, 200.0])
209
224
  ]
@@ -211,13 +226,16 @@ describe Prawn::SVG::Elements::Path do
211
226
  end
212
227
  end
213
228
 
214
- context "when given a T path" do
215
- subject { path.parse; path.commands }
229
+ context 'when given a T path' do
230
+ subject do
231
+ path.parse
232
+ path.commands
233
+ end
216
234
 
217
- context "with typical arguments" do
218
- let(:d) { "M 0 0 T 300 600" }
235
+ context 'with typical arguments' do
236
+ let(:d) { 'M 0 0 T 300 600' }
219
237
 
220
- it "issues a curve command" do
238
+ it 'issues a curve command' do
221
239
  expect(subject).to eq [
222
240
  Prawn::SVG::Elements::Path::Move.new([0, 0]),
223
241
  Prawn::SVG::Elements::Path::Curve.new([300.0, 600.0], [0, 0], [100, 200])
@@ -225,10 +243,10 @@ describe Prawn::SVG::Elements::Path do
225
243
  end
226
244
  end
227
245
 
228
- context "with incomplete arguments" do
229
- let(:d) { "M 100 200 T 30" }
246
+ context 'with incomplete arguments' do
247
+ let(:d) { 'M 100 200 T 30' }
230
248
 
231
- it "bails out" do
249
+ it 'bails out' do
232
250
  expect(subject).to eq [
233
251
  Prawn::SVG::Elements::Path::Move.new([100.0, 200.0])
234
252
  ]
@@ -236,35 +254,40 @@ describe Prawn::SVG::Elements::Path do
236
254
  end
237
255
  end
238
256
 
239
- context "when given an A path" do
240
- subject { path.parse; path.commands }
257
+ context 'when given an A path' do
258
+ subject do
259
+ path.parse
260
+ path.commands
261
+ end
241
262
 
242
- context "that is pretty normal" do
243
- let(:d) { "M 100 200 A 10 10 0 0 1 200 200" }
263
+ context 'that is pretty normal' do
264
+ let(:d) { 'M 100 200 A 10 10 0 0 1 200 200' }
244
265
 
245
- it "uses bezier curves to approximate an arc path" do
266
+ it 'uses bezier curves to approximate an arc path' do
246
267
  expect(subject).to eq [
247
268
  Prawn::SVG::Elements::Path::Move.new([100.0, 200.0]),
248
- Prawn::SVG::Elements::Path::Curve.new([150.0, 150.0], [100.0, 172.57081148225683], [122.57081148225683, 150.0]),
249
- Prawn::SVG::Elements::Path::Curve.new([200.0, 200.0], [177.42918851774317, 150.0], [200.0, 172.57081148225683])
269
+ Prawn::SVG::Elements::Path::Curve.new([150.0, 150.0], [100.0, 172.57081148225683],
270
+ [122.57081148225683, 150.0]),
271
+ Prawn::SVG::Elements::Path::Curve.new([200.0, 200.0], [177.42918851774317, 150.0],
272
+ [200.0, 172.57081148225683])
250
273
  ]
251
274
  end
252
275
  end
253
276
 
254
- context "with an identical start and end point" do
255
- let(:d) { "M 100 200 A 30 30 0 0 1 100 200" }
277
+ context 'with an identical start and end point' do
278
+ let(:d) { 'M 100 200 A 30 30 0 0 1 100 200' }
256
279
 
257
- it "ignores the path" do
280
+ it 'ignores the path' do
258
281
  expect(subject).to eq [
259
- Prawn::SVG::Elements::Path::Move.new([100.0, 200.0]),
282
+ Prawn::SVG::Elements::Path::Move.new([100.0, 200.0])
260
283
  ]
261
284
  end
262
285
  end
263
286
 
264
- context "with an rx of 0" do
265
- let(:d) { "M 100 200 A 0 10 0 0 1 200 200" }
287
+ context 'with an rx of 0' do
288
+ let(:d) { 'M 100 200 A 0 10 0 0 1 200 200' }
266
289
 
267
- it "substitutes a line_to" do
290
+ it 'substitutes a line_to' do
268
291
  expect(subject).to eq [
269
292
  Prawn::SVG::Elements::Path::Move.new([100.0, 200.0]),
270
293
  Prawn::SVG::Elements::Path::Line.new([200.0, 200.0])
@@ -272,10 +295,10 @@ describe Prawn::SVG::Elements::Path do
272
295
  end
273
296
  end
274
297
 
275
- context "with an ry of 0" do
276
- let(:d) { "M 100 200 A 10 0 0 0 1 200 200" }
298
+ context 'with an ry of 0' do
299
+ let(:d) { 'M 100 200 A 10 0 0 0 1 200 200' }
277
300
 
278
- it "substitutes a line_to" do
301
+ it 'substitutes a line_to' do
279
302
  expect(subject).to eq [
280
303
  Prawn::SVG::Elements::Path::Move.new([100.0, 200.0]),
281
304
  Prawn::SVG::Elements::Path::Line.new([200.0, 200.0])
@@ -283,24 +306,25 @@ describe Prawn::SVG::Elements::Path do
283
306
  end
284
307
  end
285
308
 
286
- context "with incomplete arguments" do
287
- let(:d) { "M 100 200 A 10 20 30 L 10 20" }
309
+ context 'with incomplete arguments' do
310
+ let(:d) { 'M 100 200 A 10 20 30 L 10 20' }
288
311
 
289
- it "bails out" do
312
+ it 'bails out' do
290
313
  expect(subject).to eq [
291
314
  Prawn::SVG::Elements::Path::Move.new([100.0, 200.0])
292
315
  ]
293
316
  end
294
317
  end
295
318
 
296
- context "with highly-compressed flags" do
297
- let(:d) { "M100,100a50 50 0 100 100" }
319
+ context 'with highly-compressed flags' do
320
+ let(:d) { 'M100,100a50 50 0 100 100' }
298
321
 
299
- it "correctly parses them" do
322
+ it 'correctly parses them' do
300
323
  expect(subject).to eq [
301
324
  Prawn::SVG::Elements::Path::Move.new([100.0, 100.0]),
302
325
  Prawn::SVG::Elements::Path::Curve.new([50.0, 150.0], [72.57081148225681, 100.0], [50.0, 122.57081148225681]),
303
- Prawn::SVG::Elements::Path::Curve.new([99.99999999999999, 200.0], [50.0, 177.42918851774317], [72.5708114822568, 200.0])
326
+ Prawn::SVG::Elements::Path::Curve.new([99.99999999999999, 200.0], [50.0, 177.42918851774317],
327
+ [72.5708114822568, 200.0])
304
328
  ]
305
329
  end
306
330
  end
@@ -1,47 +1,47 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  RSpec.describe Prawn::SVG::Elements::Polygon do
4
- let(:document) { Prawn::SVG::Document.new(svg, [800, 600], {width: 800, height: 600}) }
4
+ let(:document) { Prawn::SVG::Document.new(svg, [800, 600], { width: 800, height: 600 }) }
5
5
 
6
6
  subject do
7
7
  Prawn::SVG::Elements::Polygon.new(document, document.root, [], Prawn::SVG::State.new)
8
8
  end
9
9
 
10
- context "with a valid points attribute" do
10
+ context 'with a valid points attribute' do
11
11
  let(:svg) { '<polygon points="10 10 20,20 30,30" />' }
12
12
 
13
- it "renders the polygon" do
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", [], {}, []]]
21
- ]
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
+ ]]
22
22
  ]
23
23
  end
24
24
  end
25
25
 
26
- context "with a polygon that has an odd number of arguments" do
26
+ context 'with a polygon that has an odd number of arguments' do
27
27
  let(:svg) { '<polygon points="10 10 20,20 30" />' }
28
28
 
29
- it "ignores the last one" do
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", [], {}, []]]
36
- ]
32
+ ['fill', [], {}, [
33
+ ['move_to', [[10.0, 590.0]], {}, []],
34
+ ['line_to', [[20.0, 580.0]], {}, []],
35
+ ['close_path', [], {}, []]
36
+ ]]
37
37
  ]
38
38
  end
39
39
  end
40
40
 
41
- context "with a polygon that has no arguments" do
41
+ context 'with a polygon that has no arguments' do
42
42
  let(:svg) { '<polygon points="" />' }
43
43
 
44
- it "renders nothing" do
44
+ it 'renders nothing' do
45
45
  subject.process
46
46
  expect(subject.base_calls).to eq []
47
47
  end
@@ -1,45 +1,45 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  RSpec.describe Prawn::SVG::Elements::Polyline do
4
- let(:document) { Prawn::SVG::Document.new(svg, [800, 600], {width: 800, height: 600}) }
4
+ let(:document) { Prawn::SVG::Document.new(svg, [800, 600], { width: 800, height: 600 }) }
5
5
 
6
6
  subject do
7
7
  Prawn::SVG::Elements::Polyline.new(document, document.root, [], Prawn::SVG::State.new)
8
8
  end
9
9
 
10
- context "with a valid points attribute" do
10
+ context 'with a valid points attribute' do
11
11
  let(:svg) { '<polyline points="10 10 20,20 30,30" />' }
12
12
 
13
- it "renders the polyline" do
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]], {}, []]]
20
- ]
16
+ ['fill', [], {}, [
17
+ ['move_to', [[10.0, 590.0]], {}, []],
18
+ ['line_to', [[20.0, 580.0]], {}, []],
19
+ ['line_to', [[30.0, 570.0]], {}, []]
20
+ ]]
21
21
  ]
22
22
  end
23
23
  end
24
24
 
25
- context "with a polyline that has an odd number of arguments" do
25
+ context 'with a polyline that has an odd number of arguments' do
26
26
  let(:svg) { '<polyline points="10 10 20,20 30" />' }
27
27
 
28
- it "ignores the last one" do
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]], {}, []]]
34
- ]
31
+ ['fill', [], {}, [
32
+ ['move_to', [[10.0, 590.0]], {}, []],
33
+ ['line_to', [[20.0, 580.0]], {}, []]
34
+ ]]
35
35
  ]
36
36
  end
37
37
  end
38
38
 
39
- context "with a polyline that has no arguments" do
39
+ context 'with a polyline that has no arguments' do
40
40
  let(:svg) { '<polyline points="" />' }
41
41
 
42
- it "renders nothing" do
42
+ it 'renders nothing' do
43
43
  subject.process
44
44
  expect(subject.base_calls).to eq []
45
45
  end