prawn 2.0.2 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/data/images/blend_modes_bottom_layer.jpg +0 -0
- data/data/images/blend_modes_top_layer.jpg +0 -0
- data/data/images/indexed_transparency.png +0 -0
- data/data/images/indexed_transparency_alpha.dat +0 -0
- data/data/images/indexed_transparency_color.dat +0 -0
- data/lib/prawn.rb +2 -1
- data/lib/prawn/document.rb +1 -0
- data/lib/prawn/document/internals.rb +10 -2
- data/lib/prawn/font.rb +14 -1
- data/lib/prawn/graphics.rb +2 -0
- data/lib/prawn/graphics/blend_mode.rb +64 -0
- data/lib/prawn/graphics/patterns.rb +52 -16
- data/lib/prawn/graphics/transformation.rb +3 -0
- data/lib/prawn/images/png.rb +43 -5
- data/lib/prawn/text/formatted/arranger.rb +25 -17
- data/lib/prawn/text/formatted/line_wrap.rb +2 -3
- data/lib/prawn/transformation_stack.rb +42 -0
- data/lib/prawn/version.rb +1 -1
- data/manual/graphics/blend_mode.rb +49 -0
- data/manual/graphics/graphics.rb +1 -0
- data/manual/graphics/soft_masks.rb +1 -1
- data/prawn.gemspec +4 -5
- data/spec/acceptance/png_spec.rb +35 -0
- data/spec/blend_mode_spec.rb +71 -0
- data/spec/document_spec.rb +72 -76
- data/spec/font_spec.rb +11 -11
- data/spec/formatted_text_arranger_spec.rb +178 -149
- data/spec/formatted_text_box_spec.rb +23 -23
- data/spec/graphics_spec.rb +67 -28
- data/spec/image_handler_spec.rb +7 -7
- data/spec/images_spec.rb +1 -1
- data/spec/png_spec.rb +26 -4
- data/spec/repeater_spec.rb +9 -9
- data/spec/spec_helper.rb +1 -4
- data/spec/text_at_spec.rb +2 -2
- data/spec/text_box_spec.rb +20 -16
- data/spec/text_spec.rb +8 -14
- data/spec/transformation_stack_spec.rb +63 -0
- data/spec/view_spec.rb +10 -10
- metadata +27 -31
- data/data/images/pal_bk.png +0 -0
- data/spec/acceptance/png.rb +0 -24
- data/spec/extensions/mocha.rb +0 -45
data/spec/text_spec.rb
CHANGED
@@ -63,7 +63,7 @@ describe "#text" do
|
|
63
63
|
end
|
64
64
|
|
65
65
|
it "should ignore call when string is nil" do
|
66
|
-
expect(@pdf.text(nil)).to
|
66
|
+
expect(@pdf.text(nil)).to eq false
|
67
67
|
end
|
68
68
|
|
69
69
|
it "should correctly render empty paragraphs" do
|
@@ -91,13 +91,13 @@ describe "#text" do
|
|
91
91
|
it "should default to use kerning information" do
|
92
92
|
@pdf.text "hello world"
|
93
93
|
text = PDF::Inspector::Text.analyze(@pdf.render)
|
94
|
-
expect(text.kerned[0]).to
|
94
|
+
expect(text.kerned[0]).to eq true
|
95
95
|
end
|
96
96
|
|
97
97
|
it "should be able to disable kerning with an option" do
|
98
98
|
@pdf.text "hello world", :kerning => false
|
99
99
|
text = PDF::Inspector::Text.analyze(@pdf.render)
|
100
|
-
expect(text.kerned[0]).to
|
100
|
+
expect(text.kerned[0]).to eq false
|
101
101
|
end
|
102
102
|
|
103
103
|
it "should be able to disable kerning document-wide" do
|
@@ -105,14 +105,14 @@ describe "#text" do
|
|
105
105
|
@pdf.default_kerning = false
|
106
106
|
@pdf.text "hello world"
|
107
107
|
text = PDF::Inspector::Text.analyze(@pdf.render)
|
108
|
-
expect(text.kerned[0]).to
|
108
|
+
expect(text.kerned[0]).to eq false
|
109
109
|
end
|
110
110
|
|
111
111
|
it "option should be able to override document-wide kerning disabling" do
|
112
112
|
@pdf.default_kerning = false
|
113
113
|
@pdf.text "hello world", :kerning => true
|
114
114
|
text = PDF::Inspector::Text.analyze(@pdf.render)
|
115
|
-
expect(text.kerned[0]).to
|
115
|
+
expect(text.kerned[0]).to eq true
|
116
116
|
end
|
117
117
|
|
118
118
|
it "should raise_error ArgumentError if :at option included" do
|
@@ -480,25 +480,19 @@ describe "#text" do
|
|
480
480
|
describe "kerning" do
|
481
481
|
it "should respect text kerning setting (document default)" do
|
482
482
|
create_pdf
|
483
|
-
@pdf.font.
|
484
|
-
str == "VAT" && options[:kerning] == true
|
485
|
-
end.at_least_once.returns(10)
|
483
|
+
expect(@pdf.font).to receive(:compute_width_of).with("VAT", hash_including(kerning: true)).and_return(10)
|
486
484
|
@pdf.text "VAT"
|
487
485
|
end
|
488
486
|
|
489
487
|
it "should respect text kerning setting (kerning=true)" do
|
490
488
|
create_pdf
|
491
|
-
@pdf.font.
|
492
|
-
str == "VAT" && options[:kerning] == true
|
493
|
-
end.at_least_once.returns(10)
|
489
|
+
expect(@pdf.font).to receive(:compute_width_of).with("VAT", hash_including(kerning: true)).at_least(:once).and_return(10)
|
494
490
|
@pdf.text "VAT", :kerning => true
|
495
491
|
end
|
496
492
|
|
497
493
|
it "should respect text kerning setting (kerning=false)" do
|
498
494
|
create_pdf
|
499
|
-
@pdf.font.
|
500
|
-
str == "VAT" && options[:kerning] == false
|
501
|
-
end.at_least_once.returns(10)
|
495
|
+
expect(@pdf.font).to receive(:compute_width_of).with("VAT", hash_including(kerning: false)).at_least(:once).and_return(10)
|
502
496
|
@pdf.text "VAT", :kerning => false
|
503
497
|
end
|
504
498
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
|
4
|
+
|
5
|
+
describe Prawn::TransformationStack do
|
6
|
+
before { create_pdf }
|
7
|
+
before { pdf.add_to_transformation_stack(2, 0, 0, 2, 100, 100) }
|
8
|
+
|
9
|
+
let(:pdf) { @pdf }
|
10
|
+
let(:stack) { @pdf.instance_variable_get(:@transformation_stack) }
|
11
|
+
|
12
|
+
describe "#add_to_transformation_stack" do
|
13
|
+
it "creates and adds to the stack" do
|
14
|
+
pdf.add_to_transformation_stack(1, 0, 0, 1, 20, 20)
|
15
|
+
|
16
|
+
expect(stack).to eq [[[2, 0, 0, 2, 100, 100], [1, 0, 0, 1, 20, 20]]]
|
17
|
+
end
|
18
|
+
|
19
|
+
it "adds to the last stack" do
|
20
|
+
pdf.save_transformation_stack
|
21
|
+
pdf.add_to_transformation_stack(1, 0, 0, 1, 20, 20)
|
22
|
+
|
23
|
+
expect(stack).to eq [
|
24
|
+
[[2, 0, 0, 2, 100, 100]],
|
25
|
+
[[2, 0, 0, 2, 100, 100], [1, 0, 0, 1, 20, 20]]
|
26
|
+
]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#save_transformation_stack" do
|
31
|
+
it "clones the last stack" do
|
32
|
+
pdf.save_transformation_stack
|
33
|
+
|
34
|
+
expect(stack.length).to eq 2
|
35
|
+
expect(stack.first).to eq stack.last
|
36
|
+
expect(stack.first).to_not be stack.last
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "#restore_transformation_stack" do
|
41
|
+
it "pops off the last stack" do
|
42
|
+
pdf.save_transformation_stack
|
43
|
+
pdf.add_to_transformation_stack(1, 0, 0, 1, 20, 20)
|
44
|
+
pdf.restore_transformation_stack
|
45
|
+
|
46
|
+
expect(stack).to eq [[[2, 0, 0, 2, 100, 100]]]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "current_transformation_matrix_with_translation" do
|
51
|
+
before do
|
52
|
+
pdf.add_to_transformation_stack(1, 0, 0, 1, 20, 20)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "calculates the last transformation" do
|
56
|
+
expect(pdf.current_transformation_matrix_with_translation).to eq [2, 0, 0, 2, 140, 140]
|
57
|
+
end
|
58
|
+
|
59
|
+
it "adds the supplied x and y coordinates to the transformation stack" do
|
60
|
+
expect(pdf.current_transformation_matrix_with_translation(15, 15)).to eq [2, 0, 0, 2, 170, 170]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/spec/view_spec.rb
CHANGED
@@ -10,20 +10,20 @@ describe "Prawn::View" do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
it "delegates unhandled methods to object returned by document method" do
|
13
|
-
doc =
|
14
|
-
view_object.
|
13
|
+
doc = double("Document")
|
14
|
+
allow(view_object).to receive(:document).and_return(doc)
|
15
15
|
|
16
|
-
doc.
|
16
|
+
expect(doc).to receive(:some_delegated_method)
|
17
17
|
|
18
18
|
view_object.some_delegated_method
|
19
19
|
end
|
20
20
|
|
21
21
|
it "allows a block-like DSL via the update method" do
|
22
|
-
doc =
|
23
|
-
view_object.
|
22
|
+
doc = double("Document")
|
23
|
+
allow(view_object).to receive(:document).and_return(doc)
|
24
24
|
|
25
|
-
doc.
|
26
|
-
doc.
|
25
|
+
expect(doc).to receive(:foo)
|
26
|
+
expect(doc).to receive(:bar)
|
27
27
|
|
28
28
|
view_object.update do
|
29
29
|
foo
|
@@ -32,10 +32,10 @@ describe "Prawn::View" do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it "aliases save_as() to document.render_file()" do
|
35
|
-
doc =
|
36
|
-
doc.
|
35
|
+
doc = double("Document")
|
36
|
+
expect(doc).to receive(:render_file)
|
37
37
|
|
38
|
-
view_object.
|
38
|
+
allow(view_object).to receive(:document).and_return(doc)
|
39
39
|
|
40
40
|
view_object.save_as("foo.pdf")
|
41
41
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prawn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregory Brown
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date:
|
15
|
+
date: 2016-03-01 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: ttfunk
|
@@ -34,28 +34,28 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - "~>"
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 0.6.
|
37
|
+
version: 0.6.1
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
41
|
requirements:
|
42
42
|
- - "~>"
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
version: 0.6.
|
44
|
+
version: 0.6.1
|
45
45
|
- !ruby/object:Gem::Dependency
|
46
46
|
name: pdf-inspector
|
47
47
|
requirement: !ruby/object:Gem::Requirement
|
48
48
|
requirements:
|
49
49
|
- - "~>"
|
50
50
|
- !ruby/object:Gem::Version
|
51
|
-
version: 1.2.
|
51
|
+
version: 1.2.1
|
52
52
|
type: :development
|
53
53
|
prerelease: false
|
54
54
|
version_requirements: !ruby/object:Gem::Requirement
|
55
55
|
requirements:
|
56
56
|
- - "~>"
|
57
57
|
- !ruby/object:Gem::Version
|
58
|
-
version: 1.2.
|
58
|
+
version: 1.2.1
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: yard
|
61
61
|
requirement: !ruby/object:Gem::Requirement
|
@@ -74,30 +74,16 @@ dependencies:
|
|
74
74
|
name: rspec
|
75
75
|
requirement: !ruby/object:Gem::Requirement
|
76
76
|
requirements:
|
77
|
-
- -
|
78
|
-
- !ruby/object:Gem::Version
|
79
|
-
version: 2.14.1
|
80
|
-
type: :development
|
81
|
-
prerelease: false
|
82
|
-
version_requirements: !ruby/object:Gem::Requirement
|
83
|
-
requirements:
|
84
|
-
- - '='
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
version: 2.14.1
|
87
|
-
- !ruby/object:Gem::Dependency
|
88
|
-
name: mocha
|
89
|
-
requirement: !ruby/object:Gem::Requirement
|
90
|
-
requirements:
|
91
|
-
- - ">="
|
77
|
+
- - "~>"
|
92
78
|
- !ruby/object:Gem::Version
|
93
|
-
version: '0'
|
79
|
+
version: '3.0'
|
94
80
|
type: :development
|
95
81
|
prerelease: false
|
96
82
|
version_requirements: !ruby/object:Gem::Requirement
|
97
83
|
requirements:
|
98
|
-
- - "
|
84
|
+
- - "~>"
|
99
85
|
- !ruby/object:Gem::Version
|
100
|
-
version: '0'
|
86
|
+
version: '3.0'
|
101
87
|
- !ruby/object:Gem::Dependency
|
102
88
|
name: rake
|
103
89
|
requirement: !ruby/object:Gem::Requirement
|
@@ -221,6 +207,8 @@ files:
|
|
221
207
|
- data/images/16bit.png
|
222
208
|
- data/images/arrow.png
|
223
209
|
- data/images/arrow2.png
|
210
|
+
- data/images/blend_modes_bottom_layer.jpg
|
211
|
+
- data/images/blend_modes_top_layer.jpg
|
224
212
|
- data/images/dice.alpha
|
225
213
|
- data/images/dice.color
|
226
214
|
- data/images/dice.png
|
@@ -228,12 +216,14 @@ files:
|
|
228
216
|
- data/images/fractal.jpg
|
229
217
|
- data/images/indexed_color.dat
|
230
218
|
- data/images/indexed_color.png
|
219
|
+
- data/images/indexed_transparency.png
|
220
|
+
- data/images/indexed_transparency_alpha.dat
|
221
|
+
- data/images/indexed_transparency_color.dat
|
231
222
|
- data/images/letterhead.jpg
|
232
223
|
- data/images/license.md
|
233
224
|
- data/images/page_white_text.alpha
|
234
225
|
- data/images/page_white_text.color
|
235
226
|
- data/images/page_white_text.png
|
236
|
-
- data/images/pal_bk.png
|
237
227
|
- data/images/pigs.jpg
|
238
228
|
- data/images/prawn.png
|
239
229
|
- data/images/ruport.png
|
@@ -271,6 +261,7 @@ files:
|
|
271
261
|
- lib/prawn/font/ttf.rb
|
272
262
|
- lib/prawn/font_metric_cache.rb
|
273
263
|
- lib/prawn/graphics.rb
|
264
|
+
- lib/prawn/graphics/blend_mode.rb
|
274
265
|
- lib/prawn/graphics/cap_style.rb
|
275
266
|
- lib/prawn/graphics/color.rb
|
276
267
|
- lib/prawn/graphics/dash.rb
|
@@ -301,6 +292,7 @@ files:
|
|
301
292
|
- lib/prawn/text/formatted/line_wrap.rb
|
302
293
|
- lib/prawn/text/formatted/parser.rb
|
303
294
|
- lib/prawn/text/formatted/wrap.rb
|
295
|
+
- lib/prawn/transformation_stack.rb
|
304
296
|
- lib/prawn/utilities.rb
|
305
297
|
- lib/prawn/version.rb
|
306
298
|
- lib/prawn/view.rb
|
@@ -330,6 +322,7 @@ files:
|
|
330
322
|
- manual/document_and_page_options/page_size.rb
|
331
323
|
- manual/document_and_page_options/print_scaling.rb
|
332
324
|
- manual/example_helper.rb
|
325
|
+
- manual/graphics/blend_mode.rb
|
333
326
|
- manual/graphics/circle_and_ellipse.rb
|
334
327
|
- manual/graphics/color.rb
|
335
328
|
- manual/graphics/common_lines.rb
|
@@ -404,15 +397,15 @@ files:
|
|
404
397
|
- manual/text/utf8.rb
|
405
398
|
- manual/text/win_ansi_charset.rb
|
406
399
|
- prawn.gemspec
|
407
|
-
- spec/acceptance/
|
400
|
+
- spec/acceptance/png_spec.rb
|
408
401
|
- spec/annotations_spec.rb
|
402
|
+
- spec/blend_mode_spec.rb
|
409
403
|
- spec/bounding_box_spec.rb
|
410
404
|
- spec/column_box_spec.rb
|
411
405
|
- spec/data/curves.pdf
|
412
406
|
- spec/destinations_spec.rb
|
413
407
|
- spec/document_spec.rb
|
414
408
|
- spec/extensions/encoding_helpers.rb
|
415
|
-
- spec/extensions/mocha.rb
|
416
409
|
- spec/font_metric_cache_spec.rb
|
417
410
|
- spec/font_spec.rb
|
418
411
|
- spec/formatted_text_arranger_spec.rb
|
@@ -442,13 +435,14 @@ files:
|
|
442
435
|
- spec/text_spacing_spec.rb
|
443
436
|
- spec/text_spec.rb
|
444
437
|
- spec/text_with_inline_formatting_spec.rb
|
438
|
+
- spec/transformation_stack_spec.rb
|
445
439
|
- spec/transparency_spec.rb
|
446
440
|
- spec/view_spec.rb
|
447
441
|
homepage: http://prawn.majesticseacreature.com
|
448
442
|
licenses:
|
449
|
-
-
|
450
|
-
- GPL-2
|
451
|
-
- GPL-3
|
443
|
+
- PRAWN
|
444
|
+
- GPL-2.0
|
445
|
+
- GPL-3.0
|
452
446
|
metadata: {}
|
453
447
|
post_install_message:
|
454
448
|
rdoc_options: []
|
@@ -466,12 +460,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
466
460
|
version: 1.3.6
|
467
461
|
requirements: []
|
468
462
|
rubyforge_project: prawn
|
469
|
-
rubygems_version: 2.4.5
|
463
|
+
rubygems_version: 2.4.5.1
|
470
464
|
signing_key:
|
471
465
|
specification_version: 4
|
472
466
|
summary: A fast and nimble PDF generator for Ruby
|
473
467
|
test_files:
|
474
468
|
- spec/annotations_spec.rb
|
469
|
+
- spec/blend_mode_spec.rb
|
475
470
|
- spec/bounding_box_spec.rb
|
476
471
|
- spec/column_box_spec.rb
|
477
472
|
- spec/destinations_spec.rb
|
@@ -504,6 +499,7 @@ test_files:
|
|
504
499
|
- spec/text_spacing_spec.rb
|
505
500
|
- spec/text_spec.rb
|
506
501
|
- spec/text_with_inline_formatting_spec.rb
|
502
|
+
- spec/transformation_stack_spec.rb
|
507
503
|
- spec/transparency_spec.rb
|
508
504
|
- spec/view_spec.rb
|
509
505
|
has_rdoc:
|
data/data/images/pal_bk.png
DELETED
Binary file
|
data/spec/acceptance/png.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require_relative "../../lib/prawn"
|
4
|
-
|
5
|
-
images = [
|
6
|
-
["Type 0", "#{Prawn::BASEDIR}/data/images/web-links.png"],
|
7
|
-
["Type 2", "#{Prawn::BASEDIR}/data/images/ruport.png"],
|
8
|
-
["Type 3", "#{Prawn::BASEDIR}/data/images/indexed_color.png"],
|
9
|
-
["Type 4", "#{Prawn::BASEDIR}/data/images/page_white_text.png"],
|
10
|
-
["Type 6", "#{Prawn::BASEDIR}/data/images/dice.png"]
|
11
|
-
]
|
12
|
-
|
13
|
-
Prawn::Document.generate("png_types.pdf", :page_size => "A5") do
|
14
|
-
images.each do |header, file|
|
15
|
-
start_new_page unless header.include?("0")
|
16
|
-
|
17
|
-
fill_color "FF0000"
|
18
|
-
|
19
|
-
fill_rectangle bounds.top_left, bounds.width, bounds.height
|
20
|
-
text header
|
21
|
-
|
22
|
-
image file, :at => [50, 450]
|
23
|
-
end
|
24
|
-
end
|
data/spec/extensions/mocha.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
# Allow speccing things when an expectation matcher runs. Similar to #with, but
|
4
|
-
# always succeeds.
|
5
|
-
#
|
6
|
-
# @pdf.expects(:stroke_line).checking do |from, to|
|
7
|
-
# @pdf.map_to_absolute(from).should == [0, 0]
|
8
|
-
# end
|
9
|
-
#
|
10
|
-
# Note that the outer expectation does *not* fail only because the inner one
|
11
|
-
# does; in the above example, the outer expectation would only fail if
|
12
|
-
# stroke_line were not called.
|
13
|
-
|
14
|
-
class ParameterChecker < Mocha::ParametersMatcher
|
15
|
-
def initialize(&matching_block)
|
16
|
-
@expected_parameters = [Mocha::ParameterMatchers::AnyParameters.new]
|
17
|
-
@matching_block = matching_block
|
18
|
-
end
|
19
|
-
|
20
|
-
def match?(actual_parameters = [])
|
21
|
-
@matching_block.call(*actual_parameters)
|
22
|
-
|
23
|
-
true # always succeed
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
class Mocha::Expectation
|
28
|
-
def checking(&block)
|
29
|
-
@parameters_matcher = ParameterChecker.new(&block)
|
30
|
-
self
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
# Equivalent to expects(method_name).at_least(0). More useful when combined
|
35
|
-
# with parameter matchers to ignore certain calls for the sake of parameter
|
36
|
-
# matching.
|
37
|
-
#
|
38
|
-
# @pdf.ignores(:stroke_color=).with("000000")
|
39
|
-
# @pdf.expects(:stroke_color=).with("ff0000")
|
40
|
-
#
|
41
|
-
module Mocha::ObjectMethods
|
42
|
-
def ignores(method_name)
|
43
|
-
expects(method_name).at_least(0)
|
44
|
-
end
|
45
|
-
end
|