prawn 2.4.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/prawn/document/bounding_box.rb +213 -141
- data/lib/prawn/document/column_box.rb +61 -26
- data/lib/prawn/document/internals.rb +25 -16
- data/lib/prawn/document/span.rb +20 -18
- data/lib/prawn/document.rb +257 -171
- data/lib/prawn/encoding.rb +2 -5
- data/lib/prawn/errors.rb +23 -34
- data/lib/prawn/font.rb +248 -135
- data/lib/prawn/font_metric_cache.rb +11 -10
- data/lib/prawn/fonts/afm.rb +85 -45
- data/lib/prawn/fonts/dfont.rb +7 -1
- data/lib/prawn/fonts/otf.rb +4 -1
- data/lib/prawn/fonts/to_unicode_cmap.rb +151 -0
- data/lib/prawn/fonts/ttc.rb +7 -2
- data/lib/prawn/fonts/ttf.rb +305 -93
- data/lib/prawn/fonts.rb +14 -0
- data/lib/prawn/graphics/blend_mode.rb +25 -28
- data/lib/prawn/graphics/cap_style.rb +9 -12
- data/lib/prawn/graphics/color.rb +57 -34
- data/lib/prawn/graphics/dash.rb +45 -42
- data/lib/prawn/graphics/join_style.rb +17 -11
- data/lib/prawn/graphics/patterns.rb +190 -69
- data/lib/prawn/graphics/transformation.rb +48 -41
- data/lib/prawn/graphics/transparency.rb +16 -40
- data/lib/prawn/graphics.rb +363 -253
- data/lib/prawn/grid.rb +184 -57
- data/lib/prawn/image_handler.rb +27 -10
- data/lib/prawn/images/image.rb +8 -10
- data/lib/prawn/images/jpg.rb +42 -19
- data/lib/prawn/images/png.rb +92 -41
- data/lib/prawn/images.rb +44 -57
- data/lib/prawn/measurement_extensions.rb +39 -8
- data/lib/prawn/measurements.rb +60 -5
- data/lib/prawn/outline.rb +114 -108
- data/lib/prawn/repeater.rb +51 -35
- data/lib/prawn/security/arcfour.rb +4 -4
- data/lib/prawn/security.rb +75 -70
- data/lib/prawn/soft_mask.rb +42 -30
- data/lib/prawn/stamp.rb +38 -42
- data/lib/prawn/text/box.rb +146 -96
- data/lib/prawn/text/formatted/arranger.rb +87 -26
- data/lib/prawn/text/formatted/box.rb +221 -150
- data/lib/prawn/text/formatted/fragment.rb +130 -14
- data/lib/prawn/text/formatted/line_wrap.rb +33 -24
- data/lib/prawn/text/formatted/parser.rb +112 -72
- data/lib/prawn/text/formatted/wrap.rb +12 -17
- data/lib/prawn/text/formatted.rb +75 -0
- data/lib/prawn/text.rb +441 -196
- data/lib/prawn/transformation_stack.rb +29 -10
- data/lib/prawn/utilities.rb +13 -13
- data/lib/prawn/version.rb +2 -1
- data/lib/prawn/view.rb +68 -53
- data/lib/prawn.rb +23 -18
- data.tar.gz.sig +0 -0
- metadata +54 -177
- metadata.gz.sig +0 -0
- data/.yardopts +0 -10
- data/Gemfile +0 -5
- data/Rakefile +0 -25
- data/manual/absolute_position.pdf +0 -0
- data/manual/basic_concepts/adding_pages.rb +0 -26
- data/manual/basic_concepts/basic_concepts.rb +0 -43
- data/manual/basic_concepts/creation.rb +0 -38
- data/manual/basic_concepts/cursor.rb +0 -32
- data/manual/basic_concepts/measurement.rb +0 -24
- data/manual/basic_concepts/origin.rb +0 -37
- data/manual/basic_concepts/other_cursor_helpers.rb +0 -39
- data/manual/basic_concepts/view.rb +0 -48
- data/manual/bounding_box/bounding_box.rb +0 -41
- data/manual/bounding_box/bounds.rb +0 -48
- data/manual/bounding_box/canvas.rb +0 -23
- data/manual/bounding_box/creation.rb +0 -22
- data/manual/bounding_box/indentation.rb +0 -45
- data/manual/bounding_box/nesting.rb +0 -52
- data/manual/bounding_box/russian_boxes.rb +0 -40
- data/manual/bounding_box/stretchy.rb +0 -29
- data/manual/contents.rb +0 -35
- data/manual/cover.rb +0 -43
- data/manual/document_and_page_options/background.rb +0 -29
- data/manual/document_and_page_options/document_and_page_options.rb +0 -34
- data/manual/document_and_page_options/metadata.rb +0 -25
- data/manual/document_and_page_options/page_margins.rb +0 -36
- data/manual/document_and_page_options/page_size.rb +0 -34
- data/manual/document_and_page_options/print_scaling.rb +0 -23
- data/manual/example_helper.rb +0 -8
- data/manual/graphics/blend_mode.rb +0 -52
- data/manual/graphics/circle_and_ellipse.rb +0 -21
- data/manual/graphics/color.rb +0 -22
- data/manual/graphics/common_lines.rb +0 -29
- data/manual/graphics/fill_and_stroke.rb +0 -41
- data/manual/graphics/fill_rules.rb +0 -38
- data/manual/graphics/gradients.rb +0 -43
- data/manual/graphics/graphics.rb +0 -64
- data/manual/graphics/helper.rb +0 -34
- data/manual/graphics/line_width.rb +0 -36
- data/manual/graphics/lines_and_curves.rb +0 -40
- data/manual/graphics/polygon.rb +0 -27
- data/manual/graphics/rectangle.rb +0 -20
- data/manual/graphics/rotate.rb +0 -25
- data/manual/graphics/scale.rb +0 -42
- data/manual/graphics/soft_masks.rb +0 -44
- data/manual/graphics/stroke_cap.rb +0 -30
- data/manual/graphics/stroke_dash.rb +0 -47
- data/manual/graphics/stroke_join.rb +0 -29
- data/manual/graphics/translate.rb +0 -29
- data/manual/graphics/transparency.rb +0 -33
- data/manual/how_to_read_this_manual.rb +0 -39
- data/manual/images/absolute_position.rb +0 -22
- data/manual/images/fit.rb +0 -20
- data/manual/images/horizontal.rb +0 -24
- data/manual/images/images.rb +0 -41
- data/manual/images/plain_image.rb +0 -17
- data/manual/images/scale.rb +0 -21
- data/manual/images/vertical.rb +0 -30
- data/manual/images/width_and_height.rb +0 -24
- data/manual/layout/boxes.rb +0 -26
- data/manual/layout/content.rb +0 -24
- data/manual/layout/layout.rb +0 -27
- data/manual/layout/simple_grid.rb +0 -22
- data/manual/outline/add_subsection_to.rb +0 -60
- data/manual/outline/insert_section_after.rb +0 -46
- data/manual/outline/outline.rb +0 -33
- data/manual/outline/sections_and_pages.rb +0 -66
- data/manual/repeatable_content/alternate_page_numbering.rb +0 -36
- data/manual/repeatable_content/page_numbering.rb +0 -55
- data/manual/repeatable_content/repeatable_content.rb +0 -35
- data/manual/repeatable_content/repeater.rb +0 -54
- data/manual/repeatable_content/stamp.rb +0 -40
- data/manual/security/encryption.rb +0 -28
- data/manual/security/permissions.rb +0 -43
- data/manual/security/security.rb +0 -28
- data/manual/table.rb +0 -16
- data/manual/text/alignment.rb +0 -43
- data/manual/text/color.rb +0 -24
- data/manual/text/column_box.rb +0 -30
- data/manual/text/fallback_fonts.rb +0 -41
- data/manual/text/font.rb +0 -40
- data/manual/text/font_size.rb +0 -44
- data/manual/text/font_style.rb +0 -25
- data/manual/text/formatted_callbacks.rb +0 -70
- data/manual/text/formatted_text.rb +0 -61
- data/manual/text/free_flowing_text.rb +0 -50
- data/manual/text/inline.rb +0 -40
- data/manual/text/kerning_and_character_spacing.rb +0 -38
- data/manual/text/leading.rb +0 -24
- data/manual/text/line_wrapping.rb +0 -60
- data/manual/text/paragraph_indentation.rb +0 -31
- data/manual/text/positioned_text.rb +0 -37
- data/manual/text/registering_families.rb +0 -51
- data/manual/text/rendering_and_color.rb +0 -36
- data/manual/text/right_to_left_text.rb +0 -54
- data/manual/text/rotation.rb +0 -52
- data/manual/text/single_usage.rb +0 -36
- data/manual/text/text.rb +0 -75
- data/manual/text/text_box_excess.rb +0 -35
- data/manual/text/text_box_extensions.rb +0 -48
- data/manual/text/text_box_overflow.rb +0 -51
- data/manual/text/utf8.rb +0 -27
- data/manual/text/win_ansi_charset.rb +0 -62
- data/prawn.gemspec +0 -51
- data/spec/data/curves.pdf +0 -66
- data/spec/extensions/encoding_helpers.rb +0 -11
- data/spec/prawn/document/bounding_box_spec.rb +0 -550
- data/spec/prawn/document/column_box_spec.rb +0 -75
- data/spec/prawn/document/security_spec.rb +0 -176
- data/spec/prawn/document_annotations_spec.rb +0 -76
- data/spec/prawn/document_destinations_spec.rb +0 -15
- data/spec/prawn/document_grid_spec.rb +0 -99
- data/spec/prawn/document_reference_spec.rb +0 -27
- data/spec/prawn/document_span_spec.rb +0 -44
- data/spec/prawn/document_spec.rb +0 -805
- data/spec/prawn/font_metric_cache_spec.rb +0 -54
- data/spec/prawn/font_spec.rb +0 -544
- data/spec/prawn/graphics/blend_mode_spec.rb +0 -63
- data/spec/prawn/graphics/transparency_spec.rb +0 -81
- data/spec/prawn/graphics_spec.rb +0 -872
- data/spec/prawn/graphics_stroke_styles_spec.rb +0 -229
- data/spec/prawn/image_handler_spec.rb +0 -53
- data/spec/prawn/images/jpg_spec.rb +0 -20
- data/spec/prawn/images/png_spec.rb +0 -283
- data/spec/prawn/images_spec.rb +0 -229
- data/spec/prawn/measurements_extensions_spec.rb +0 -24
- data/spec/prawn/outline_spec.rb +0 -512
- data/spec/prawn/repeater_spec.rb +0 -166
- data/spec/prawn/soft_mask_spec.rb +0 -74
- data/spec/prawn/stamp_spec.rb +0 -173
- data/spec/prawn/text/box_spec.rb +0 -1110
- data/spec/prawn/text/formatted/arranger_spec.rb +0 -466
- data/spec/prawn/text/formatted/box_spec.rb +0 -849
- data/spec/prawn/text/formatted/fragment_spec.rb +0 -343
- data/spec/prawn/text/formatted/line_wrap_spec.rb +0 -495
- data/spec/prawn/text/formatted/parser_spec.rb +0 -697
- data/spec/prawn/text_draw_text_spec.rb +0 -150
- data/spec/prawn/text_rendering_mode_spec.rb +0 -48
- data/spec/prawn/text_spacing_spec.rb +0 -95
- data/spec/prawn/text_spec.rb +0 -603
- data/spec/prawn/text_with_inline_formatting_spec.rb +0 -35
- data/spec/prawn/transformation_stack_spec.rb +0 -66
- data/spec/prawn/view_spec.rb +0 -63
- data/spec/prawn_manual_spec.rb +0 -35
- 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(
|
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
|
data/lib/prawn/utilities.rb
CHANGED
@@ -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
|
-
#
|
13
|
-
#
|
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
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
|
-
#
|
12
|
-
#
|
7
|
+
# ```ruby
|
8
|
+
# class Greeter
|
9
|
+
# include Prawn::View
|
13
10
|
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
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
|
-
#
|
21
|
-
#
|
22
|
-
#
|
17
|
+
# def initialize(name)
|
18
|
+
# @name = name
|
19
|
+
# end
|
23
20
|
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
21
|
+
# def say_hello
|
22
|
+
# text "Hello, #{@name}!"
|
23
|
+
# end
|
27
24
|
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
25
|
+
# def say_goodbye
|
26
|
+
# font("Courier") do
|
27
|
+
# text "Goodbye, #{@name}!"
|
28
|
+
# end
|
29
|
+
# end
|
30
|
+
# end
|
34
31
|
#
|
35
|
-
#
|
32
|
+
# greeter = Greeter.new("Gregory")
|
36
33
|
#
|
37
|
-
#
|
38
|
-
#
|
34
|
+
# greeter.say_hello
|
35
|
+
# greeter.say_goodbye
|
39
36
|
#
|
40
|
-
#
|
37
|
+
# greeter.save_as("greetings.pdf")
|
38
|
+
# ```
|
41
39
|
#
|
42
|
-
# The short story about why you should use this mixin rather than
|
43
|
-
#
|
44
|
-
#
|
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
|
-
#
|
51
|
-
#
|
52
|
-
#
|
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
|
-
#
|
56
|
-
#
|
57
|
-
#
|
58
|
-
#
|
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
|
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
|
71
|
-
#
|
72
|
-
|
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, *
|
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
|
90
|
+
# Syntactic sugar that uses `instance_eval` under the hood to provide
|
83
91
|
# a block-based DSL.
|
84
92
|
#
|
85
|
-
#
|
86
|
-
#
|
87
|
-
#
|
88
|
-
#
|
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
|
105
|
+
# Syntatic sugar that calls `document.render_file` under the hood.
|
106
|
+
#
|
107
|
+
# @example
|
108
|
+
# greeter.save_as("greetings.pdf")
|
95
109
|
#
|
96
|
-
#
|
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
|
25
|
-
# are used.
|
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
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
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}\
|
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
|