prawn 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +7 -5
- data/lib/prawn.rb +4 -4
- data/lib/prawn/document.rb +47 -46
- data/lib/prawn/document/bounding_box.rb +13 -19
- data/lib/prawn/document/column_box.rb +3 -5
- data/lib/prawn/document/internals.rb +0 -1
- data/lib/prawn/document/span.rb +12 -12
- data/lib/prawn/errors.rb +32 -33
- data/lib/prawn/font.rb +29 -36
- data/lib/prawn/font/afm.rb +20 -20
- data/lib/prawn/font/dfont.rb +0 -1
- data/lib/prawn/font/ttf.rb +30 -27
- data/lib/prawn/font_metric_cache.rb +4 -8
- data/lib/prawn/graphics.rb +37 -42
- data/lib/prawn/graphics/cap_style.rb +1 -1
- data/lib/prawn/graphics/color.rb +21 -23
- data/lib/prawn/graphics/dash.rb +5 -6
- data/lib/prawn/graphics/join_style.rb +1 -2
- data/lib/prawn/graphics/patterns.rb +25 -21
- data/lib/prawn/graphics/transformation.rb +4 -5
- data/lib/prawn/graphics/transparency.rb +6 -8
- data/lib/prawn/grid.rb +21 -14
- data/lib/prawn/image_handler.rb +2 -2
- data/lib/prawn/images.rb +29 -31
- data/lib/prawn/images/image.rb +1 -1
- data/lib/prawn/images/jpg.rb +10 -12
- data/lib/prawn/images/png.rb +13 -13
- data/lib/prawn/measurements.rb +7 -14
- data/lib/prawn/outline.rb +6 -6
- data/lib/prawn/repeater.rb +1 -5
- data/lib/prawn/security.rb +17 -25
- data/lib/prawn/security/arcfour.rb +1 -1
- data/lib/prawn/soft_mask.rb +11 -12
- data/lib/prawn/stamp.rb +16 -8
- data/lib/prawn/text.rb +23 -20
- data/lib/prawn/text/box.rb +3 -6
- data/lib/prawn/text/formatted/arranger.rb +9 -12
- data/lib/prawn/text/formatted/box.rb +23 -22
- data/lib/prawn/text/formatted/fragment.rb +0 -4
- data/lib/prawn/text/formatted/line_wrap.rb +13 -24
- data/lib/prawn/text/formatted/parser.rb +16 -20
- data/lib/prawn/text/formatted/wrap.rb +2 -7
- data/lib/prawn/utilities.rb +6 -3
- data/lib/prawn/version.rb +1 -1
- data/manual/basic_concepts/basic_concepts.rb +0 -2
- data/manual/basic_concepts/view.rb +1 -1
- data/manual/bounding_box/bounding_box.rb +0 -3
- data/manual/bounding_box/russian_boxes.rb +7 -8
- data/manual/bounding_box/stretchy.rb +0 -1
- data/manual/contents.rb +2 -2
- data/manual/cover.rb +11 -12
- data/manual/document_and_page_options/document_and_page_options.rb +2 -5
- data/manual/document_and_page_options/metadata.rb +10 -10
- data/manual/document_and_page_options/page_size.rb +0 -1
- data/manual/graphics/fill_rules.rb +5 -4
- data/manual/graphics/graphics.rb +0 -3
- data/manual/graphics/lines_and_curves.rb +1 -1
- data/manual/graphics/rotate.rb +0 -2
- data/manual/graphics/scale.rb +4 -2
- data/manual/graphics/soft_masks.rb +0 -1
- data/manual/graphics/stroke_cap.rb +1 -1
- data/manual/graphics/stroke_join.rb +1 -1
- data/manual/graphics/translate.rb +3 -3
- data/manual/graphics/transparency.rb +0 -1
- data/manual/how_to_read_this_manual.rb +0 -1
- data/manual/images/images.rb +0 -3
- data/manual/layout/boxes.rb +5 -5
- data/manual/layout/content.rb +2 -2
- data/manual/layout/layout.rb +0 -3
- data/manual/outline/outline.rb +0 -3
- data/manual/repeatable_content/page_numbering.rb +1 -1
- data/manual/repeatable_content/repeatable_content.rb +0 -3
- data/manual/repeatable_content/repeater.rb +6 -6
- data/manual/security/encryption.rb +0 -2
- data/manual/security/permissions.rb +0 -2
- data/manual/security/security.rb +0 -3
- data/manual/text/alignment.rb +3 -3
- data/manual/text/color.rb +0 -1
- data/manual/text/column_box.rb +0 -1
- data/manual/text/fallback_fonts.rb +2 -2
- data/manual/text/formatted_callbacks.rb +3 -2
- data/manual/text/paragraph_indentation.rb +2 -3
- data/manual/text/registering_families.rb +13 -9
- data/manual/text/rotation.rb +0 -1
- data/manual/text/text.rb +0 -3
- data/manual/text/text_box_overflow.rb +7 -5
- data/manual/text/utf8.rb +1 -1
- data/manual/text/win_ansi_charset.rb +2 -2
- data/prawn.gemspec +4 -4
- data/spec/acceptance/png.rb +6 -7
- data/spec/annotations_spec.rb +21 -28
- data/spec/bounding_box_spec.rb +100 -109
- data/spec/column_box_spec.rb +26 -32
- data/spec/destinations_spec.rb +2 -4
- data/spec/document_spec.rb +145 -151
- data/spec/extensions/mocha.rb +0 -1
- data/spec/font_metric_cache_spec.rb +7 -7
- data/spec/font_spec.rb +103 -102
- data/spec/formatted_text_arranger_spec.rb +76 -74
- data/spec/formatted_text_box_spec.rb +170 -159
- data/spec/formatted_text_fragment_spec.rb +57 -56
- data/spec/graphics_spec.rb +158 -175
- data/spec/grid_spec.rb +28 -29
- data/spec/image_handler_spec.rb +4 -5
- data/spec/images_spec.rb +50 -36
- data/spec/inline_formatted_text_parser_spec.rb +397 -393
- data/spec/jpg_spec.rb +4 -6
- data/spec/line_wrap_spec.rb +54 -55
- data/spec/measurement_units_spec.rb +12 -15
- data/spec/outline_spec.rb +77 -98
- data/spec/png_spec.rb +55 -65
- data/spec/reference_spec.rb +3 -3
- data/spec/repeater_spec.rb +20 -26
- data/spec/security_spec.rb +42 -49
- data/spec/soft_mask_spec.rb +4 -5
- data/spec/span_spec.rb +5 -6
- data/spec/spec_helper.rb +2 -4
- data/spec/stamp_spec.rb +41 -22
- data/spec/stroke_styles_spec.rb +36 -39
- data/spec/text_at_spec.rb +28 -29
- data/spec/text_box_spec.rb +160 -165
- data/spec/text_rendering_mode_spec.rb +9 -9
- data/spec/text_spacing_spec.rb +13 -13
- data/spec/text_spec.rb +116 -124
- data/spec/text_with_inline_formatting_spec.rb +5 -5
- data/spec/transparency_spec.rb +20 -20
- data/spec/view_spec.rb +0 -1
- metadata +7 -7
data/spec/soft_mask_spec.rb
CHANGED
@@ -21,14 +21,13 @@ module SoftMaskHelper
|
|
21
21
|
end
|
22
22
|
|
23
23
|
describe "Document with soft masks" do
|
24
|
-
|
25
24
|
include SoftMaskHelper
|
26
25
|
|
27
26
|
it "should have PDF version at least 1.4" do
|
28
27
|
create_pdf
|
29
28
|
make_soft_mask
|
30
29
|
str = @pdf.render
|
31
|
-
str[0,8].
|
30
|
+
expect(str[0, 8]).to eq("%PDF-1.4")
|
32
31
|
end
|
33
32
|
|
34
33
|
it "should create a new extended graphics state for each unique soft mask" do
|
@@ -45,7 +44,7 @@ describe "Document with soft masks" do
|
|
45
44
|
end
|
46
45
|
|
47
46
|
extgstates = PDF::Inspector::ExtGState.analyze(@pdf.render).extgstates
|
48
|
-
extgstates.length.
|
47
|
+
expect(extgstates.length).to eq(2)
|
49
48
|
end
|
50
49
|
|
51
50
|
it "a new extended graphics state should contain soft mask with drawing instructions" do
|
@@ -57,7 +56,7 @@ describe "Document with soft masks" do
|
|
57
56
|
end
|
58
57
|
|
59
58
|
extgstate = PDF::Inspector::ExtGState.analyze(@pdf.render).extgstates.first
|
60
|
-
extgstate[:soft_mask][:G].data.
|
59
|
+
expect(extgstate[:soft_mask][:G].data).to eq("q\n/DeviceRGB cs\n0.000 0.000 0.000 scn\n/DeviceRGB CS\n0.000 0.000 0.000 SCN\n1 w\n0 J\n0 j\n[] 0 d\n/DeviceRGB cs\n0.502 0.502 0.502 scn\n100.0 -100.0 200.0 200.0 re\nf\nQ\n")
|
61
60
|
end
|
62
61
|
|
63
62
|
it "should not create duplicate extended graphics states" do
|
@@ -74,6 +73,6 @@ describe "Document with soft masks" do
|
|
74
73
|
end
|
75
74
|
|
76
75
|
extgstates = PDF::Inspector::ExtGState.analyze(@pdf.render).extgstates
|
77
|
-
extgstates.length.
|
76
|
+
expect(extgstates.length).to eq(1)
|
78
77
|
end
|
79
78
|
end
|
data/spec/span_spec.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
|
4
4
|
|
5
5
|
describe "drawing span" do
|
6
|
-
|
7
6
|
before do
|
8
7
|
Prawn.debug = false
|
9
8
|
create_pdf
|
@@ -15,11 +14,11 @@ describe "drawing span" do
|
|
15
14
|
|
16
15
|
it "should only accept :position as option in debug mode" do
|
17
16
|
Prawn.debug = true
|
18
|
-
|
17
|
+
expect { @pdf.span(350, :x => 3) {} }.to raise_error(Prawn::Errors::UnknownOption)
|
19
18
|
end
|
20
19
|
|
21
20
|
it "should have raise an error if :position is invalid" do
|
22
|
-
|
21
|
+
expect { @pdf.span(350, :position => :x) {} }.to raise_error(ArgumentError)
|
23
22
|
end
|
24
23
|
|
25
24
|
it "should restore the margin box when bounding box exits" do
|
@@ -29,7 +28,7 @@ describe "drawing span" do
|
|
29
28
|
@pdf.text "Here's some centered text in a 350 point column. " * 100
|
30
29
|
end
|
31
30
|
|
32
|
-
@pdf.bounds.
|
31
|
+
expect(@pdf.bounds).to eq(margin_box)
|
33
32
|
end
|
34
33
|
|
35
34
|
it "should do create a margin box" do
|
@@ -38,7 +37,7 @@ describe "drawing span" do
|
|
38
37
|
@pdf.text "Here's some centered text in a 350 point column. " * 100
|
39
38
|
end
|
40
39
|
|
41
|
-
margin_box.top.
|
42
|
-
margin_box.bottom.
|
40
|
+
expect(margin_box.top).to eq(792.0)
|
41
|
+
expect(margin_box.bottom).to eq(0)
|
43
42
|
end
|
44
43
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -17,7 +17,6 @@ require_relative "../lib/prawn"
|
|
17
17
|
Prawn.debug = true
|
18
18
|
Prawn::Font::AFM.hide_m17n_warning = true
|
19
19
|
|
20
|
-
#require "test/spec"
|
21
20
|
require "rspec"
|
22
21
|
require "mocha/api"
|
23
22
|
require "pdf/reader"
|
@@ -25,7 +24,7 @@ require "pdf/inspector"
|
|
25
24
|
|
26
25
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
27
26
|
# in spec/extensions/ and its subdirectories.
|
28
|
-
Dir[File.dirname(__FILE__) + "/extensions/**/*.rb"].each {|f| require f }
|
27
|
+
Dir[File.dirname(__FILE__) + "/extensions/**/*.rb"].each { |f| require f }
|
29
28
|
|
30
29
|
RSpec.configure do |config|
|
31
30
|
config.mock_framework = :mocha
|
@@ -33,7 +32,7 @@ RSpec.configure do |config|
|
|
33
32
|
config.treat_symbols_as_metadata_keys_with_true_values = true
|
34
33
|
end
|
35
34
|
|
36
|
-
def create_pdf(klass=Prawn::Document)
|
35
|
+
def create_pdf(klass = Prawn::Document)
|
37
36
|
@pdf = klass.new(:margin => 0)
|
38
37
|
end
|
39
38
|
|
@@ -51,4 +50,3 @@ end
|
|
51
50
|
module Prawn::Graphics
|
52
51
|
public :map_to_absolute
|
53
52
|
end
|
54
|
-
|
data/spec/stamp_spec.rb
CHANGED
@@ -31,26 +31,26 @@ describe "#stamp_at" do
|
|
31
31
|
# invoke_xobject message and count the number of times it was
|
32
32
|
# called, but it was only called once, so I reverted checking the
|
33
33
|
# output with a regular expression
|
34
|
-
@pdf.render.
|
34
|
+
expect(@pdf.render).to match(/\/Stamp1 Do.*?/m)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
describe "Document with a stamp" do
|
39
|
-
it "should raise_error NameTaken error when attempt to create stamp "
|
39
|
+
it "should raise_error NameTaken error when attempt to create stamp " \
|
40
40
|
"with same name as an existing stamp" do
|
41
41
|
create_pdf
|
42
42
|
@pdf.create_stamp("MyStamp")
|
43
|
-
|
43
|
+
expect {
|
44
44
|
@pdf.create_stamp("MyStamp")
|
45
|
-
}.
|
45
|
+
}.to raise_error(Prawn::Errors::NameTaken)
|
46
46
|
end
|
47
47
|
|
48
|
-
it "should raise_error InvalidName error when attempt to create "
|
48
|
+
it "should raise_error InvalidName error when attempt to create " \
|
49
49
|
"stamp with a blank name" do
|
50
50
|
create_pdf
|
51
|
-
|
51
|
+
expect {
|
52
52
|
@pdf.create_stamp("")
|
53
|
-
}.
|
53
|
+
}.to raise_error(Prawn::Errors::InvalidName)
|
54
54
|
end
|
55
55
|
|
56
56
|
it "a new XObject should be defined for each stamp created" do
|
@@ -62,16 +62,16 @@ describe "Document with a stamp" do
|
|
62
62
|
|
63
63
|
inspector = PDF::Inspector::XObject.analyze(@pdf.render)
|
64
64
|
xobjects = inspector.page_xobjects.last
|
65
|
-
xobjects.length.
|
65
|
+
expect(xobjects.length).to eq(2)
|
66
66
|
end
|
67
67
|
|
68
|
-
it "calling stamp with a name that does not match an existing stamp "
|
68
|
+
it "calling stamp with a name that does not match an existing stamp " \
|
69
69
|
"should raise_error UndefinedObjectName" do
|
70
70
|
create_pdf
|
71
71
|
@pdf.create_stamp("MyStamp")
|
72
|
-
|
72
|
+
expect {
|
73
73
|
@pdf.stamp("OtherStamp")
|
74
|
-
}.
|
74
|
+
}.to raise_error(Prawn::Errors::UndefinedObjectName)
|
75
75
|
end
|
76
76
|
|
77
77
|
it "stamp should be drawn into the document each time stamp is called" do
|
@@ -84,14 +84,33 @@ describe "Document with a stamp" do
|
|
84
84
|
# invoke_xobject message and count the number of times it was
|
85
85
|
# called, but it was only called once, so I reverted checking the
|
86
86
|
# output with a regular expression
|
87
|
-
@pdf.render.
|
87
|
+
expect(@pdf.render).to match(/(\/Stamp1 Do.*?){3}/m)
|
88
88
|
end
|
89
89
|
|
90
|
-
it "
|
90
|
+
it "stamp should render clickable links" do
|
91
|
+
create_pdf
|
92
|
+
@pdf.create_stamp 'bar' do
|
93
|
+
@pdf.text '<b>Prawn</b> <link href="http://github.com">GitHub</link>', inline_format: true
|
94
|
+
end
|
95
|
+
@pdf.stamp 'bar'
|
96
|
+
|
97
|
+
output = @pdf.render
|
98
|
+
objects = output.split("endobj")
|
99
|
+
|
100
|
+
objects.each do |obj|
|
101
|
+
if obj =~ /\/Type \/Page$/
|
102
|
+
# The page object must contain the annotation reference
|
103
|
+
# to render a clickable link
|
104
|
+
expect(obj).to match(/^\/Annots \[\d \d .\]$/)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
it "resources added during stamp creation should be added to the " \
|
91
110
|
"stamp XObject, not the page" do
|
92
111
|
create_pdf
|
93
112
|
@pdf.create_stamp("MyStamp") do
|
94
|
-
@pdf.transparent(0.5) { @pdf.circle([100, 100], 10)}
|
113
|
+
@pdf.transparent(0.5) { @pdf.circle([100, 100], 10) }
|
95
114
|
end
|
96
115
|
@pdf.stamp("MyStamp")
|
97
116
|
|
@@ -102,9 +121,9 @@ describe "Document with a stamp" do
|
|
102
121
|
objects = output.split("endobj")
|
103
122
|
objects.each do |object|
|
104
123
|
if object =~ /\/Type \/Page$/
|
105
|
-
object.
|
124
|
+
expect(object).not_to match(/\/ExtGState/)
|
106
125
|
elsif object =~ /\/Type \/XObject$/
|
107
|
-
object.
|
126
|
+
expect(object).to match(/\/ExtGState/)
|
108
127
|
end
|
109
128
|
end
|
110
129
|
end
|
@@ -116,12 +135,12 @@ describe "Document with a stamp" do
|
|
116
135
|
end
|
117
136
|
@pdf.stamp("MyStamp")
|
118
137
|
stamps = PDF::Inspector::XObject.analyze(@pdf.render)
|
119
|
-
stamps.xobject_streams[:Stamp1].data.chomp.
|
138
|
+
expect(stamps.xobject_streams[:Stamp1].data.chomp).to match(/q(.|\s)*Q\Z/)
|
120
139
|
end
|
121
140
|
|
122
141
|
it "should not add to the page graphic state stack " do
|
123
142
|
create_pdf
|
124
|
-
@pdf.state.page.stack.stack.size.
|
143
|
+
expect(@pdf.state.page.stack.stack.size).to eq(1)
|
125
144
|
|
126
145
|
@pdf.create_stamp("MyStamp") do
|
127
146
|
@pdf.save_graphics_state
|
@@ -130,7 +149,7 @@ describe "Document with a stamp" do
|
|
130
149
|
@pdf.text "This should have a 'q' before it and a 'Q' after it"
|
131
150
|
@pdf.restore_graphics_state
|
132
151
|
end
|
133
|
-
@pdf.state.page.stack.stack.size.
|
152
|
+
expect(@pdf.state.page.stack.stack.size).to eq(1)
|
134
153
|
end
|
135
154
|
|
136
155
|
it "should be able to change fill and stroke colors within the stamp stream" do
|
@@ -142,8 +161,8 @@ describe "Document with a stamp" do
|
|
142
161
|
@pdf.stamp("MyStamp")
|
143
162
|
stamps = PDF::Inspector::XObject.analyze(@pdf.render)
|
144
163
|
stamp_stream = stamps.xobject_streams[:Stamp1].data
|
145
|
-
stamp_stream.
|
146
|
-
stamp_stream.
|
164
|
+
expect(stamp_stream).to include("/DeviceCMYK cs\n1.000 1.000 0.200 0.000 scn")
|
165
|
+
expect(stamp_stream).to include("/DeviceCMYK CS\n1.000 1.000 0.200 0.000 SCN")
|
147
166
|
end
|
148
167
|
|
149
168
|
it "should save the color space even when same as current page color space" do
|
@@ -155,6 +174,6 @@ describe "Document with a stamp" do
|
|
155
174
|
@pdf.stamp("MyStamp")
|
156
175
|
stamps = PDF::Inspector::XObject.analyze(@pdf.render)
|
157
176
|
stamp_stream = stamps.xobject_streams[:Stamp1].data
|
158
|
-
stamp_stream.
|
177
|
+
expect(stamp_stream).to include("/DeviceCMYK CS\n1.000 1.000 0.200 0.000 SCN")
|
159
178
|
end
|
160
179
|
end
|
data/spec/stroke_styles_spec.rb
CHANGED
@@ -5,15 +5,15 @@ require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
|
|
5
5
|
describe "When stroking with default settings" do
|
6
6
|
before(:each) { create_pdf }
|
7
7
|
it "cap_style should be :butt" do
|
8
|
-
@pdf.cap_style.
|
8
|
+
expect(@pdf.cap_style).to eq(:butt)
|
9
9
|
end
|
10
10
|
|
11
11
|
it "join_style should be :miter" do
|
12
|
-
@pdf.join_style.
|
12
|
+
expect(@pdf.join_style).to eq(:miter)
|
13
13
|
end
|
14
14
|
|
15
15
|
it "dashed? should be_false" do
|
16
|
-
@pdf.
|
16
|
+
expect(@pdf).not_to be_dashed
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -22,14 +22,14 @@ describe "Cap styles" do
|
|
22
22
|
|
23
23
|
it "should be able to use assignment operator" do
|
24
24
|
@pdf.cap_style = :round
|
25
|
-
@pdf.cap_style.
|
25
|
+
expect(@pdf.cap_style).to eq(:round)
|
26
26
|
end
|
27
27
|
|
28
28
|
describe "#cap_style(:butt)" do
|
29
29
|
it "rendered PDF should include butt style cap" do
|
30
30
|
@pdf.cap_style(:butt)
|
31
31
|
cap_style = PDF::Inspector::Graphics::CapStyle.analyze(@pdf.render).cap_style
|
32
|
-
cap_style.
|
32
|
+
expect(cap_style).to eq(0)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -37,7 +37,7 @@ describe "Cap styles" do
|
|
37
37
|
it "rendered PDF should include round style cap" do
|
38
38
|
@pdf.cap_style(:round)
|
39
39
|
cap_style = PDF::Inspector::Graphics::CapStyle.analyze(@pdf.render).cap_style
|
40
|
-
cap_style.
|
40
|
+
expect(cap_style).to eq(1)
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -45,7 +45,7 @@ describe "Cap styles" do
|
|
45
45
|
it "rendered PDF should include projecting_square style cap" do
|
46
46
|
@pdf.cap_style(:projecting_square)
|
47
47
|
cap_style = PDF::Inspector::Graphics::CapStyle.analyze(@pdf.render).cap_style
|
48
|
-
cap_style.
|
48
|
+
expect(cap_style).to eq(2)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -53,8 +53,8 @@ describe "Cap styles" do
|
|
53
53
|
@pdf.cap_style(:round)
|
54
54
|
@pdf.start_new_page
|
55
55
|
cap_styles = PDF::Inspector::Graphics::CapStyle.analyze(@pdf.render)
|
56
|
-
cap_styles.cap_style_count.
|
57
|
-
cap_styles.cap_style.
|
56
|
+
expect(cap_styles.cap_style_count).to eq(2)
|
57
|
+
expect(cap_styles.cap_style).to eq(1)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
@@ -63,14 +63,14 @@ describe "Join styles" do
|
|
63
63
|
|
64
64
|
it "should be able to use assignment operator" do
|
65
65
|
@pdf.join_style = :round
|
66
|
-
@pdf.join_style.
|
66
|
+
expect(@pdf.join_style).to eq(:round)
|
67
67
|
end
|
68
68
|
|
69
69
|
describe "#join_style(:miter)" do
|
70
70
|
it "rendered PDF should include miter style join" do
|
71
71
|
@pdf.join_style(:miter)
|
72
72
|
join_style = PDF::Inspector::Graphics::JoinStyle.analyze(@pdf.render).join_style
|
73
|
-
join_style.
|
73
|
+
expect(join_style).to eq(0)
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
@@ -78,7 +78,7 @@ describe "Join styles" do
|
|
78
78
|
it "rendered PDF should include round style join" do
|
79
79
|
@pdf.join_style(:round)
|
80
80
|
join_style = PDF::Inspector::Graphics::JoinStyle.analyze(@pdf.render).join_style
|
81
|
-
join_style.
|
81
|
+
expect(join_style).to eq(1)
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
@@ -86,7 +86,7 @@ describe "Join styles" do
|
|
86
86
|
it "rendered PDF should include bevel style join" do
|
87
87
|
@pdf.join_style(:bevel)
|
88
88
|
join_style = PDF::Inspector::Graphics::JoinStyle.analyze(@pdf.render).join_style
|
89
|
-
join_style.
|
89
|
+
expect(join_style).to eq(2)
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
@@ -94,28 +94,28 @@ describe "Join styles" do
|
|
94
94
|
@pdf.join_style(:round)
|
95
95
|
@pdf.start_new_page
|
96
96
|
join_styles = PDF::Inspector::Graphics::JoinStyle.analyze(@pdf.render)
|
97
|
-
join_styles.join_style_count.
|
98
|
-
join_styles.join_style.
|
97
|
+
expect(join_styles.join_style_count).to eq(2)
|
98
|
+
expect(join_styles.join_style).to eq(1)
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
102
|
describe "Dashes" do
|
103
103
|
before(:each) { create_pdf }
|
104
104
|
|
105
|
-
|
106
|
-
|
107
|
-
|
105
|
+
it "should be able to use assignment operator" do
|
106
|
+
@pdf.dash = 2
|
107
|
+
expect(@pdf).to be_dashed
|
108
108
|
end
|
109
109
|
|
110
110
|
describe "setting a dash" do
|
111
111
|
it "dashed? should be_true" do
|
112
112
|
@pdf.dash(2)
|
113
|
-
@pdf.
|
113
|
+
expect(@pdf).to be_dashed
|
114
114
|
end
|
115
115
|
it "rendered PDF should include a stroked dash" do
|
116
116
|
@pdf.dash(2)
|
117
117
|
dashes = PDF::Inspector::Graphics::Dash.analyze(@pdf.render)
|
118
|
-
dashes.stroke_dash.
|
118
|
+
expect(dashes.stroke_dash).to eq([[2, 2], 0])
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
@@ -123,7 +123,7 @@ describe "Dashes" do
|
|
123
123
|
it "space between dashes should be the same length as the dash in the rendered PDF" do
|
124
124
|
@pdf.dash(2)
|
125
125
|
dashes = PDF::Inspector::Graphics::Dash.analyze(@pdf.render)
|
126
|
-
dashes.stroke_dash.
|
126
|
+
expect(dashes.stroke_dash).to eq([[2, 2], 0])
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
@@ -131,7 +131,7 @@ describe "Dashes" do
|
|
131
131
|
it "space between dashes in the rendered PDF should be different length than the length of the dash" do
|
132
132
|
@pdf.dash(2, :space => 3)
|
133
133
|
dashes = PDF::Inspector::Graphics::Dash.analyze(@pdf.render)
|
134
|
-
dashes.stroke_dash.
|
134
|
+
expect(dashes.stroke_dash).to eq([[2, 3], 0])
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
@@ -139,25 +139,25 @@ describe "Dashes" do
|
|
139
139
|
it "rendered PDF should include a non-zero phase" do
|
140
140
|
@pdf.dash(2, :phase => 1)
|
141
141
|
dashes = PDF::Inspector::Graphics::Dash.analyze(@pdf.render)
|
142
|
-
dashes.stroke_dash.
|
142
|
+
expect(dashes.stroke_dash).to eq([[2, 2], 1])
|
143
143
|
end
|
144
144
|
end
|
145
145
|
|
146
146
|
describe "setting a dash by using an array" do
|
147
147
|
it "dash and spaces should be set from the array" do
|
148
|
-
@pdf.dash([1,2,3,4])
|
148
|
+
@pdf.dash([1, 2, 3, 4])
|
149
149
|
dashes = PDF::Inspector::Graphics::Dash.analyze(@pdf.render)
|
150
|
-
dashes.stroke_dash.
|
150
|
+
expect(dashes.stroke_dash).to eq([[1, 2, 3, 4], 0])
|
151
151
|
end
|
152
152
|
it "space options has to be ignored" do
|
153
|
-
@pdf.dash([1,2,3,4], :space => 3)
|
153
|
+
@pdf.dash([1, 2, 3, 4], :space => 3)
|
154
154
|
dashes = PDF::Inspector::Graphics::Dash.analyze(@pdf.render)
|
155
|
-
dashes.stroke_dash.
|
155
|
+
expect(dashes.stroke_dash).to eq([[1, 2, 3, 4], 0])
|
156
156
|
end
|
157
157
|
it "phase options should be correctly used" do
|
158
|
-
@pdf.dash([1,2,3,4], :phase => 3)
|
158
|
+
@pdf.dash([1, 2, 3, 4], :phase => 3)
|
159
159
|
dashes = PDF::Inspector::Graphics::Dash.analyze(@pdf.render)
|
160
|
-
dashes.stroke_dash.
|
160
|
+
expect(dashes.stroke_dash).to eq([[1, 2, 3, 4], 3])
|
161
161
|
end
|
162
162
|
end
|
163
163
|
|
@@ -166,7 +166,7 @@ describe "Dashes" do
|
|
166
166
|
@pdf.dash(2)
|
167
167
|
@pdf.undash
|
168
168
|
dashes = PDF::Inspector::Graphics::Dash.analyze(@pdf.render)
|
169
|
-
dashes.stroke_dash.
|
169
|
+
expect(dashes.stroke_dash).to eq([[], 0])
|
170
170
|
end
|
171
171
|
end
|
172
172
|
|
@@ -174,20 +174,19 @@ describe "Dashes" do
|
|
174
174
|
@pdf.dash(2)
|
175
175
|
@pdf.start_new_page
|
176
176
|
dashes = PDF::Inspector::Graphics::Dash.analyze(@pdf.render)
|
177
|
-
dashes.stroke_dash_count.
|
178
|
-
dashes.stroke_dash.
|
177
|
+
expect(dashes.stroke_dash_count).to eq(2)
|
178
|
+
expect(dashes.stroke_dash).to eq([[2, 2], 0])
|
179
179
|
end
|
180
180
|
|
181
181
|
describe "#dashed?" do
|
182
|
-
|
183
182
|
it "an initial document should not be dashed" do
|
184
|
-
@pdf.dashed
|
183
|
+
expect(@pdf.dashed?).to eq(false)
|
185
184
|
end
|
186
185
|
|
187
186
|
it "should return true if any of the currently active settings are dashed" do
|
188
187
|
@pdf.dash(2)
|
189
188
|
@pdf.save_graphics_state
|
190
|
-
@pdf.dashed
|
189
|
+
expect(@pdf.dashed?).to eq(true)
|
191
190
|
end
|
192
191
|
|
193
192
|
it "should return false if the document was most recently undashed" do
|
@@ -195,7 +194,7 @@ describe "Dashes" do
|
|
195
194
|
@pdf.save_graphics_state
|
196
195
|
@pdf.undash
|
197
196
|
@pdf.save_graphics_state
|
198
|
-
@pdf.dashed
|
197
|
+
expect(@pdf.dashed?).to eq(false)
|
199
198
|
end
|
200
199
|
|
201
200
|
it "should return true when restoring to a state that was dashed" do
|
@@ -203,9 +202,7 @@ describe "Dashes" do
|
|
203
202
|
@pdf.save_graphics_state
|
204
203
|
@pdf.undash
|
205
204
|
@pdf.restore_graphics_state
|
206
|
-
@pdf.dashed
|
205
|
+
expect(@pdf.dashed?).to eq(true)
|
207
206
|
end
|
208
|
-
|
209
207
|
end
|
210
|
-
|
211
208
|
end
|