prawn 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (203) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/lib/prawn/document/bounding_box.rb +213 -141
  4. data/lib/prawn/document/column_box.rb +61 -26
  5. data/lib/prawn/document/internals.rb +25 -16
  6. data/lib/prawn/document/span.rb +20 -18
  7. data/lib/prawn/document.rb +257 -171
  8. data/lib/prawn/encoding.rb +2 -5
  9. data/lib/prawn/errors.rb +23 -34
  10. data/lib/prawn/font.rb +248 -135
  11. data/lib/prawn/font_metric_cache.rb +11 -10
  12. data/lib/prawn/fonts/afm.rb +85 -45
  13. data/lib/prawn/fonts/dfont.rb +7 -1
  14. data/lib/prawn/fonts/otf.rb +4 -1
  15. data/lib/prawn/fonts/to_unicode_cmap.rb +151 -0
  16. data/lib/prawn/fonts/ttc.rb +7 -2
  17. data/lib/prawn/fonts/ttf.rb +305 -93
  18. data/lib/prawn/fonts.rb +14 -0
  19. data/lib/prawn/graphics/blend_mode.rb +25 -28
  20. data/lib/prawn/graphics/cap_style.rb +9 -12
  21. data/lib/prawn/graphics/color.rb +57 -34
  22. data/lib/prawn/graphics/dash.rb +45 -42
  23. data/lib/prawn/graphics/join_style.rb +17 -11
  24. data/lib/prawn/graphics/patterns.rb +190 -69
  25. data/lib/prawn/graphics/transformation.rb +48 -41
  26. data/lib/prawn/graphics/transparency.rb +16 -40
  27. data/lib/prawn/graphics.rb +363 -253
  28. data/lib/prawn/grid.rb +184 -57
  29. data/lib/prawn/image_handler.rb +27 -10
  30. data/lib/prawn/images/image.rb +8 -10
  31. data/lib/prawn/images/jpg.rb +42 -19
  32. data/lib/prawn/images/png.rb +92 -41
  33. data/lib/prawn/images.rb +44 -57
  34. data/lib/prawn/measurement_extensions.rb +39 -8
  35. data/lib/prawn/measurements.rb +60 -5
  36. data/lib/prawn/outline.rb +114 -108
  37. data/lib/prawn/repeater.rb +51 -35
  38. data/lib/prawn/security/arcfour.rb +4 -4
  39. data/lib/prawn/security.rb +75 -70
  40. data/lib/prawn/soft_mask.rb +42 -30
  41. data/lib/prawn/stamp.rb +38 -42
  42. data/lib/prawn/text/box.rb +146 -96
  43. data/lib/prawn/text/formatted/arranger.rb +87 -26
  44. data/lib/prawn/text/formatted/box.rb +221 -150
  45. data/lib/prawn/text/formatted/fragment.rb +130 -14
  46. data/lib/prawn/text/formatted/line_wrap.rb +33 -24
  47. data/lib/prawn/text/formatted/parser.rb +112 -72
  48. data/lib/prawn/text/formatted/wrap.rb +12 -17
  49. data/lib/prawn/text/formatted.rb +75 -0
  50. data/lib/prawn/text.rb +441 -196
  51. data/lib/prawn/transformation_stack.rb +29 -10
  52. data/lib/prawn/utilities.rb +13 -13
  53. data/lib/prawn/version.rb +2 -1
  54. data/lib/prawn/view.rb +68 -53
  55. data/lib/prawn.rb +23 -18
  56. data.tar.gz.sig +0 -0
  57. metadata +54 -177
  58. metadata.gz.sig +0 -0
  59. data/.yardopts +0 -10
  60. data/Gemfile +0 -5
  61. data/Rakefile +0 -25
  62. data/manual/absolute_position.pdf +0 -0
  63. data/manual/basic_concepts/adding_pages.rb +0 -26
  64. data/manual/basic_concepts/basic_concepts.rb +0 -43
  65. data/manual/basic_concepts/creation.rb +0 -38
  66. data/manual/basic_concepts/cursor.rb +0 -32
  67. data/manual/basic_concepts/measurement.rb +0 -24
  68. data/manual/basic_concepts/origin.rb +0 -37
  69. data/manual/basic_concepts/other_cursor_helpers.rb +0 -39
  70. data/manual/basic_concepts/view.rb +0 -48
  71. data/manual/bounding_box/bounding_box.rb +0 -41
  72. data/manual/bounding_box/bounds.rb +0 -48
  73. data/manual/bounding_box/canvas.rb +0 -23
  74. data/manual/bounding_box/creation.rb +0 -22
  75. data/manual/bounding_box/indentation.rb +0 -45
  76. data/manual/bounding_box/nesting.rb +0 -52
  77. data/manual/bounding_box/russian_boxes.rb +0 -40
  78. data/manual/bounding_box/stretchy.rb +0 -29
  79. data/manual/contents.rb +0 -35
  80. data/manual/cover.rb +0 -43
  81. data/manual/document_and_page_options/background.rb +0 -29
  82. data/manual/document_and_page_options/document_and_page_options.rb +0 -34
  83. data/manual/document_and_page_options/metadata.rb +0 -25
  84. data/manual/document_and_page_options/page_margins.rb +0 -36
  85. data/manual/document_and_page_options/page_size.rb +0 -34
  86. data/manual/document_and_page_options/print_scaling.rb +0 -23
  87. data/manual/example_helper.rb +0 -8
  88. data/manual/graphics/blend_mode.rb +0 -52
  89. data/manual/graphics/circle_and_ellipse.rb +0 -21
  90. data/manual/graphics/color.rb +0 -22
  91. data/manual/graphics/common_lines.rb +0 -29
  92. data/manual/graphics/fill_and_stroke.rb +0 -41
  93. data/manual/graphics/fill_rules.rb +0 -38
  94. data/manual/graphics/gradients.rb +0 -43
  95. data/manual/graphics/graphics.rb +0 -64
  96. data/manual/graphics/helper.rb +0 -34
  97. data/manual/graphics/line_width.rb +0 -36
  98. data/manual/graphics/lines_and_curves.rb +0 -40
  99. data/manual/graphics/polygon.rb +0 -27
  100. data/manual/graphics/rectangle.rb +0 -20
  101. data/manual/graphics/rotate.rb +0 -25
  102. data/manual/graphics/scale.rb +0 -42
  103. data/manual/graphics/soft_masks.rb +0 -44
  104. data/manual/graphics/stroke_cap.rb +0 -30
  105. data/manual/graphics/stroke_dash.rb +0 -47
  106. data/manual/graphics/stroke_join.rb +0 -29
  107. data/manual/graphics/translate.rb +0 -29
  108. data/manual/graphics/transparency.rb +0 -33
  109. data/manual/how_to_read_this_manual.rb +0 -39
  110. data/manual/images/absolute_position.rb +0 -22
  111. data/manual/images/fit.rb +0 -20
  112. data/manual/images/horizontal.rb +0 -24
  113. data/manual/images/images.rb +0 -41
  114. data/manual/images/plain_image.rb +0 -17
  115. data/manual/images/scale.rb +0 -21
  116. data/manual/images/vertical.rb +0 -30
  117. data/manual/images/width_and_height.rb +0 -24
  118. data/manual/layout/boxes.rb +0 -26
  119. data/manual/layout/content.rb +0 -24
  120. data/manual/layout/layout.rb +0 -27
  121. data/manual/layout/simple_grid.rb +0 -22
  122. data/manual/outline/add_subsection_to.rb +0 -60
  123. data/manual/outline/insert_section_after.rb +0 -46
  124. data/manual/outline/outline.rb +0 -33
  125. data/manual/outline/sections_and_pages.rb +0 -66
  126. data/manual/repeatable_content/alternate_page_numbering.rb +0 -36
  127. data/manual/repeatable_content/page_numbering.rb +0 -55
  128. data/manual/repeatable_content/repeatable_content.rb +0 -35
  129. data/manual/repeatable_content/repeater.rb +0 -54
  130. data/manual/repeatable_content/stamp.rb +0 -40
  131. data/manual/security/encryption.rb +0 -28
  132. data/manual/security/permissions.rb +0 -43
  133. data/manual/security/security.rb +0 -28
  134. data/manual/table.rb +0 -16
  135. data/manual/text/alignment.rb +0 -43
  136. data/manual/text/color.rb +0 -24
  137. data/manual/text/column_box.rb +0 -30
  138. data/manual/text/fallback_fonts.rb +0 -41
  139. data/manual/text/font.rb +0 -40
  140. data/manual/text/font_size.rb +0 -44
  141. data/manual/text/font_style.rb +0 -25
  142. data/manual/text/formatted_callbacks.rb +0 -70
  143. data/manual/text/formatted_text.rb +0 -61
  144. data/manual/text/free_flowing_text.rb +0 -50
  145. data/manual/text/inline.rb +0 -40
  146. data/manual/text/kerning_and_character_spacing.rb +0 -38
  147. data/manual/text/leading.rb +0 -24
  148. data/manual/text/line_wrapping.rb +0 -60
  149. data/manual/text/paragraph_indentation.rb +0 -31
  150. data/manual/text/positioned_text.rb +0 -37
  151. data/manual/text/registering_families.rb +0 -51
  152. data/manual/text/rendering_and_color.rb +0 -36
  153. data/manual/text/right_to_left_text.rb +0 -54
  154. data/manual/text/rotation.rb +0 -52
  155. data/manual/text/single_usage.rb +0 -36
  156. data/manual/text/text.rb +0 -75
  157. data/manual/text/text_box_excess.rb +0 -35
  158. data/manual/text/text_box_extensions.rb +0 -48
  159. data/manual/text/text_box_overflow.rb +0 -51
  160. data/manual/text/utf8.rb +0 -27
  161. data/manual/text/win_ansi_charset.rb +0 -62
  162. data/prawn.gemspec +0 -51
  163. data/spec/data/curves.pdf +0 -66
  164. data/spec/extensions/encoding_helpers.rb +0 -11
  165. data/spec/prawn/document/bounding_box_spec.rb +0 -550
  166. data/spec/prawn/document/column_box_spec.rb +0 -75
  167. data/spec/prawn/document/security_spec.rb +0 -176
  168. data/spec/prawn/document_annotations_spec.rb +0 -76
  169. data/spec/prawn/document_destinations_spec.rb +0 -15
  170. data/spec/prawn/document_grid_spec.rb +0 -99
  171. data/spec/prawn/document_reference_spec.rb +0 -27
  172. data/spec/prawn/document_span_spec.rb +0 -44
  173. data/spec/prawn/document_spec.rb +0 -805
  174. data/spec/prawn/font_metric_cache_spec.rb +0 -54
  175. data/spec/prawn/font_spec.rb +0 -544
  176. data/spec/prawn/graphics/blend_mode_spec.rb +0 -63
  177. data/spec/prawn/graphics/transparency_spec.rb +0 -81
  178. data/spec/prawn/graphics_spec.rb +0 -872
  179. data/spec/prawn/graphics_stroke_styles_spec.rb +0 -229
  180. data/spec/prawn/image_handler_spec.rb +0 -53
  181. data/spec/prawn/images/jpg_spec.rb +0 -20
  182. data/spec/prawn/images/png_spec.rb +0 -283
  183. data/spec/prawn/images_spec.rb +0 -229
  184. data/spec/prawn/measurements_extensions_spec.rb +0 -24
  185. data/spec/prawn/outline_spec.rb +0 -512
  186. data/spec/prawn/repeater_spec.rb +0 -166
  187. data/spec/prawn/soft_mask_spec.rb +0 -74
  188. data/spec/prawn/stamp_spec.rb +0 -173
  189. data/spec/prawn/text/box_spec.rb +0 -1110
  190. data/spec/prawn/text/formatted/arranger_spec.rb +0 -466
  191. data/spec/prawn/text/formatted/box_spec.rb +0 -849
  192. data/spec/prawn/text/formatted/fragment_spec.rb +0 -343
  193. data/spec/prawn/text/formatted/line_wrap_spec.rb +0 -495
  194. data/spec/prawn/text/formatted/parser_spec.rb +0 -697
  195. data/spec/prawn/text_draw_text_spec.rb +0 -150
  196. data/spec/prawn/text_rendering_mode_spec.rb +0 -48
  197. data/spec/prawn/text_spacing_spec.rb +0 -95
  198. data/spec/prawn/text_spec.rb +0 -603
  199. data/spec/prawn/text_with_inline_formatting_spec.rb +0 -35
  200. data/spec/prawn/transformation_stack_spec.rb +0 -66
  201. data/spec/prawn/view_spec.rb +0 -63
  202. data/spec/prawn_manual_spec.rb +0 -35
  203. data/spec/spec_helper.rb +0 -48
@@ -1,31 +1,50 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # transformation_stack.rb : Stores the transformations that have been applied to
4
- # the document
5
- #
6
- # Copyright 2015, Roger Nesbitt. All Rights Reserved.
7
- #
8
- # This is free software. Please see the LICENSE and COPYING files for details.
9
-
10
3
  require 'matrix'
11
4
 
12
- # rubocop: disable Metrics/ParameterLists, Naming/MethodParameterName
13
5
  module Prawn
6
+ # Stores the transformations that have been applied to the document.
7
+ # @private
14
8
  module TransformationStack
9
+ # rubocop: disable Metrics/ParameterLists, Naming/MethodParameterName
10
+
11
+ # Add transformation to the stack.
12
+ #
13
+ # @param a [Number]
14
+ # @param b [Number]
15
+ # @param c [Number]
16
+ # @param d [Number]
17
+ # @param e [Number]
18
+ # @param f [Number]
19
+ # @return [void]
15
20
  def add_to_transformation_stack(a, b, c, d, e, f)
16
21
  @transformation_stack ||= [[]]
17
- @transformation_stack.last.push([a, b, c, d, e, f].map(&:to_f))
22
+ @transformation_stack.last.push([a, b, c, d, e, f].map { |i| Float(i) })
18
23
  end
19
24
 
25
+ # Save transformation stack.
26
+ #
27
+ # @return [void]
20
28
  def save_transformation_stack
21
29
  @transformation_stack ||= [[]]
22
30
  @transformation_stack.push(@transformation_stack.last.dup)
23
31
  end
24
32
 
33
+ # Restore previous transformation.
34
+ #
35
+ # Effectively pops the last transformation off of the transformation stack.
36
+ #
37
+ # @return [void]
25
38
  def restore_transformation_stack
26
39
  @transformation_stack&.pop
27
40
  end
28
41
 
42
+ # Get current transformation matrix. It's a result of multiplication of the
43
+ # whole transformation stack with additional translation.
44
+ #
45
+ # @param x [Number]
46
+ # @param y [Number]
47
+ # @return [Array(Number, Number, Number, Number, Number, Number)]
29
48
  def current_transformation_matrix_with_translation(x = 0, y = 0)
30
49
  transformations = (@transformation_stack || [[]]).last
31
50
 
@@ -39,6 +58,6 @@ module Prawn
39
58
 
40
59
  matrix.to_a[0..1].transpose.flatten
41
60
  end
61
+ # rubocop: enable Metrics/ParameterLists, Naming/MethodParameterName
42
62
  end
43
63
  end
44
- # rubocop: enable Metrics/ParameterLists, Naming/MethodParameterName
@@ -1,32 +1,32 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # utilities.rb : General-purpose utility classes which don't fit anywhere else
4
- #
5
- # Copyright August 2012, Alex Dowad. All Rights Reserved.
6
- #
7
- # This is free software. Please see the LICENSE and COPYING files for details.
8
-
9
3
  module Prawn
10
4
  # Throughout the Prawn codebase, repeated calculations which can benefit from
11
- # caching are made.
12
- # In some cases, caching and reusing results can not only save CPU cycles but
13
- # also greatly reduce memory requirements
14
- # But at the same time, we don't want to throw away thread safety
15
- # We have two interchangeable thread-safe cache implementations:
16
-
5
+ # caching are made. n some cases, caching and reusing results can not only
6
+ # save CPU cycles but also greatly reduce memory requirements But at the same
7
+ # time, we don't want to throw away thread safety.
17
8
  # @private
18
9
  class SynchronizedCache
19
10
  # As an optimization, this could access the hash directly on VMs with
20
- # a global interpreter lock (like MRI)
11
+ # a global interpreter lock (like MRI).
21
12
  def initialize
22
13
  @cache = {}
23
14
  @mutex = Mutex.new
24
15
  end
25
16
 
17
+ # Get cache entry.
18
+ #
19
+ # @param key [any]
20
+ # @return [any]
26
21
  def [](key)
27
22
  @mutex.synchronize { @cache[key] }
28
23
  end
29
24
 
25
+ # Set cache entry.
26
+ #
27
+ # @param key [any]
28
+ # @param value [any]
29
+ # @return [void]
30
30
  def []=(key, value)
31
31
  @mutex.synchronize { @cache[key] = value }
32
32
  end
data/lib/prawn/version.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Prawn
4
- VERSION = '2.4.0'
4
+ # Prawn versions
5
+ VERSION = '2.5.0'
5
6
  end
data/lib/prawn/view.rb CHANGED
@@ -1,99 +1,114 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # prawn/view.rb : Implements a mixin for Prawn's DSL
4
- #
5
- # This is free software. Please see the LICENSE and COPYING files for details.
6
-
7
3
  module Prawn
8
4
  # This mixin allows you to create modular Prawn code without the
9
- # need to create subclasses of Prawn::Document.
5
+ # need to create subclasses of {Prawn::Document}.
10
6
  #
11
- # class Greeter
12
- # include Prawn::View
7
+ # ```ruby
8
+ # class Greeter
9
+ # include Prawn::View
13
10
  #
14
- # # Optional override: allows you to set document options or even use
15
- # # a custom document class
16
- # def document
17
- # @document ||= Prawn::Document.new(page_size: 'A4')
18
- # end
11
+ # # Optional override: allows you to set document options or even use
12
+ # # a custom document class
13
+ # def document
14
+ # @document ||= Prawn::Document.new(page_size: 'A4')
15
+ # end
19
16
  #
20
- # def initialize(name)
21
- # @name = name
22
- # end
17
+ # def initialize(name)
18
+ # @name = name
19
+ # end
23
20
  #
24
- # def say_hello
25
- # text "Hello, #{@name}!"
26
- # end
21
+ # def say_hello
22
+ # text "Hello, #{@name}!"
23
+ # end
27
24
  #
28
- # def say_goodbye
29
- # font("Courier") do
30
- # text "Goodbye, #{@name}!"
31
- # end
32
- # end
33
- # end
25
+ # def say_goodbye
26
+ # font("Courier") do
27
+ # text "Goodbye, #{@name}!"
28
+ # end
29
+ # end
30
+ # end
34
31
  #
35
- # greeter = Greeter.new("Gregory")
32
+ # greeter = Greeter.new("Gregory")
36
33
  #
37
- # greeter.say_hello
38
- # greeter.say_goodbye
34
+ # greeter.say_hello
35
+ # greeter.say_goodbye
39
36
  #
40
- # greeter.save_as("greetings.pdf")
37
+ # greeter.save_as("greetings.pdf")
38
+ # ```
41
39
  #
42
- # The short story about why you should use this mixin rather than
43
- # creating subclasses of +Prawn::Document+ is that it helps
44
- # prevent accidental conflicts between your code and Prawn's
45
- # code.
40
+ # The short story about why you should use this mixin rather than creating
41
+ # subclasses of `Prawn::Document` is that it helps prevent accidental
42
+ # conflicts between your code and Prawn's code.
46
43
  #
47
44
  # Here's the slightly longer story...
48
45
  #
49
- # By using composition rather than inheritance under the hood, this
50
- # mixin allows you to keep your state separate from +Prawn::Document+'s
51
- # state, and also will prevent unexpected method name collisions due
52
- # to late binding effects.
46
+ # By using composition rather than inheritance under the hood, this mixin
47
+ # allows you to keep your state separate from `Prawn::Document`'s state, and
48
+ # also will prevent unexpected method name collisions due to late binding
49
+ # effects.
53
50
  #
54
- # This mixin is mostly meant for extending Prawn's functionality
55
- # with your own additions, but you can also use it to replace or
56
- # wrap existing Prawn methods. Calling +super+ will still work
57
- # as expected, and alternatively you can explictly call
58
- # +document.some_method+ to delegate to Prawn where needed.
51
+ # This mixin is mostly meant for extending Prawn's functionality with your own
52
+ # additions, but you can also use it to replace or wrap existing Prawn
53
+ # methods. Calling `super` will still work as expected, and alternatively you
54
+ # can explicitly call `document.some_method` to delegate to Prawn where
55
+ # needed.
59
56
  module View
60
57
  # @group Experimental API
61
58
 
62
- # Lazily instantiates a +Prawn::Document+ object.
59
+ # Lazily instantiates a `Prawn::Document` object.
63
60
  #
64
61
  # You can also redefine this method in your own classes to use
65
62
  # a custom document class.
63
+ #
64
+ # @return [Prawn::Dcoument]
66
65
  def document
67
66
  @document ||= Prawn::Document.new
68
67
  end
69
68
 
70
- # Delegates all unhandled calls to object returned by +document+ method.
71
- # (which is an instance of Prawn::Document by default)
72
- def method_missing(method_name, *arguments, &block)
69
+ # Delegates all unhandled calls to object returned by {document} method.
70
+ #
71
+ # @param method_name [Symbol]
72
+ # @param args [Array] Positional arguments.
73
+ # @param kwargs [Hash] Keyword arguments.
74
+ # @param block [Proc]
75
+ def method_missing(method_name, *args, **kwargs, &block)
73
76
  return super unless document.respond_to?(method_name)
74
77
 
75
- document.public_send(method_name, *arguments, &block)
78
+ document.public_send(method_name, *args, **kwargs, &block)
76
79
  end
77
80
 
81
+ # Does this object respond to the specified message?
82
+ #
83
+ # @param method_name [Symbol]
84
+ # @param _include_all [Boolean]
85
+ # @return [Boolean]
78
86
  def respond_to_missing?(method_name, _include_all = false)
79
87
  document.respond_to?(method_name) || super
80
88
  end
81
89
 
82
- # Syntactic sugar that uses +instance_eval+ under the hood to provide
90
+ # Syntactic sugar that uses `instance_eval` under the hood to provide
83
91
  # a block-based DSL.
84
92
  #
85
- # greeter.update do
86
- # say_hello
87
- # say_goodbye
88
- # end
93
+ # @example
94
+ # greeter.update do
95
+ # say_hello
96
+ # say_goodbye
97
+ # end
89
98
  #
99
+ # @yield
100
+ # @return [void]
90
101
  def update(&block)
91
102
  instance_eval(&block)
92
103
  end
93
104
 
94
- # Syntatic sugar that calls +document.render_file+ under the hood.
105
+ # Syntatic sugar that calls `document.render_file` under the hood.
106
+ #
107
+ # @example
108
+ # greeter.save_as("greetings.pdf")
95
109
  #
96
- # greeter.save_as("greetings.pdf")
110
+ # @param filename [String]
111
+ # @return [void]
97
112
  def save_as(filename)
98
113
  document.render_file(filename)
99
114
  end
data/lib/prawn.rb CHANGED
@@ -1,36 +1,40 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Welcome to Prawn, the best PDF Generation library ever.
4
- # This documentation covers user level functionality.
5
- #
6
3
  require 'set'
7
4
 
8
5
  require 'ttfunk'
9
6
  require 'pdf/core'
10
7
 
8
+ # Welcome to Prawn, the best PDF Generation library ever.
9
+ # This documentation covers user level functionality.
11
10
  module Prawn
12
11
  file = __FILE__
13
12
  file = File.readlink(file) if File.symlink?(file)
14
13
  dir = File.dirname(file)
15
14
 
16
- # The base source directory for Prawn as installed on the system
17
- #
18
- #
15
+ # The base source directory for Prawn as installed on the system.
19
16
  BASEDIR = File.expand_path(File.join(dir, '..'))
17
+
18
+ # Directory where Prawn keeps its data files.
20
19
  DATADIR = File.expand_path(File.join(dir, '..', 'data'))
21
20
 
21
+ # @deprecated This is not used any more.
22
22
  FLOAT_PRECISION = 1.0e-9
23
23
 
24
- # When set to true, Prawn will verify hash options to ensure only valid keys
25
- # are used. Off by default.
24
+ # When set to `true`, Prawn will verify hash options to ensure only valid keys
25
+ # are used. Off by default.
26
26
  #
27
27
  # Example:
28
- # >> Prawn::Document.new(:tomato => "Juicy")
29
- # Prawn::Errors::UnknownOption:
30
- # Detected unknown option(s): [:tomato]
31
- # Accepted options are: [:page_size, :page_layout, :left_margin, ...]
28
+ #
29
+ # ```shell
30
+ # >> Prawn::Document.new(:tomato => "Juicy")
31
+ # Prawn::Errors::UnknownOption:
32
+ # Detected unknown option(s): [:tomato]
33
+ # Accepted options are: [:page_size, :page_layout, :left_margin, ...]
34
+ # ```
32
35
  #
33
36
  # @private
37
+ # @return [Boolean]
34
38
  attr_accessor :debug
35
39
 
36
40
  module_function :debug, :debug=
@@ -38,13 +42,17 @@ module Prawn
38
42
  module_function
39
43
 
40
44
  # @private
45
+ # @param accepted [Array<Symbol>] list of valid options
46
+ # @param actual [Hash<Symbol, any>] opetions hash to validate
47
+ # @return [void]
48
+ # @raise [Prawn::Errors::UnknownOption]
49
+ # @yield
41
50
  def verify_options(accepted, actual)
42
51
  return unless debug || $DEBUG
43
52
 
44
53
  unless (act = Set[*actual.keys]).subset?(acc = Set[*accepted])
45
54
  raise Prawn::Errors::UnknownOption,
46
- "\nDetected unknown option(s): #{(act - acc).to_a.inspect}\n" \
47
- "Accepted options are: #{accepted.inspect}"
55
+ "\nDetected unknown option(s): #{(act - acc).to_a.inspect}\nAccepted options are: #{accepted.inspect}"
48
56
  end
49
57
  yield if block_given?
50
58
  end
@@ -54,6 +62,7 @@ require_relative 'prawn/version'
54
62
 
55
63
  require_relative 'prawn/errors'
56
64
 
65
+ require_relative 'prawn/image_handler'
57
66
  require_relative 'prawn/utilities'
58
67
  require_relative 'prawn/text'
59
68
  require_relative 'prawn/graphics'
@@ -72,7 +81,3 @@ require_relative 'prawn/repeater'
72
81
  require_relative 'prawn/outline'
73
82
  require_relative 'prawn/grid'
74
83
  require_relative 'prawn/view'
75
- require_relative 'prawn/image_handler'
76
-
77
- Prawn.image_handler.register(Prawn::Images::PNG)
78
- Prawn.image_handler.register(Prawn::Images::JPG)
data.tar.gz.sig CHANGED
Binary file