prawn 2.2.2 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (199) hide show
  1. checksums.yaml +5 -5
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/GPLv2 +20 -21
  5. data/Gemfile +2 -0
  6. data/Rakefile +10 -3
  7. data/lib/prawn.rb +9 -3
  8. data/lib/prawn/document.rb +40 -18
  9. data/lib/prawn/document/bounding_box.rb +9 -4
  10. data/lib/prawn/document/column_box.rb +2 -0
  11. data/lib/prawn/document/internals.rb +6 -4
  12. data/lib/prawn/document/span.rb +2 -0
  13. data/lib/prawn/encoding.rb +4 -1
  14. data/lib/prawn/errors.rb +2 -0
  15. data/lib/prawn/font.rb +34 -17
  16. data/lib/prawn/font_metric_cache.rb +8 -3
  17. data/lib/prawn/{font → fonts}/afm.rb +14 -7
  18. data/lib/prawn/{font → fonts}/dfont.rb +3 -1
  19. data/lib/prawn/fonts/otf.rb +11 -0
  20. data/lib/prawn/{font → fonts}/ttc.rb +3 -1
  21. data/lib/prawn/{font → fonts}/ttf.rb +23 -12
  22. data/lib/prawn/graphics.rb +24 -26
  23. data/lib/prawn/graphics/blend_mode.rb +2 -0
  24. data/lib/prawn/graphics/cap_style.rb +2 -0
  25. data/lib/prawn/graphics/color.rb +8 -3
  26. data/lib/prawn/graphics/dash.rb +3 -1
  27. data/lib/prawn/graphics/join_style.rb +2 -0
  28. data/lib/prawn/graphics/patterns.rb +7 -2
  29. data/lib/prawn/graphics/transformation.rb +5 -1
  30. data/lib/prawn/graphics/transparency.rb +2 -0
  31. data/lib/prawn/grid.rb +39 -38
  32. data/lib/prawn/image_handler.rb +2 -0
  33. data/lib/prawn/images.rb +21 -19
  34. data/lib/prawn/images/image.rb +2 -0
  35. data/lib/prawn/images/jpg.rb +2 -0
  36. data/lib/prawn/images/png.rb +9 -9
  37. data/lib/prawn/measurement_extensions.rb +2 -0
  38. data/lib/prawn/measurements.rb +5 -0
  39. data/lib/prawn/outline.rb +2 -0
  40. data/lib/prawn/repeater.rb +2 -0
  41. data/lib/prawn/security.rb +26 -24
  42. data/lib/prawn/security/arcfour.rb +2 -0
  43. data/lib/prawn/soft_mask.rb +3 -1
  44. data/lib/prawn/stamp.rb +4 -1
  45. data/lib/prawn/text.rb +14 -12
  46. data/lib/prawn/text/box.rb +3 -1
  47. data/lib/prawn/text/formatted.rb +2 -0
  48. data/lib/prawn/text/formatted/arranger.rb +12 -12
  49. data/lib/prawn/text/formatted/box.rb +23 -13
  50. data/lib/prawn/text/formatted/fragment.rb +2 -0
  51. data/lib/prawn/text/formatted/line_wrap.rb +10 -8
  52. data/lib/prawn/text/formatted/parser.rb +8 -10
  53. data/lib/prawn/text/formatted/wrap.rb +4 -2
  54. data/lib/prawn/transformation_stack.rb +5 -2
  55. data/lib/prawn/utilities.rb +2 -2
  56. data/lib/prawn/version.rb +3 -1
  57. data/lib/prawn/view.rb +15 -7
  58. data/manual/basic_concepts/adding_pages.rb +2 -0
  59. data/manual/basic_concepts/basic_concepts.rb +4 -2
  60. data/manual/basic_concepts/creation.rb +2 -0
  61. data/manual/basic_concepts/cursor.rb +2 -0
  62. data/manual/basic_concepts/measurement.rb +3 -1
  63. data/manual/basic_concepts/origin.rb +2 -0
  64. data/manual/basic_concepts/other_cursor_helpers.rb +2 -0
  65. data/manual/basic_concepts/view.rb +2 -0
  66. data/manual/bounding_box/bounding_box.rb +4 -2
  67. data/manual/bounding_box/bounds.rb +6 -4
  68. data/manual/bounding_box/canvas.rb +2 -0
  69. data/manual/bounding_box/creation.rb +2 -0
  70. data/manual/bounding_box/indentation.rb +2 -0
  71. data/manual/bounding_box/nesting.rb +2 -0
  72. data/manual/bounding_box/russian_boxes.rb +6 -4
  73. data/manual/bounding_box/stretchy.rb +2 -0
  74. data/manual/contents.rb +2 -0
  75. data/manual/cover.rb +10 -7
  76. data/manual/document_and_page_options/background.rb +2 -0
  77. data/manual/document_and_page_options/document_and_page_options.rb +4 -2
  78. data/manual/document_and_page_options/metadata.rb +2 -0
  79. data/manual/document_and_page_options/page_margins.rb +2 -0
  80. data/manual/document_and_page_options/page_size.rb +2 -0
  81. data/manual/document_and_page_options/print_scaling.rb +2 -0
  82. data/manual/example_helper.rb +5 -2
  83. data/manual/graphics/blend_mode.rb +6 -4
  84. data/manual/graphics/circle_and_ellipse.rb +2 -0
  85. data/manual/graphics/color.rb +2 -0
  86. data/manual/graphics/common_lines.rb +2 -0
  87. data/manual/graphics/fill_and_stroke.rb +2 -0
  88. data/manual/graphics/fill_rules.rb +2 -0
  89. data/manual/graphics/gradients.rb +2 -0
  90. data/manual/graphics/graphics.rb +4 -2
  91. data/manual/graphics/helper.rb +2 -0
  92. data/manual/graphics/line_width.rb +3 -0
  93. data/manual/graphics/lines_and_curves.rb +2 -0
  94. data/manual/graphics/polygon.rb +2 -0
  95. data/manual/graphics/rectangle.rb +2 -0
  96. data/manual/graphics/rotate.rb +2 -0
  97. data/manual/graphics/scale.rb +2 -0
  98. data/manual/graphics/soft_masks.rb +2 -0
  99. data/manual/graphics/stroke_cap.rb +3 -1
  100. data/manual/graphics/stroke_dash.rb +2 -0
  101. data/manual/graphics/stroke_join.rb +3 -1
  102. data/manual/graphics/translate.rb +2 -0
  103. data/manual/graphics/transparency.rb +2 -0
  104. data/manual/how_to_read_this_manual.rb +2 -0
  105. data/manual/images/absolute_position.rb +2 -0
  106. data/manual/images/fit.rb +2 -0
  107. data/manual/images/horizontal.rb +3 -1
  108. data/manual/images/images.rb +4 -2
  109. data/manual/images/plain_image.rb +2 -0
  110. data/manual/images/scale.rb +2 -0
  111. data/manual/images/vertical.rb +3 -1
  112. data/manual/images/width_and_height.rb +2 -0
  113. data/manual/layout/boxes.rb +2 -0
  114. data/manual/layout/content.rb +2 -0
  115. data/manual/layout/layout.rb +4 -2
  116. data/manual/layout/simple_grid.rb +2 -0
  117. data/manual/outline/add_subsection_to.rb +2 -0
  118. data/manual/outline/insert_section_after.rb +2 -0
  119. data/manual/outline/outline.rb +4 -2
  120. data/manual/outline/sections_and_pages.rb +2 -0
  121. data/manual/repeatable_content/alternate_page_numbering.rb +2 -0
  122. data/manual/repeatable_content/page_numbering.rb +2 -0
  123. data/manual/repeatable_content/repeatable_content.rb +4 -2
  124. data/manual/repeatable_content/repeater.rb +2 -0
  125. data/manual/repeatable_content/stamp.rb +2 -0
  126. data/manual/security/encryption.rb +2 -0
  127. data/manual/security/permissions.rb +2 -0
  128. data/manual/security/security.rb +4 -2
  129. data/manual/table.rb +2 -0
  130. data/manual/text/alignment.rb +2 -0
  131. data/manual/text/color.rb +2 -0
  132. data/manual/text/column_box.rb +4 -2
  133. data/manual/text/fallback_fonts.rb +4 -2
  134. data/manual/text/font.rb +2 -0
  135. data/manual/text/font_size.rb +2 -0
  136. data/manual/text/font_style.rb +4 -2
  137. data/manual/text/formatted_callbacks.rb +2 -0
  138. data/manual/text/formatted_text.rb +3 -1
  139. data/manual/text/free_flowing_text.rb +2 -0
  140. data/manual/text/inline.rb +2 -0
  141. data/manual/text/kerning_and_character_spacing.rb +2 -0
  142. data/manual/text/leading.rb +2 -0
  143. data/manual/text/line_wrapping.rb +4 -1
  144. data/manual/text/paragraph_indentation.rb +2 -0
  145. data/manual/text/positioned_text.rb +2 -0
  146. data/manual/text/registering_families.rb +4 -2
  147. data/manual/text/rendering_and_color.rb +2 -0
  148. data/manual/text/right_to_left_text.rb +2 -0
  149. data/manual/text/rotation.rb +3 -1
  150. data/manual/text/single_usage.rb +2 -0
  151. data/manual/text/text.rb +4 -3
  152. data/manual/text/text_box_excess.rb +2 -0
  153. data/manual/text/text_box_extensions.rb +2 -0
  154. data/manual/text/text_box_overflow.rb +3 -1
  155. data/manual/text/utf8.rb +3 -1
  156. data/manual/text/win_ansi_charset.rb +6 -3
  157. data/prawn.gemspec +14 -11
  158. data/spec/extensions/encoding_helpers.rb +4 -2
  159. data/spec/prawn/document/bounding_box_spec.rb +8 -8
  160. data/spec/prawn/document/column_box_spec.rb +2 -0
  161. data/spec/prawn/document/security_spec.rb +12 -9
  162. data/spec/prawn/document_annotations_spec.rb +2 -0
  163. data/spec/prawn/document_destinations_spec.rb +2 -0
  164. data/spec/prawn/document_grid_spec.rb +3 -0
  165. data/spec/prawn/document_reference_spec.rb +2 -0
  166. data/spec/prawn/document_span_spec.rb +2 -0
  167. data/spec/prawn/document_spec.rb +59 -14
  168. data/spec/prawn/font_metric_cache_spec.rb +2 -0
  169. data/spec/prawn/font_spec.rb +45 -16
  170. data/spec/prawn/graphics/blend_mode_spec.rb +4 -2
  171. data/spec/prawn/graphics/transparency_spec.rb +2 -0
  172. data/spec/prawn/graphics_spec.rb +40 -20
  173. data/spec/prawn/graphics_stroke_styles_spec.rb +2 -0
  174. data/spec/prawn/image_handler_spec.rb +2 -0
  175. data/spec/prawn/images/jpg_spec.rb +2 -0
  176. data/spec/prawn/images/png_spec.rb +2 -0
  177. data/spec/prawn/images_spec.rb +56 -2
  178. data/spec/prawn/measurements_extensions_spec.rb +2 -0
  179. data/spec/prawn/outline_spec.rb +6 -2
  180. data/spec/prawn/repeater_spec.rb +6 -4
  181. data/spec/prawn/soft_mask_spec.rb +2 -0
  182. data/spec/prawn/stamp_spec.rb +11 -7
  183. data/spec/prawn/text/box_spec.rb +26 -27
  184. data/spec/prawn/text/formatted/arranger_spec.rb +30 -28
  185. data/spec/prawn/text/formatted/box_spec.rb +78 -57
  186. data/spec/prawn/text/formatted/fragment_spec.rb +10 -8
  187. data/spec/prawn/text/formatted/line_wrap_spec.rb +8 -5
  188. data/spec/prawn/text/formatted/parser_spec.rb +32 -2
  189. data/spec/prawn/text_draw_text_spec.rb +5 -3
  190. data/spec/prawn/text_rendering_mode_spec.rb +7 -1
  191. data/spec/prawn/text_spacing_spec.rb +6 -4
  192. data/spec/prawn/text_spec.rb +9 -7
  193. data/spec/prawn/text_with_inline_formatting_spec.rb +3 -1
  194. data/spec/prawn/transformation_stack_spec.rb +2 -0
  195. data/spec/prawn/view_spec.rb +18 -0
  196. data/spec/{manual_spec.rb → prawn_manual_spec.rb} +6 -4
  197. data/spec/spec_helper.rb +9 -10
  198. metadata +86 -73
  199. metadata.gz.sig +4 -2
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Most font families come with some styles other than normal. Most common are
2
4
  # <code>bold</code>, <code>italic</code> and <code>bold_italic</code>.
3
5
  #
@@ -9,10 +11,10 @@ require_relative '../example_helper'
9
11
 
10
12
  filename = File.basename(__FILE__).gsub('.rb', '.pdf')
11
13
  Prawn::ManualBuilder::Example.generate(filename) do
12
- ['Courier', 'Helvetica', 'Times-Roman'].each do |example_font|
14
+ %w[Courier Helvetica Times-Roman].each do |example_font|
13
15
  move_down 20
14
16
 
15
- [:bold, :bold_italic, :italic, :normal].each do |style|
17
+ %i[bold bold_italic italic normal].each do |style|
16
18
  font example_font, style: style
17
19
  text "I'm writing in #{example_font} (#{style})"
18
20
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # The <code>:callback</code> option is also available for the formatted text
2
4
  # methods.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # There are two other text methods available: <code>formatted_text</code> and
2
4
  # <code>formatted_text_box</code>.
3
5
  #
@@ -25,7 +27,7 @@ Prawn::ManualBuilder::Example.generate(filename) do
25
27
  formatted_text [
26
28
  { text: 'Some bold. ', styles: [:bold] },
27
29
  { text: 'Some italic. ', styles: [:italic] },
28
- { text: 'Bold italic. ', styles: [:bold, :italic] },
30
+ { text: 'Bold italic. ', styles: %i[bold italic] },
29
31
  { text: 'Bigger Text. ', size: 20 },
30
32
  { text: 'More spacing. ', character_spacing: 3 },
31
33
  { text: 'Different Font. ', font: 'Courier' },
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Text rendering can be as simple or as complex as you want.
2
4
  #
3
5
  # This example covers the most basic method: <code>text</code>. It is meant for
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Inline formatting gives you the option to format specific portions of a text.
2
4
  # It uses HTML-esque syntax inside the text string. Supported tags are:
3
5
  # <code>b</code> (bold), <code>i</code> (italic), <code>u</code> (underline),
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Kerning is the process of adjusting the spacing between characters in a
2
4
  # proportional font. It is usually done with specific letter pairs. We can
3
5
  # switch it on and off if it is available with the current font. Just pass a
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Leading is the additional space between lines of text.
2
4
  #
3
5
  # The leading can be set using the <code>default_leading</code> method which
@@ -1,9 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Line wrapping happens on white space or hyphens. Soft hyphens can be used to
2
4
  # indicate where words can be hyphenated. Non-breaking spaces can be used to
3
5
  # display space without allowing for a break.
4
6
  #
5
7
  # For writing styles that do not make use of spaces, the zero width space serves
6
- # to mark word boundaries. Zero width spaces are available only with TTF fonts.
8
+ # to mark word boundaries. Zero width spaces are available only with external
9
+ # fonts.
7
10
 
8
11
  require_relative '../example_helper'
9
12
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Prawn strips all whitespace from the beginning and the end of strings so there
2
4
  # are two ways to indent paragraphs:
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Sometimes we want the text on a specific position on the page. The
2
4
  # <code>text</code> method just won't help us.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Registering font families will help you when you want to use a font over and
2
4
  # over or if you would like to take advantage of the <code>:style</code> option
3
5
  # of the text methods and the <code>b</code> and <code>i</code> tags when using
@@ -10,7 +12,7 @@ require_relative '../example_helper'
10
12
 
11
13
  filename = File.basename(__FILE__).gsub('.rb', '.pdf')
12
14
  Prawn::ManualBuilder::Example.generate(filename) do
13
- # Registering a single TTF font
15
+ # Registering a single external font
14
16
  font_families.update(
15
17
  'DejaVu Sans' => {
16
18
  normal: "#{Prawn::DATADIR}/fonts/DejaVuSans.ttf"
@@ -41,7 +43,7 @@ Prawn::ManualBuilder::Example.generate(filename) do
41
43
  inline_format: true
42
44
  move_down 20
43
45
 
44
- [:bold, :bold_italic, :italic, :normal].each do |style|
46
+ %i[bold bold_italic italic normal].each do |style|
45
47
  text "Using the #{style} style option.",
46
48
  style: style
47
49
  move_down 10
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # You have already seen how to set the text color using both inline formatting
2
4
  # and the format text methods. There is another way by using the graphics
3
5
  # methods <code>fill_color</code> and <code>stroke_color</code>.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Prawn can be used with right-to-left text. The direction can be set
2
4
  # document-wide, on particular text, or on a text-box. Setting the direction to
3
5
  # <code>:rtl</code> automatically changes the default alignment to
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Rotating text is best avoided on free flowing text, so this example
2
4
  # will only use the <code>text_box</code> method as we can have much more
3
5
  # control over its output.
@@ -29,7 +31,7 @@ Prawn::ManualBuilder::Example.generate(filename) do
29
31
  rotate: angle, rotate_around: :center
30
32
  )
31
33
 
32
- [:lower_left, :upper_left, :lower_right, :upper_right]
34
+ %i[lower_left upper_left lower_right upper_right]
33
35
  .each_with_index do |corner, index|
34
36
  y -= 100 if index == 2
35
37
  stroke_rectangle [x + (index % 2) * 200, y], width, height
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # The PDF format has some built-in font support. If you want to use other fonts
2
4
  # in Prawn you need to embed the font file.
3
5
  #
@@ -1,8 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Examples for text rendering.
2
4
 
3
5
  require '../example_helper'
4
6
 
5
- # rubocop: disable Metrics/LineLength
6
7
  Prawn::ManualBuilder::Example.generate('text.pdf', page_size: 'FOLIO') do
7
8
  package 'text' do |p|
8
9
  p.section 'Basics' do |s|
@@ -47,14 +48,14 @@ Prawn::ManualBuilder::Example.generate('text.pdf', page_size: 'FOLIO') do
47
48
  end
48
49
 
49
50
  p.intro do
50
- prose <<-END
51
+ prose <<-TEXT
51
52
  This is probably the feature people will use the most. There is no
52
53
  shortage of options when it comes to text. You'll be hard pressed to
53
54
  find a use case that is not covered by one of the text methods and
54
55
  configurable options.
55
56
 
56
57
  The examples show:
57
- END
58
+ TEXT
58
59
 
59
60
  list(
60
61
  'Text that flows from page to page automatically starting new pages when necessary',
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Whenever the <code>text_box</code> method truncates text, this truncated bit
2
4
  # is not lost, it is the method return value and we can take advantage of that.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # We've already seen one way of using text boxes with the <code>text_box</code>
2
4
  # method. Turns out this method is just a convenience for using the
3
5
  # <code>Prawn::Text::Box</code> class as it creates a new object and call
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # The <code>text_box</code> method accepts both <code>:width</code> and
2
4
  # <code>:height</code> options. So what happens if the text doesn't fit the box?
3
5
  #
@@ -24,7 +26,7 @@ Prawn::ManualBuilder::Example.generate(filename) do
24
26
  text string
25
27
 
26
28
  y_position = cursor - 20
27
- [:truncate, :expand, :shrink_to_fit].each_with_index do |mode, i|
29
+ %i[truncate expand shrink_to_fit].each_with_index do |mode, i|
28
30
  text_box string, at: [i * 150, y_position],
29
31
  width: 100,
30
32
  height: 50,
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Multilingualization isn't much of a problem on Prawn as its default encoding
2
4
  # is UTF-8. The only thing you need to worry about is if the font support the
3
5
  # glyphs of your language.
@@ -15,7 +17,7 @@ Prawn::ManualBuilder::Example.generate(filename) do
15
17
 
16
18
  move_down 20
17
19
 
18
- text 'For full internationalized text support, we need to use TTF fonts:'
20
+ text 'For full internationalized text support, we need to use external fonts:'
19
21
  move_down 20
20
22
 
21
23
  font("#{Prawn::DATADIR}/fonts/DejaVuSans.ttf") do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Prints a list of all of the glyphs that can be rendered by Adobe's built
2
4
  # in fonts, along with their character widths and WinAnsi codes. Be sure
3
5
  # to pass these glyphs as UTF-8, and Prawn will transcode them for you.
@@ -22,6 +24,7 @@ Prawn::ManualBuilder::Example.generate(filename) do
22
24
 
23
25
  Prawn::Encoding::WinAnsi::CHARACTERS.each_with_index do |name, index|
24
26
  next if name == '.notdef'
27
+
25
28
  y -= FONT_SIZE
26
29
 
27
30
  if y < FONT_SIZE
@@ -29,11 +32,11 @@ Prawn::ManualBuilder::Example.generate(filename) do
29
32
  x += 170
30
33
  end
31
34
 
32
- code = format('%d.', index)
35
+ code = format('%<index>d.', index: index)
33
36
  char = index.chr.force_encoding(::Encoding::Windows_1252)
34
37
 
35
38
  width = 1000 * width_of(char, size: FONT_SIZE) / FONT_SIZE
36
- size = format('%d', width)
39
+ size = format('%<width>d', width: width)
37
40
 
38
41
  data = [code, nil, char, size, nil, name]
39
42
  dx = x
@@ -48,7 +51,7 @@ Prawn::ManualBuilder::Example.generate(filename) do
48
51
  end
49
52
 
50
53
  text_box(
51
- field.force_encoding('windows-1252').encode('UTF-8'),
54
+ field.dup.force_encoding('windows-1252').encode('UTF-8'),
52
55
  at: [dx + offset, y]
53
56
  )
54
57
  end
@@ -1,4 +1,6 @@
1
- basedir = File.expand_path(File.dirname(__FILE__))
1
+ # frozen_string_literal: true
2
+
3
+ basedir = __dir__
2
4
 
3
5
  require "#{basedir}/lib/prawn/version"
4
6
 
@@ -10,7 +12,7 @@ Gem::Specification.new do |spec|
10
12
 
11
13
  spec.cert_chain = ['certs/pointlessone.pem']
12
14
  if $PROGRAM_NAME.end_with? 'gem'
13
- spec.signing_key = File.expand_path('~/.ssh/gem-private_key.pem')
15
+ spec.signing_key = File.expand_path('~/.gem/gem-private_key.pem')
14
16
  end
15
17
 
16
18
  spec.files = Dir.glob('{examples,lib,spec,manual}/**/**/*') +
@@ -21,7 +23,7 @@ Gem::Specification.new do |spec|
21
23
  '.yardopts'
22
24
  ]
23
25
  spec.require_path = 'lib'
24
- spec.required_ruby_version = '~> 2.1'
26
+ spec.required_ruby_version = '~> 2.5'
25
27
  spec.required_rubygems_version = '>= 1.3.6'
26
28
 
27
29
  spec.authors = [
@@ -34,18 +36,19 @@ Gem::Specification.new do |spec|
34
36
  ]
35
37
  spec.licenses = %w[PRAWN GPL-2.0 GPL-3.0]
36
38
 
37
- spec.add_dependency('ttfunk', '~> 1.5')
38
- spec.add_dependency('pdf-core', '~> 0.7.0')
39
+ spec.add_dependency('pdf-core', '~> 0.8.1')
40
+ spec.add_dependency('ttfunk', '~> 1.6')
39
41
 
40
42
  spec.add_development_dependency('pdf-inspector', '>= 1.2.1', '< 2.0.a')
41
- spec.add_development_dependency('yard')
42
- spec.add_development_dependency('rspec', '~> 3.0')
43
+ spec.add_development_dependency('pdf-reader', ['~> 1.4', '>= 1.4.1'])
44
+ spec.add_development_dependency('prawn-manual_builder', '>= 0.3.0')
43
45
  spec.add_development_dependency('rake', '~> 12.0')
46
+ spec.add_development_dependency('rspec', '~> 3.0')
47
+ spec.add_development_dependency('rubocop', '~> 0.84.0')
48
+ spec.add_development_dependency('rubocop-performance', '~> 1.1')
49
+ spec.add_development_dependency('rubocop-rspec', '~> 1.32')
44
50
  spec.add_development_dependency('simplecov')
45
- spec.add_development_dependency('prawn-manual_builder', '>= 0.2.0')
46
- spec.add_development_dependency('pdf-reader', ['~> 1.4', '>= 1.4.1'])
47
- spec.add_development_dependency('rubocop', '~> 0.47.1')
48
- spec.add_development_dependency('rubocop-rspec', '~> 1.10')
51
+ spec.add_development_dependency('yard')
49
52
 
50
53
  spec.homepage = 'http://prawnpdf.org'
51
54
  spec.description = <<END_DESC
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module EncodingHelpers
2
4
  def win1252_string(str)
3
- str.force_encoding(Encoding::Windows_1252)
5
+ str.dup.force_encoding(Encoding::Windows_1252)
4
6
  end
5
7
 
6
8
  def bin_string(str)
7
- str.force_encoding(Encoding::ASCII_8BIT)
9
+ str.dup.force_encoding(Encoding::ASCII_8BIT)
8
10
  end
9
11
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Prawn::Document::BoundingBox do
@@ -183,8 +185,8 @@ describe Prawn::Document::BoundingBox do
183
185
  expect(pdf.y).to be_within(0.001).of(orig_y - pdf.height_of('hello'))
184
186
  end
185
187
 
186
- it 'should not advance y-position of a stretchy bbox if it would stretch ' \
187
- 'the bbox further' do
188
+ it 'does not advance y-position of a stretchy bbox if it would stretch '\
189
+ 'the bbox further' do
188
190
  bottom = pdf.y = pdf.margin_box.absolute_bottom
189
191
  pdf.bounding_box [0, pdf.margin_box.top], width: pdf.bounds.width do
190
192
  pdf.y = bottom
@@ -224,12 +226,10 @@ describe Prawn::Document::BoundingBox do
224
226
 
225
227
  it 'restores the x coordinate and width on error' do
226
228
  pdf.bounding_box([100, 100], width: 200) do
227
- begin
228
- pdf.indent(20) { raise }
229
- rescue
230
- expect(pdf.bounds.absolute_left).to eq(100)
231
- expect(pdf.bounds.width).to eq(200)
232
- end
229
+ pdf.indent(20) { raise }
230
+ rescue StandardError
231
+ expect(pdf.bounds.absolute_left).to eq(100)
232
+ expect(pdf.bounds.width).to eq(200)
233
233
  end
234
234
  end
235
235
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Prawn::Document::ColumnBox do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'tempfile'
3
5
 
@@ -17,7 +19,7 @@ describe Prawn::Document::Security do
17
19
  padded = pad_password(pw)
18
20
  expect(padded.length).to eq(32)
19
21
  expect(padded).to eq(
20
- pw + Prawn::Document::Security::PasswordPadding[0, 28]
22
+ pw + Prawn::Document::Security::PASSWORD_PADDING[0, 28]
21
23
  )
22
24
  end
23
25
 
@@ -25,7 +27,7 @@ describe Prawn::Document::Security do
25
27
  pw = ''
26
28
  padded = pad_password(pw)
27
29
  expect(padded.length).to eq(32)
28
- expect(padded).to eq(Prawn::Document::Security::PasswordPadding)
30
+ expect(padded).to eq(Prawn::Document::Security::PASSWORD_PADDING)
29
31
  end
30
32
  end
31
33
 
@@ -33,10 +35,11 @@ describe Prawn::Document::Security do
33
35
  def doc_with_permissions(permissions)
34
36
  pdf = Prawn::Document.new
35
37
 
36
- class << pdf
37
- # Make things easier to test
38
- public :permissions_value
39
- end
38
+ # Make things easier to test
39
+ pdf.singleton_class.send :public, :permissions_value
40
+ # class << pdf
41
+ # public :permissions_value
42
+ # end
40
43
 
41
44
  pdf.encrypt_document(permissions: permissions)
42
45
  pdf
@@ -90,17 +93,17 @@ describe Prawn::Document::Security do
90
93
  end
91
94
 
92
95
  it 'calculates the correct owner hash' do
93
- expect(pdf.owner_password_hash.unpack('H*').first)
96
+ expect(pdf.owner_password_hash.unpack1('H*'))
94
97
  .to match(/^61CA855012/i)
95
98
  end
96
99
 
97
100
  it 'calculates the correct user hash' do
98
- expect(pdf.user_password_hash.unpack('H*').first)
101
+ expect(pdf.user_password_hash.unpack1('H*'))
99
102
  .to match(/^6BC8C51031/i)
100
103
  end
101
104
 
102
105
  it 'calculates the correct user_encryption_key' do
103
- expect(pdf.user_encryption_key.unpack('H*').first.upcase)
106
+ expect(pdf.user_encryption_key.unpack1('H*').upcase)
104
107
  .to eq('B100AB6429')
105
108
  end
106
109
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Prawn::Document do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Prawn::Document do