prawn 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +7 -5
  3. data/lib/prawn.rb +4 -4
  4. data/lib/prawn/document.rb +47 -46
  5. data/lib/prawn/document/bounding_box.rb +13 -19
  6. data/lib/prawn/document/column_box.rb +3 -5
  7. data/lib/prawn/document/internals.rb +0 -1
  8. data/lib/prawn/document/span.rb +12 -12
  9. data/lib/prawn/errors.rb +32 -33
  10. data/lib/prawn/font.rb +29 -36
  11. data/lib/prawn/font/afm.rb +20 -20
  12. data/lib/prawn/font/dfont.rb +0 -1
  13. data/lib/prawn/font/ttf.rb +30 -27
  14. data/lib/prawn/font_metric_cache.rb +4 -8
  15. data/lib/prawn/graphics.rb +37 -42
  16. data/lib/prawn/graphics/cap_style.rb +1 -1
  17. data/lib/prawn/graphics/color.rb +21 -23
  18. data/lib/prawn/graphics/dash.rb +5 -6
  19. data/lib/prawn/graphics/join_style.rb +1 -2
  20. data/lib/prawn/graphics/patterns.rb +25 -21
  21. data/lib/prawn/graphics/transformation.rb +4 -5
  22. data/lib/prawn/graphics/transparency.rb +6 -8
  23. data/lib/prawn/grid.rb +21 -14
  24. data/lib/prawn/image_handler.rb +2 -2
  25. data/lib/prawn/images.rb +29 -31
  26. data/lib/prawn/images/image.rb +1 -1
  27. data/lib/prawn/images/jpg.rb +10 -12
  28. data/lib/prawn/images/png.rb +13 -13
  29. data/lib/prawn/measurements.rb +7 -14
  30. data/lib/prawn/outline.rb +6 -6
  31. data/lib/prawn/repeater.rb +1 -5
  32. data/lib/prawn/security.rb +17 -25
  33. data/lib/prawn/security/arcfour.rb +1 -1
  34. data/lib/prawn/soft_mask.rb +11 -12
  35. data/lib/prawn/stamp.rb +16 -8
  36. data/lib/prawn/text.rb +23 -20
  37. data/lib/prawn/text/box.rb +3 -6
  38. data/lib/prawn/text/formatted/arranger.rb +9 -12
  39. data/lib/prawn/text/formatted/box.rb +23 -22
  40. data/lib/prawn/text/formatted/fragment.rb +0 -4
  41. data/lib/prawn/text/formatted/line_wrap.rb +13 -24
  42. data/lib/prawn/text/formatted/parser.rb +16 -20
  43. data/lib/prawn/text/formatted/wrap.rb +2 -7
  44. data/lib/prawn/utilities.rb +6 -3
  45. data/lib/prawn/version.rb +1 -1
  46. data/manual/basic_concepts/basic_concepts.rb +0 -2
  47. data/manual/basic_concepts/view.rb +1 -1
  48. data/manual/bounding_box/bounding_box.rb +0 -3
  49. data/manual/bounding_box/russian_boxes.rb +7 -8
  50. data/manual/bounding_box/stretchy.rb +0 -1
  51. data/manual/contents.rb +2 -2
  52. data/manual/cover.rb +11 -12
  53. data/manual/document_and_page_options/document_and_page_options.rb +2 -5
  54. data/manual/document_and_page_options/metadata.rb +10 -10
  55. data/manual/document_and_page_options/page_size.rb +0 -1
  56. data/manual/graphics/fill_rules.rb +5 -4
  57. data/manual/graphics/graphics.rb +0 -3
  58. data/manual/graphics/lines_and_curves.rb +1 -1
  59. data/manual/graphics/rotate.rb +0 -2
  60. data/manual/graphics/scale.rb +4 -2
  61. data/manual/graphics/soft_masks.rb +0 -1
  62. data/manual/graphics/stroke_cap.rb +1 -1
  63. data/manual/graphics/stroke_join.rb +1 -1
  64. data/manual/graphics/translate.rb +3 -3
  65. data/manual/graphics/transparency.rb +0 -1
  66. data/manual/how_to_read_this_manual.rb +0 -1
  67. data/manual/images/images.rb +0 -3
  68. data/manual/layout/boxes.rb +5 -5
  69. data/manual/layout/content.rb +2 -2
  70. data/manual/layout/layout.rb +0 -3
  71. data/manual/outline/outline.rb +0 -3
  72. data/manual/repeatable_content/page_numbering.rb +1 -1
  73. data/manual/repeatable_content/repeatable_content.rb +0 -3
  74. data/manual/repeatable_content/repeater.rb +6 -6
  75. data/manual/security/encryption.rb +0 -2
  76. data/manual/security/permissions.rb +0 -2
  77. data/manual/security/security.rb +0 -3
  78. data/manual/text/alignment.rb +3 -3
  79. data/manual/text/color.rb +0 -1
  80. data/manual/text/column_box.rb +0 -1
  81. data/manual/text/fallback_fonts.rb +2 -2
  82. data/manual/text/formatted_callbacks.rb +3 -2
  83. data/manual/text/paragraph_indentation.rb +2 -3
  84. data/manual/text/registering_families.rb +13 -9
  85. data/manual/text/rotation.rb +0 -1
  86. data/manual/text/text.rb +0 -3
  87. data/manual/text/text_box_overflow.rb +7 -5
  88. data/manual/text/utf8.rb +1 -1
  89. data/manual/text/win_ansi_charset.rb +2 -2
  90. data/prawn.gemspec +4 -4
  91. data/spec/acceptance/png.rb +6 -7
  92. data/spec/annotations_spec.rb +21 -28
  93. data/spec/bounding_box_spec.rb +100 -109
  94. data/spec/column_box_spec.rb +26 -32
  95. data/spec/destinations_spec.rb +2 -4
  96. data/spec/document_spec.rb +145 -151
  97. data/spec/extensions/mocha.rb +0 -1
  98. data/spec/font_metric_cache_spec.rb +7 -7
  99. data/spec/font_spec.rb +103 -102
  100. data/spec/formatted_text_arranger_spec.rb +76 -74
  101. data/spec/formatted_text_box_spec.rb +170 -159
  102. data/spec/formatted_text_fragment_spec.rb +57 -56
  103. data/spec/graphics_spec.rb +158 -175
  104. data/spec/grid_spec.rb +28 -29
  105. data/spec/image_handler_spec.rb +4 -5
  106. data/spec/images_spec.rb +50 -36
  107. data/spec/inline_formatted_text_parser_spec.rb +397 -393
  108. data/spec/jpg_spec.rb +4 -6
  109. data/spec/line_wrap_spec.rb +54 -55
  110. data/spec/measurement_units_spec.rb +12 -15
  111. data/spec/outline_spec.rb +77 -98
  112. data/spec/png_spec.rb +55 -65
  113. data/spec/reference_spec.rb +3 -3
  114. data/spec/repeater_spec.rb +20 -26
  115. data/spec/security_spec.rb +42 -49
  116. data/spec/soft_mask_spec.rb +4 -5
  117. data/spec/span_spec.rb +5 -6
  118. data/spec/spec_helper.rb +2 -4
  119. data/spec/stamp_spec.rb +41 -22
  120. data/spec/stroke_styles_spec.rb +36 -39
  121. data/spec/text_at_spec.rb +28 -29
  122. data/spec/text_box_spec.rb +160 -165
  123. data/spec/text_rendering_mode_spec.rb +9 -9
  124. data/spec/text_spacing_spec.rb +13 -13
  125. data/spec/text_spec.rb +116 -124
  126. data/spec/text_with_inline_formatting_spec.rb +5 -5
  127. data/spec/transparency_spec.rb +20 -20
  128. data/spec/view_spec.rb +0 -1
  129. metadata +7 -7
@@ -101,8 +101,8 @@ module Prawn
101
101
  #
102
102
  def add_subsection_to(title, position = :last, &block)
103
103
  @parent = items[title]
104
- raise Prawn::Errors::UnknownOutlineTitle,
105
- "\n No outline item with title: '#{title}' exists in the outline tree" unless @parent
104
+ fail Prawn::Errors::UnknownOutlineTitle,
105
+ "\n No outline item with title: '#{title}' exists in the outline tree" unless @parent
106
106
  @prev = position == :first ? nil : @parent.data.last
107
107
  nxt = position == :first ? @parent.data.first : nil
108
108
  insert_section(nxt, &block)
@@ -131,8 +131,8 @@ module Prawn
131
131
  #
132
132
  def insert_section_after(title, &block)
133
133
  @prev = items[title]
134
- raise Prawn::Errors::UnknownOutlineTitle,
135
- "\n No outline item with title: '#{title}' exists in the outline tree" unless @prev
134
+ fail Prawn::Errors::UnknownOutlineTitle,
135
+ "\n No outline item with title: '#{title}' exists in the outline tree" unless @prev
136
136
  @parent = @prev.data.parent
137
137
  nxt = @prev.data.next
138
138
  insert_section(nxt, &block)
@@ -195,8 +195,8 @@ module Prawn
195
195
  if options[:title]
196
196
  title = options[:title]
197
197
  else
198
- raise Prawn::Errors::RequiredOption,
199
- "\nTitle is a required option for page"
198
+ fail Prawn::Errors::RequiredOption,
199
+ "\nTitle is a required option for page"
200
200
  end
201
201
  add_outline_item(title, options)
202
202
  end
@@ -9,7 +9,6 @@
9
9
  # This is free software. Please see the LICENSE and COPYING files for details.
10
10
 
11
11
  module Prawn
12
-
13
12
  class Document
14
13
  # A list of all repeaters in the document.
15
14
  # See Document#repeat for details
@@ -75,7 +74,7 @@ module Prawn
75
74
  #
76
75
  # end
77
76
  #
78
- def repeat(page_filter, options={}, &block)
77
+ def repeat(page_filter, options = {}, &block)
79
78
  repeaters << Prawn::Repeater.new(self, page_filter, !!options[:dynamic], &block)
80
79
  end
81
80
  end
@@ -117,8 +116,5 @@ module Prawn
117
116
  end
118
117
  end
119
118
  end
120
-
121
119
  end
122
120
  end
123
-
124
-
@@ -14,11 +14,9 @@ require_relative 'security/arcfour'
14
14
 
15
15
  module Prawn
16
16
  class Document
17
-
18
17
  # Implements PDF encryption (password protection and permissions) as
19
18
  # specified in the PDF Reference, version 1.3, section 3.5 "Encryption".
20
19
  module Security
21
-
22
20
  # @group Experimental API
23
21
 
24
22
  # Encrypts the document, to protect confidential data or control
@@ -89,9 +87,9 @@ module Prawn
89
87
  # not a limitation of Prawn, but is rather a built-in limitation of the
90
88
  # PDF format.
91
89
  #
92
- def encrypt_document(options={})
90
+ def encrypt_document(options = {})
93
91
  Prawn.verify_options [:user_password, :owner_password, :permissions],
94
- options
92
+ options
95
93
  @user_password = options.delete(:user_password) || ""
96
94
 
97
95
  @owner_password = options.delete(:owner_password) || @user_password
@@ -113,8 +111,8 @@ module Prawn
113
111
  # See Algorithm 3.1.
114
112
  def self.encrypt_string(str, key, id, gen)
115
113
  # Convert ID and Gen number into little-endian truncated byte strings
116
- id = [id].pack('V')[0,3]
117
- gen = [gen].pack('V')[0,2]
114
+ id = [id].pack('V')[0, 3]
115
+ gen = [gen].pack('V')[0, 2]
118
116
  extended_key = "#{key}#{id}#{gen}"
119
117
 
120
118
  # Compute the RC4 key from the extended key and perform the encryption
@@ -142,12 +140,12 @@ module Prawn
142
140
 
143
141
  FullPermissions = 0b1111_1111_1111_1111_1111_1111_1111_1111
144
142
 
145
- def permissions=(perms={})
143
+ def permissions=(perms = {})
146
144
  @permissions ||= FullPermissions
147
145
  perms.each do |key, value|
148
146
  unless PermissionsBits[key]
149
- raise ArgumentError, "Unknown permission :#{key}. Valid options: " +
150
- PermissionsBits.keys.map { |k| k.inspect }.join(", ")
147
+ fail ArgumentError, "Unknown permission :#{key}. Valid options: " +
148
+ PermissionsBits.keys.map(&:inspect).join(", ")
151
149
  end
152
150
 
153
151
  # 0-based bit number, from LSB
@@ -167,7 +165,7 @@ module Prawn
167
165
 
168
166
  PasswordPadding =
169
167
  "28BF4E5E4E758A4164004E56FFFA01082E2E00B6D0683E802F0CA9FE6453697A".
170
- scan(/../).map{|x| x.to_i(16)}.pack("c*")
168
+ scan(/../).map{ |x| x.to_i(16) }.pack("c*")
171
169
 
172
170
  # Pads or truncates a password to 32 bytes as per Alg 3.2.
173
171
  def pad_password(password)
@@ -197,9 +195,7 @@ module Prawn
197
195
  def user_password_hash
198
196
  Arcfour.new(user_encryption_key).encrypt(PasswordPadding)
199
197
  end
200
-
201
198
  end
202
-
203
199
  end
204
200
  end
205
201
 
@@ -213,11 +209,11 @@ module PDF
213
209
  # from the indirect object referencing obj.
214
210
  #
215
211
  # @private
216
- def EncryptedPdfObject(obj, key, id, gen, in_content_stream=false)
212
+ def EncryptedPdfObject(obj, key, id, gen, in_content_stream = false)
217
213
  case obj
218
214
  when Array
219
215
  "[" << obj.map { |e|
220
- EncryptedPdfObject(e, key, id, gen, in_content_stream)
216
+ EncryptedPdfObject(e, key, id, gen, in_content_stream)
221
217
  }.join(' ') << "]"
222
218
  when LiteralString
223
219
  obj = ByteString.new(Prawn::Document::Security.encrypt_string(obj, key, id, gen)).gsub(/[\\\n\(\)]/) { |m| "\\#{m}" }
@@ -233,13 +229,12 @@ module PDF
233
229
  in_content_stream)
234
230
  when ::Hash
235
231
  output = "<< "
236
- obj.each do |k,v|
232
+ obj.each do |k, v|
237
233
  unless String === k || Symbol === k
238
- raise PDF::Core::Errors::FailedObjectConversion,
239
- "A PDF Dictionary must be keyed by names"
234
+ fail PDF::Core::Errors::FailedObjectConversion,
235
+ "A PDF Dictionary must be keyed by names"
240
236
  end
241
- output << PdfObject(k.to_sym, in_content_stream) << " " <<
242
- EncryptedPdfObject(v, key, id, gen, in_content_stream) << "\n"
237
+ output << PdfObject(k.to_sym, in_content_stream) << " " << EncryptedPdfObject(v, key, id, gen, in_content_stream) << "\n"
243
238
  end
244
239
  output << ">>"
245
240
  when NameTree::Value
@@ -252,7 +247,6 @@ module PDF
252
247
  end
253
248
  end
254
249
 
255
-
256
250
  # @private
257
251
  class Stream
258
252
  def encrypted_object(key, id, gen)
@@ -266,23 +260,21 @@ module PDF
266
260
 
267
261
  # @private
268
262
  class Reference
269
-
270
263
  # Returns the object definition for the object this references, keyed from
271
264
  # +key+.
272
265
  def encrypted_object(key)
273
266
  @on_encode.call(self) if @on_encode
274
267
 
275
268
  output = "#{@identifier} #{gen} obj\n"
276
- unless @stream.empty?
269
+ if @stream.empty?
270
+ output << PDF::Core::EncryptedPdfObject(data, key, @identifier, gen) << "\n"
271
+ else
277
272
  output << PDF::Core::EncryptedPdfObject(data.merge(@stream.data), key, @identifier, gen) << "\n" <<
278
273
  @stream.encrypted_object(key, @identifier, gen)
279
- else
280
- output << PDF::Core::EncryptedPdfObject(data, key, @identifier, gen) << "\n"
281
274
  end
282
275
 
283
276
  output << "endobj\n"
284
277
  end
285
-
286
278
  end
287
279
  end
288
280
  end
@@ -39,7 +39,7 @@ class Arcfour
39
39
  end
40
40
 
41
41
  def encrypt(string)
42
- string.unpack('c*').map{|byte| byte ^ key_byte}.pack('c*')
42
+ string.unpack('c*').map{ |byte| byte ^ key_byte }.pack('c*')
43
43
  end
44
44
 
45
45
  private
@@ -8,7 +8,6 @@
8
8
  #
9
9
 
10
10
  module Prawn
11
-
12
11
  # The Prawn::SoftMask module is used to create arbitrary transparency in
13
12
  # document. Using a soft mask allows creating more visually rich documents.
14
13
  #
@@ -31,30 +30,30 @@ module Prawn
31
30
  def soft_mask(&block)
32
31
  renderer.min_version(1.4)
33
32
 
34
- group_attrs = ref!({
33
+ group_attrs = ref!(
35
34
  :Type => :Group,
36
35
  :S => :Transparency,
37
36
  :CS => :DeviceRGB,
38
37
  :I => false,
39
38
  :K => false
40
- })
39
+ )
41
40
 
42
- group = ref!({
41
+ group = ref!(
43
42
  :Type => :XObject,
44
43
  :Subtype => :Form,
45
44
  :BBox => state.page.dimensions,
46
- :Group => group_attrs,
47
- })
45
+ :Group => group_attrs
46
+ )
48
47
 
49
48
  state.page.stamp_stream(group, &block)
50
49
 
51
- mask = ref!({
50
+ mask = ref!(
52
51
  :Type => :Mask,
53
52
  :S => :Luminosity,
54
53
  :G => group
55
- })
54
+ )
56
55
 
57
- g_state = ref!({
56
+ g_state = ref!(
58
57
  :Type => :ExtGState,
59
58
  :SMask => mask,
60
59
 
@@ -63,13 +62,13 @@ module Prawn
63
62
  :OP => false,
64
63
  :op => false,
65
64
  :OPM => 1,
66
- :SA => true,
67
- })
65
+ :SA => true
66
+ )
68
67
 
69
68
  registry_key = {
70
69
  :bbox => state.page.dimensions,
71
70
  :mask => [group.stream.filters.normalized, group.stream.filtered_stream],
72
- :page => state.page_count,
71
+ :page => state.page_count
73
72
  }.hash
74
73
 
75
74
  if soft_mask_registry[registry_key]
@@ -6,9 +6,7 @@
6
6
  #
7
7
  # This is free software. Please see the LICENSE and COPYING files for details.
8
8
  #
9
-
10
9
  module Prawn
11
-
12
10
  # The Prawn::Stamp module is used to create content that will be
13
11
  # included multiple times in a document. Using a stamp has three
14
12
  # advantages over creating content anew each time it is placed on
@@ -27,7 +25,6 @@ module Prawn
27
25
  # pdf.stamp("my_stamp")
28
26
  #
29
27
  module Stamp
30
-
31
28
  # @group Stable API
32
29
 
33
30
  # Renders the stamp named <tt>name</tt> to the page
@@ -45,6 +42,7 @@ module Prawn
45
42
  def stamp(name)
46
43
  dictionary_name, dictionary = stamp_dictionary(name)
47
44
  renderer.add_content "/#{dictionary_name} Do"
45
+ update_annotation_references dictionary.data[:Annots]
48
46
  state.page.xobjects.merge!(dictionary_name => dictionary)
49
47
  end
50
48
 
@@ -94,9 +92,9 @@ module Prawn
94
92
  end
95
93
 
96
94
  def stamp_dictionary(name)
97
- raise Prawn::Errors::InvalidName if name.empty?
95
+ fail Prawn::Errors::InvalidName if name.empty?
98
96
  if stamp_dictionary_registry[name].nil?
99
- raise Prawn::Errors::UndefinedObjectName
97
+ fail Prawn::Errors::UndefinedObjectName
100
98
  end
101
99
 
102
100
  dict = stamp_dictionary_registry[name]
@@ -107,8 +105,8 @@ module Prawn
107
105
  end
108
106
 
109
107
  def create_stamp_dictionary(name)
110
- raise Prawn::Errors::InvalidName if name.empty?
111
- raise Prawn::Errors::NameTaken unless stamp_dictionary_registry[name].nil?
108
+ fail Prawn::Errors::InvalidName if name.empty?
109
+ fail Prawn::Errors::NameTaken unless stamp_dictionary_registry[name].nil?
112
110
  # BBox origin is the lower left margin of the page, so we need
113
111
  # it to be the full dimension of the page, or else things that
114
112
  # should appear near the top or right margin are invisible
@@ -124,6 +122,17 @@ module Prawn
124
122
  dictionary
125
123
  end
126
124
 
125
+ # Referencing annotations from a stamp XObject doesn't result
126
+ # in a working link. Instead, the references must be appended
127
+ # to the /Annot dictionary of the object that contains the
128
+ # call to the stamp object.
129
+ def update_annotation_references(annots)
130
+ if annots && annots.any?
131
+ state.page.dictionary.data[:Annots] ||= []
132
+ state.page.dictionary.data[:Annots] |= annots
133
+ end
134
+ end
135
+
127
136
  def freeze_stamp_graphics
128
137
  update_colors
129
138
  write_line_width
@@ -131,6 +140,5 @@ module Prawn
131
140
  write_stroke_join_style
132
141
  write_stroke_dash
133
142
  end
134
-
135
143
  end
136
144
  end
@@ -15,7 +15,6 @@ require_relative "text/box"
15
15
 
16
16
  module Prawn
17
17
  module Text
18
-
19
18
  include PDF::Core::Text
20
19
  include Prawn::Text::Formatted
21
20
 
@@ -152,7 +151,7 @@ module Prawn
152
151
  # Raises <tt>Prawn::Errrors::CannotFit</tt> if not wide enough to print
153
152
  # any text
154
153
  #
155
- def text(string, options={})
154
+ def text(string, options = {})
156
155
  return false if string.nil?
157
156
  # we modify the options. don't change the user's hash
158
157
  options = options.dup
@@ -188,7 +187,7 @@ module Prawn
188
187
  #
189
188
  # Same as for #text
190
189
  #
191
- def formatted_text(array, options={})
190
+ def formatted_text(array, options = {})
192
191
  options = inspect_options_for_text(options.dup)
193
192
 
194
193
  if color = options.delete(:color)
@@ -288,17 +287,17 @@ module Prawn
288
287
  #
289
288
  def draw_text!(text, options)
290
289
  unless font.unicode? || font.class.hide_m17n_warning || text.ascii_only?
291
- warn "PDF's built-in fonts have very limited support for "+
292
- "internationalized text.\nIf you need full UTF-8 support, "+
293
- "consider using a TTF font instead.\n\nTo disable this "+
294
- "warning, add the following line to your code:\n"+
290
+ warn "PDF's built-in fonts have very limited support for " \
291
+ "internationalized text.\nIf you need full UTF-8 support, " \
292
+ "consider using a TTF font instead.\n\nTo disable this " \
293
+ "warning, add the following line to your code:\n" \
295
294
  "Prawn::Font::AFM.hide_m17n_warning = true\n"
296
295
 
297
296
  font.class.hide_m17n_warning = true
298
297
  end
299
298
 
300
- x,y = map_to_absolute(options[:at])
301
- add_text_content(text,x,y,options)
299
+ x, y = map_to_absolute(options[:at])
300
+ add_text_content(text, x, y, options)
302
301
  end
303
302
 
304
303
  # Gets height of text in PDF points.
@@ -317,7 +316,7 @@ module Prawn
317
316
  # Raises <tt>Prawn::Errrors::CannotFit</tt> if not wide enough to print
318
317
  # any text
319
318
  #
320
- def height_of(string, options={})
319
+ def height_of(string, options = {})
321
320
  height_of_formatted([{ :text => string }], options)
322
321
  end
323
322
 
@@ -331,15 +330,16 @@ module Prawn
331
330
  # :size => 24,
332
331
  # :styles => [:bold, :italic] }])
333
332
  #
334
- def height_of_formatted(array, options={})
333
+ def height_of_formatted(array, options = {})
335
334
  if options[:indent_paragraphs]
336
- raise NotImplementedError, ":indent_paragraphs option not available" +
335
+ fail NotImplementedError, ":indent_paragraphs option not available" \
337
336
  "with height_of"
338
337
  end
339
338
  process_final_gap_option(options)
340
- box = Text::Formatted::Box.new(array,
341
- options.merge(:height => 100000000,
342
- :document => self))
339
+ box = Text::Formatted::Box.new(
340
+ array,
341
+ options.merge(:height => 100000000, :document => self)
342
+ )
343
343
  box.render(:dry_run => true)
344
344
 
345
345
  height = box.height
@@ -359,8 +359,11 @@ module Prawn
359
359
  end
360
360
 
361
361
  def draw_indented_formatted_line(string, options)
362
- gap = options.fetch(:direction, text_direction) == :ltr ?
363
- [@indent_paragraphs, 0] : [0, @indent_paragraphs]
362
+ if options.fetch(:direction, text_direction) == :ltr
363
+ gap = [@indent_paragraphs, 0]
364
+ else
365
+ gap = [0, @indent_paragraphs]
366
+ end
364
367
 
365
368
  indent(*gap) do
366
369
  fill_formatted_text_box(string, options.dup.merge(:single_line => true))
@@ -392,9 +395,9 @@ module Prawn
392
395
 
393
396
  def inspect_options_for_draw_text(options)
394
397
  if options[:at].nil?
395
- raise ArgumentError, "The :at option is required for draw_text"
398
+ fail ArgumentError, "The :at option is required for draw_text"
396
399
  elsif options[:align]
397
- raise ArgumentError, "The :align option does not work with draw_text"
400
+ fail ArgumentError, "The :align option does not work with draw_text"
398
401
  end
399
402
  if options[:kerning].nil? then
400
403
  options[:kerning] = default_kerning?
@@ -406,7 +409,7 @@ module Prawn
406
409
 
407
410
  def inspect_options_for_text(options)
408
411
  if options[:at]
409
- raise ArgumentError, ":at is no longer a valid option with text." +
412
+ fail ArgumentError, ":at is no longer a valid option with text." \
410
413
  "use draw_text or text_box instead"
411
414
  end
412
415
  process_final_gap_option(options)
@@ -101,7 +101,7 @@ module Prawn
101
101
  # Raises <tt>Prawn::Errors::CannotFit</tt> if not wide enough to print
102
102
  # any text
103
103
  #
104
- def text_box(string, options={})
104
+ def text_box(string, options = {})
105
105
  options = options.dup
106
106
  options[:document] = self
107
107
 
@@ -125,17 +125,14 @@ module Prawn
125
125
  # consumed by the printed text
126
126
  #
127
127
  class Box < Prawn::Text::Formatted::Box
128
-
129
- def initialize(string, options={})
128
+ def initialize(string, options = {})
130
129
  super([{ :text => string }], options)
131
130
  end
132
131
 
133
- def render(flags={})
132
+ def render(flags = {})
134
133
  leftover = super(flags)
135
134
  leftover.collect { |hash| hash[:text] }.join
136
135
  end
137
-
138
136
  end
139
-
140
137
  end
141
138
  end