prawn 1.1.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (309) hide show
  1. checksums.yaml +5 -5
  2. checksums.yaml.gz.sig +0 -0
  3. data/.yardopts +1 -0
  4. data/GPLv2 +20 -21
  5. data/Gemfile +3 -9
  6. data/Rakefile +9 -40
  7. data/lib/prawn/document/bounding_box.rb +54 -40
  8. data/lib/prawn/document/column_box.rb +8 -10
  9. data/lib/prawn/document/internals.rb +39 -146
  10. data/lib/prawn/document/span.rb +23 -17
  11. data/lib/prawn/document.rb +217 -182
  12. data/lib/prawn/encoding.rb +69 -101
  13. data/lib/prawn/errors.rb +47 -43
  14. data/lib/prawn/font.rb +124 -104
  15. data/lib/prawn/font_metric_cache.rb +23 -21
  16. data/lib/prawn/fonts/afm.rb +292 -0
  17. data/lib/prawn/{font → fonts}/dfont.rb +5 -12
  18. data/lib/prawn/fonts/otf.rb +11 -0
  19. data/lib/prawn/fonts/ttc.rb +36 -0
  20. data/lib/prawn/{font → fonts}/ttf.rb +140 -88
  21. data/lib/prawn/graphics/blend_mode.rb +65 -0
  22. data/lib/prawn/graphics/cap_style.rb +5 -5
  23. data/lib/prawn/graphics/color.rb +46 -44
  24. data/lib/prawn/graphics/dash.rb +27 -11
  25. data/lib/prawn/graphics/join_style.rb +11 -6
  26. data/lib/prawn/graphics/patterns.rb +220 -78
  27. data/lib/prawn/graphics/transformation.rb +20 -12
  28. data/lib/prawn/graphics/transparency.rb +20 -18
  29. data/lib/prawn/graphics.rb +153 -115
  30. data/lib/prawn/grid.rb +93 -50
  31. data/lib/prawn/image_handler.rb +4 -4
  32. data/lib/prawn/images/image.rb +3 -2
  33. data/lib/prawn/images/jpg.rb +31 -24
  34. data/lib/prawn/images/png.rb +101 -68
  35. data/lib/prawn/images.rb +64 -56
  36. data/lib/prawn/measurement_extensions.rb +10 -9
  37. data/lib/prawn/measurements.rb +20 -23
  38. data/lib/prawn/outline.rb +96 -75
  39. data/lib/prawn/repeater.rb +16 -16
  40. data/lib/prawn/security/arcfour.rb +2 -2
  41. data/lib/prawn/security.rb +100 -85
  42. data/lib/prawn/soft_mask.rb +37 -38
  43. data/lib/prawn/stamp.rb +28 -13
  44. data/lib/prawn/text/box.rb +24 -29
  45. data/lib/prawn/text/formatted/arranger.rb +108 -63
  46. data/lib/prawn/text/formatted/box.rb +187 -124
  47. data/lib/prawn/text/formatted/fragment.rb +24 -20
  48. data/lib/prawn/text/formatted/line_wrap.rb +133 -73
  49. data/lib/prawn/text/formatted/parser.rb +147 -127
  50. data/lib/prawn/text/formatted/wrap.rb +48 -35
  51. data/lib/prawn/text/formatted.rb +5 -5
  52. data/lib/prawn/text.rb +103 -68
  53. data/lib/prawn/transformation_stack.rb +44 -0
  54. data/lib/prawn/utilities.rb +10 -22
  55. data/lib/prawn/version.rb +5 -0
  56. data/lib/prawn/view.rb +101 -0
  57. data/lib/prawn.rb +39 -54
  58. data/manual/basic_concepts/adding_pages.rb +6 -7
  59. data/manual/basic_concepts/basic_concepts.rb +34 -25
  60. data/manual/basic_concepts/creation.rb +10 -11
  61. data/manual/basic_concepts/cursor.rb +4 -5
  62. data/manual/basic_concepts/measurement.rb +8 -9
  63. data/manual/basic_concepts/origin.rb +5 -6
  64. data/manual/basic_concepts/other_cursor_helpers.rb +11 -12
  65. data/manual/basic_concepts/view.rb +48 -0
  66. data/manual/bounding_box/bounding_box.rb +30 -28
  67. data/manual/bounding_box/bounds.rb +12 -13
  68. data/manual/bounding_box/canvas.rb +7 -8
  69. data/manual/bounding_box/creation.rb +6 -7
  70. data/manual/bounding_box/indentation.rb +14 -15
  71. data/manual/bounding_box/nesting.rb +25 -18
  72. data/manual/bounding_box/russian_boxes.rb +18 -18
  73. data/manual/bounding_box/stretchy.rb +12 -14
  74. data/manual/contents.rb +28 -22
  75. data/manual/cover.rb +33 -32
  76. data/manual/document_and_page_options/background.rb +15 -13
  77. data/manual/document_and_page_options/document_and_page_options.rb +24 -22
  78. data/manual/document_and_page_options/metadata.rb +20 -18
  79. data/manual/document_and_page_options/page_margins.rb +18 -20
  80. data/manual/document_and_page_options/page_size.rb +13 -13
  81. data/manual/document_and_page_options/print_scaling.rb +18 -15
  82. data/manual/example_helper.rb +5 -4
  83. data/manual/graphics/blend_mode.rb +52 -0
  84. data/manual/graphics/circle_and_ellipse.rb +4 -5
  85. data/manual/graphics/color.rb +7 -9
  86. data/manual/graphics/common_lines.rb +7 -8
  87. data/manual/graphics/fill_and_stroke.rb +5 -6
  88. data/manual/graphics/fill_rules.rb +12 -11
  89. data/manual/graphics/gradients.rb +27 -21
  90. data/manual/graphics/graphics.rb +46 -40
  91. data/manual/graphics/helper.rb +19 -9
  92. data/manual/graphics/line_width.rb +8 -7
  93. data/manual/graphics/lines_and_curves.rb +8 -9
  94. data/manual/graphics/polygon.rb +6 -8
  95. data/manual/graphics/rectangle.rb +4 -5
  96. data/manual/graphics/rotate.rb +6 -9
  97. data/manual/graphics/scale.rb +14 -13
  98. data/manual/graphics/soft_masks.rb +4 -6
  99. data/manual/graphics/stroke_cap.rb +7 -8
  100. data/manual/graphics/stroke_dash.rb +15 -16
  101. data/manual/graphics/stroke_join.rb +6 -7
  102. data/manual/graphics/translate.rb +10 -10
  103. data/manual/graphics/transparency.rb +7 -9
  104. data/manual/how_to_read_this_manual.rb +8 -9
  105. data/manual/images/absolute_position.rb +6 -7
  106. data/manual/images/fit.rb +7 -8
  107. data/manual/images/horizontal.rb +10 -11
  108. data/manual/images/images.rb +28 -27
  109. data/manual/images/plain_image.rb +5 -6
  110. data/manual/images/scale.rb +9 -10
  111. data/manual/images/vertical.rb +16 -14
  112. data/manual/images/width_and_height.rb +10 -11
  113. data/manual/layout/boxes.rb +10 -11
  114. data/manual/layout/content.rb +9 -10
  115. data/manual/layout/layout.rb +17 -18
  116. data/manual/layout/simple_grid.rb +6 -7
  117. data/manual/outline/add_subsection_to.rb +20 -21
  118. data/manual/outline/insert_section_after.rb +15 -16
  119. data/manual/outline/outline.rb +22 -21
  120. data/manual/outline/sections_and_pages.rb +17 -18
  121. data/manual/repeatable_content/alternate_page_numbering.rb +36 -0
  122. data/manual/repeatable_content/page_numbering.rb +17 -16
  123. data/manual/repeatable_content/repeatable_content.rb +27 -23
  124. data/manual/repeatable_content/repeater.rb +15 -16
  125. data/manual/repeatable_content/stamp.rb +14 -15
  126. data/manual/security/encryption.rb +8 -11
  127. data/manual/security/permissions.rb +20 -15
  128. data/manual/security/security.rb +18 -18
  129. data/manual/table.rb +16 -0
  130. data/manual/text/alignment.rb +16 -17
  131. data/manual/text/color.rb +12 -12
  132. data/manual/text/column_box.rb +9 -11
  133. data/manual/text/fallback_fonts.rb +25 -21
  134. data/manual/text/font.rb +11 -12
  135. data/manual/text/font_size.rb +13 -14
  136. data/manual/text/font_style.rb +10 -8
  137. data/manual/text/formatted_callbacks.rb +33 -23
  138. data/manual/text/formatted_text.rb +36 -25
  139. data/manual/text/free_flowing_text.rb +22 -23
  140. data/manual/text/inline.rb +18 -19
  141. data/manual/text/kerning_and_character_spacing.rb +14 -15
  142. data/manual/text/leading.rb +7 -8
  143. data/manual/text/line_wrapping.rb +37 -18
  144. data/manual/text/paragraph_indentation.rb +15 -10
  145. data/manual/text/positioned_text.rb +16 -17
  146. data/manual/text/registering_families.rb +27 -24
  147. data/manual/text/rendering_and_color.rb +9 -10
  148. data/manual/text/right_to_left_text.rb +30 -19
  149. data/manual/text/rotation.rb +33 -24
  150. data/manual/text/single_usage.rb +8 -9
  151. data/manual/text/text.rb +56 -54
  152. data/manual/text/text_box_excess.rb +20 -17
  153. data/manual/text/text_box_extensions.rb +18 -15
  154. data/manual/text/text_box_overflow.rb +24 -17
  155. data/manual/text/utf8.rb +12 -13
  156. data/manual/text/win_ansi_charset.rb +28 -25
  157. data/prawn.gemspec +45 -50
  158. data/spec/extensions/encoding_helpers.rb +3 -3
  159. data/spec/prawn/document/bounding_box_spec.rb +550 -0
  160. data/spec/prawn/document/column_box_spec.rb +75 -0
  161. data/spec/prawn/document/security_spec.rb +176 -0
  162. data/spec/prawn/document_annotations_spec.rb +76 -0
  163. data/spec/prawn/document_destinations_spec.rb +15 -0
  164. data/spec/prawn/document_grid_spec.rb +99 -0
  165. data/spec/prawn/document_reference_spec.rb +27 -0
  166. data/spec/prawn/document_span_spec.rb +44 -0
  167. data/spec/prawn/document_spec.rb +805 -0
  168. data/spec/prawn/font_metric_cache_spec.rb +54 -0
  169. data/spec/prawn/font_spec.rb +544 -0
  170. data/spec/prawn/graphics/blend_mode_spec.rb +63 -0
  171. data/spec/prawn/graphics/transparency_spec.rb +81 -0
  172. data/spec/prawn/graphics_spec.rb +872 -0
  173. data/spec/prawn/graphics_stroke_styles_spec.rb +229 -0
  174. data/spec/prawn/image_handler_spec.rb +53 -0
  175. data/spec/prawn/images/jpg_spec.rb +20 -0
  176. data/spec/prawn/images/png_spec.rb +283 -0
  177. data/spec/prawn/images_spec.rb +229 -0
  178. data/spec/prawn/measurements_extensions_spec.rb +24 -0
  179. data/spec/prawn/outline_spec.rb +512 -0
  180. data/spec/prawn/repeater_spec.rb +166 -0
  181. data/spec/prawn/soft_mask_spec.rb +74 -0
  182. data/spec/prawn/stamp_spec.rb +173 -0
  183. data/spec/prawn/text/box_spec.rb +1110 -0
  184. data/spec/prawn/text/formatted/arranger_spec.rb +466 -0
  185. data/spec/prawn/text/formatted/box_spec.rb +849 -0
  186. data/spec/prawn/text/formatted/fragment_spec.rb +343 -0
  187. data/spec/prawn/text/formatted/line_wrap_spec.rb +495 -0
  188. data/spec/prawn/text/formatted/parser_spec.rb +697 -0
  189. data/spec/prawn/text_draw_text_spec.rb +150 -0
  190. data/spec/prawn/text_rendering_mode_spec.rb +48 -0
  191. data/spec/prawn/text_spacing_spec.rb +95 -0
  192. data/spec/prawn/text_spec.rb +603 -0
  193. data/spec/prawn/text_with_inline_formatting_spec.rb +35 -0
  194. data/spec/prawn/transformation_stack_spec.rb +66 -0
  195. data/spec/prawn/view_spec.rb +63 -0
  196. data/spec/prawn_manual_spec.rb +35 -0
  197. data/spec/spec_helper.rb +19 -25
  198. data.tar.gz.sig +0 -0
  199. metadata +113 -276
  200. metadata.gz.sig +0 -0
  201. data/data/encodings/win_ansi.txt +0 -29
  202. data/data/images/16bit.alpha +0 -0
  203. data/data/images/16bit.color +0 -0
  204. data/data/images/16bit.png +0 -0
  205. data/data/images/arrow.png +0 -0
  206. data/data/images/arrow2.png +0 -0
  207. data/data/images/dice.alpha +0 -0
  208. data/data/images/dice.color +0 -0
  209. data/data/images/dice.png +0 -0
  210. data/data/images/dice_interlaced.png +0 -0
  211. data/data/images/fractal.jpg +0 -0
  212. data/data/images/indexed_color.dat +0 -0
  213. data/data/images/indexed_color.png +0 -0
  214. data/data/images/letterhead.jpg +0 -0
  215. data/data/images/license.md +0 -8
  216. data/data/images/page_white_text.alpha +0 -0
  217. data/data/images/page_white_text.color +0 -0
  218. data/data/images/page_white_text.png +0 -0
  219. data/data/images/pigs.jpg +0 -0
  220. data/data/images/prawn.png +0 -0
  221. data/data/images/ruport.png +0 -0
  222. data/data/images/ruport_data.dat +0 -0
  223. data/data/images/ruport_transparent.png +0 -0
  224. data/data/images/ruport_type0.png +0 -0
  225. data/data/images/stef.jpg +0 -0
  226. data/data/images/tru256.bmp +0 -0
  227. data/data/images/web-links.dat +0 -1
  228. data/data/images/web-links.png +0 -0
  229. data/data/pdfs/complex_template.pdf +0 -0
  230. data/data/pdfs/contains_ttf_font.pdf +0 -0
  231. data/data/pdfs/encrypted.pdf +0 -0
  232. data/data/pdfs/form.pdf +1 -819
  233. data/data/pdfs/hexagon.pdf +0 -61
  234. data/data/pdfs/indirect_reference.pdf +0 -86
  235. data/data/pdfs/multipage_template.pdf +0 -127
  236. data/data/pdfs/nested_pages.pdf +0 -118
  237. data/data/pdfs/page_without_mediabox.pdf +0 -193
  238. data/data/pdfs/resources_as_indirect_object.pdf +0 -83
  239. data/data/pdfs/two_hexagons.pdf +0 -90
  240. data/data/pdfs/version_1_6.pdf +0 -61
  241. data/data/shift_jis_text.txt +0 -1
  242. data/lib/prawn/document/graphics_state.rb +0 -73
  243. data/lib/prawn/font/afm.rb +0 -247
  244. data/lib/prawn/table/cell/image.rb +0 -69
  245. data/lib/prawn/table/cell/in_table.rb +0 -33
  246. data/lib/prawn/table/cell/span_dummy.rb +0 -93
  247. data/lib/prawn/table/cell/subtable.rb +0 -66
  248. data/lib/prawn/table/cell/text.rb +0 -154
  249. data/lib/prawn/table/cell.rb +0 -772
  250. data/lib/prawn/table/cells.rb +0 -255
  251. data/lib/prawn/table/column_width_calculator.rb +0 -182
  252. data/lib/prawn/table.rb +0 -644
  253. data/manual/table/basic_block.rb +0 -53
  254. data/manual/table/before_rendering_page.rb +0 -26
  255. data/manual/table/cell_border_lines.rb +0 -24
  256. data/manual/table/cell_borders_and_bg.rb +0 -31
  257. data/manual/table/cell_dimensions.rb +0 -30
  258. data/manual/table/cell_text.rb +0 -38
  259. data/manual/table/column_widths.rb +0 -30
  260. data/manual/table/content_and_subtables.rb +0 -39
  261. data/manual/table/creation.rb +0 -27
  262. data/manual/table/filtering.rb +0 -36
  263. data/manual/table/flow_and_header.rb +0 -17
  264. data/manual/table/image_cells.rb +0 -33
  265. data/manual/table/position.rb +0 -29
  266. data/manual/table/row_colors.rb +0 -20
  267. data/manual/table/span.rb +0 -30
  268. data/manual/table/style.rb +0 -22
  269. data/manual/table/table.rb +0 -52
  270. data/manual/table/width.rb +0 -27
  271. data/spec/acceptance/png.rb +0 -25
  272. data/spec/annotations_spec.rb +0 -74
  273. data/spec/bounding_box_spec.rb +0 -510
  274. data/spec/cell_spec.rb +0 -629
  275. data/spec/column_box_spec.rb +0 -65
  276. data/spec/destinations_spec.rb +0 -15
  277. data/spec/document_spec.rb +0 -730
  278. data/spec/extensions/mocha.rb +0 -46
  279. data/spec/font_metric_cache_spec.rb +0 -52
  280. data/spec/font_spec.rb +0 -449
  281. data/spec/formatted_text_arranger_spec.rb +0 -421
  282. data/spec/formatted_text_box_spec.rb +0 -639
  283. data/spec/formatted_text_fragment_spec.rb +0 -298
  284. data/spec/graphics_spec.rb +0 -669
  285. data/spec/grid_spec.rb +0 -96
  286. data/spec/image_handler_spec.rb +0 -54
  287. data/spec/images_spec.rb +0 -153
  288. data/spec/inline_formatted_text_parser_spec.rb +0 -564
  289. data/spec/jpg_spec.rb +0 -25
  290. data/spec/line_wrap_spec.rb +0 -344
  291. data/spec/measurement_units_spec.rb +0 -25
  292. data/spec/outline_spec.rb +0 -430
  293. data/spec/png_spec.rb +0 -237
  294. data/spec/reference_spec.rb +0 -25
  295. data/spec/repeater_spec.rb +0 -160
  296. data/spec/security_spec.rb +0 -158
  297. data/spec/soft_mask_spec.rb +0 -79
  298. data/spec/span_spec.rb +0 -44
  299. data/spec/stamp_spec.rb +0 -160
  300. data/spec/stroke_styles_spec.rb +0 -211
  301. data/spec/table/span_dummy_spec.rb +0 -17
  302. data/spec/table_spec.rb +0 -1527
  303. data/spec/text_at_spec.rb +0 -115
  304. data/spec/text_box_spec.rb +0 -1034
  305. data/spec/text_rendering_mode_spec.rb +0 -45
  306. data/spec/text_spacing_spec.rb +0 -93
  307. data/spec/text_spec.rb +0 -437
  308. data/spec/text_with_inline_formatting_spec.rb +0 -35
  309. data/spec/transparency_spec.rb +0 -91
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 8492b319da06bf93faa4e58cfa4932b46fd8a474
4
- data.tar.gz: ba94547a9eda37f13c91b7293203a12df99b9815
2
+ SHA256:
3
+ metadata.gz: d64c2da1e4be48e40f4fa6fa4de35e04c75debf0119e8c59b3fba9d944c112db
4
+ data.tar.gz: 393bbdd1a5df657d5c6190d4bd10ecd7353522e714b2f60c8d9c5f70e5bc1ce9
5
5
  SHA512:
6
- metadata.gz: d898304c9f63ac7826f49b3802106ec84e36fb8a0efcb07d85b2b88d0e7a2f3016f722655fea9e4992e028a8a740ef5d29a5ee9e7287164f6768d9435179891c
7
- data.tar.gz: 0127f4e217c2588fe196665712cb1fe7e3914a49d3ba4e0b248e1a7bd3615f52e6c97e2288c4c7fb9295383e48c03ad48557c137e8d1f822841c65d1a8f77d62
6
+ metadata.gz: c4980639ca24796d577be790ed0f6fa85c985f1a6eb147e4c5db1df261c5d50afe8a466f06b65588b71a897e22e8d2b7b01daceed1714f6164124057154d2d28
7
+ data.tar.gz: e0fd560d4a80f2827736d599266bcb2e2fe19abedcde639520fba8bd19a2f12fe2cf0e8a60a91b87dbac4336d25c680f94b2341e5f9ce3d6d24f2e65f24e24a3
checksums.yaml.gz.sig ADDED
Binary file
data/.yardopts CHANGED
@@ -7,3 +7,4 @@ CONTRIBUTING.md
7
7
  COPYING
8
8
  LICENSE
9
9
  README.md
10
+ CHANGELOG.md
data/GPLv2 CHANGED
@@ -1,12 +1,12 @@
1
- GNU GENERAL PUBLIC LICENSE
2
- Version 2, June 1991
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
3
 
4
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
6
  Everyone is permitted to copy and distribute verbatim copies
7
7
  of this license document, but changing it is not allowed.
8
8
 
9
- Preamble
9
+ Preamble
10
10
 
11
11
  The licenses for most software are designed to take away your
12
12
  freedom to share and change it. By contrast, the GNU General Public
@@ -15,7 +15,7 @@ software--to make sure the software is free for all its users. This
15
15
  General Public License applies to most of the Free Software
16
16
  Foundation's software and to any other program whose authors commit to
17
17
  using it. (Some other Free Software Foundation software is covered by
18
- the GNU Library General Public License instead.) You can apply it to
18
+ the GNU Lesser General Public License instead.) You can apply it to
19
19
  your programs, too.
20
20
 
21
21
  When we speak of free software, we are referring to freedom, not
@@ -55,8 +55,8 @@ patent must be licensed for everyone's free use or not licensed at all.
55
55
 
56
56
  The precise terms and conditions for copying, distribution and
57
57
  modification follow.
58
-
59
- GNU GENERAL PUBLIC LICENSE
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
60
  TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
61
 
62
62
  0. This License applies to any program or other work which contains
@@ -110,7 +110,7 @@ above, provided that you also meet all of these conditions:
110
110
  License. (Exception: if the Program itself is interactive but
111
111
  does not normally print such an announcement, your work based on
112
112
  the Program is not required to print an announcement.)
113
-
113
+
114
114
  These requirements apply to the modified work as a whole. If
115
115
  identifiable sections of that work are not derived from the Program,
116
116
  and can be reasonably considered independent and separate works in
@@ -168,7 +168,7 @@ access to copy from a designated place, then offering equivalent
168
168
  access to copy the source code from the same place counts as
169
169
  distribution of the source code, even though third parties are not
170
170
  compelled to copy the source along with the object code.
171
-
171
+
172
172
  4. You may not copy, modify, sublicense, or distribute the Program
173
173
  except as expressly provided under this License. Any attempt
174
174
  otherwise to copy, modify, sublicense or distribute the Program is
@@ -225,7 +225,7 @@ impose that choice.
225
225
 
226
226
  This section is intended to make thoroughly clear what is believed to
227
227
  be a consequence of the rest of this License.
228
-
228
+
229
229
  8. If the distribution and/or use of the Program is restricted in
230
230
  certain countries either by patents or by copyrighted interfaces, the
231
231
  original copyright holder who places the Program under this License
@@ -255,7 +255,7 @@ make exceptions for this. Our decision will be guided by the two goals
255
255
  of preserving the free status of all derivatives of our free software and
256
256
  of promoting the sharing and reuse of software generally.
257
257
 
258
- NO WARRANTY
258
+ NO WARRANTY
259
259
 
260
260
  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
261
  FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
@@ -277,9 +277,9 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
277
  PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
278
  POSSIBILITY OF SUCH DAMAGES.
279
279
 
280
- END OF TERMS AND CONDITIONS
281
-
282
- How to Apply These Terms to Your New Programs
280
+ END OF TERMS AND CONDITIONS
281
+
282
+ How to Apply These Terms to Your New Programs
283
283
 
284
284
  If you develop a new program, and you want it to be of the greatest
285
285
  possible use to the public, the best way to achieve this is to make it
@@ -303,17 +303,16 @@ the "copyright" line and a pointer to where the full notice is found.
303
303
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304
304
  GNU General Public License for more details.
305
305
 
306
- You should have received a copy of the GNU General Public License
307
- along with this program; if not, write to the Free Software
308
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
309
-
306
+ You should have received a copy of the GNU General Public License along
307
+ with this program; if not, write to the Free Software Foundation, Inc.,
308
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
310
309
 
311
310
  Also add information on how to contact you by electronic and paper mail.
312
311
 
313
312
  If the program is interactive, make it output a short notice like this
314
313
  when it starts in an interactive mode:
315
314
 
316
- Gnomovision version 69, Copyright (C) year name of author
315
+ Gnomovision version 69, Copyright (C) year name of author
317
316
  Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
318
317
  This is free software, and you are welcome to redistribute it
319
318
  under certain conditions; type `show c' for details.
@@ -336,5 +335,5 @@ necessary. Here is a sample; alter the names:
336
335
  This General Public License does not permit incorporating your program into
337
336
  proprietary programs. If your program is a subroutine library, you may
338
337
  consider it more useful to permit linking proprietary applications with the
339
- library. If this is what you want to do, use the GNU Library General
338
+ library. If this is what you want to do, use the GNU Lesser General
340
339
  Public License instead of this License.
data/Gemfile CHANGED
@@ -1,11 +1,5 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
2
 
3
- gemspec
3
+ source 'https://rubygems.org'
4
4
 
5
- if ENV["CI"]
6
- platforms :rbx do
7
- gem "rubysl-singleton", "~> 2.0"
8
- gem "rubysl-digest", "~> 2.0"
9
- gem "rubysl-enumerator", "~> 2.0"
10
- end
11
- end
5
+ gemspec
data/Rakefile CHANGED
@@ -1,48 +1,19 @@
1
- require "bundler"
2
- Bundler.setup
1
+ # frozen_string_literal: true
3
2
 
4
- require 'rake'
5
- require 'rspec/core/rake_task'
6
- require 'yard'
7
- require 'rubygems/package_task'
8
- require 'rubocop/rake_task'
9
-
10
- task :default => [:rubocop, :spec]
11
-
12
- desc "Run all rspec files"
13
- RSpec::Core::RakeTask.new("spec") do |c|
14
- c.rspec_opts = "-t ~unresolved"
15
- end
16
-
17
- desc "Show library's code statistics"
18
- task :stats do
19
- require 'code_statistics'
20
- CodeStatistics::TEST_TYPES << "Specs"
21
- CodeStatistics.new( ["Prawn", "lib"],
22
- ["Specs", "spec"] ).to_s
23
- end
24
-
25
- YARD::Rake::YardocTask.new do |t|
26
- t.options = ['--output-dir', 'doc/html']
27
- end
28
- task :docs => :yard
3
+ GEMSPEC = File.expand_path('prawn.gemspec', __dir__)
4
+ require 'prawn/dev/tasks'
29
5
 
6
+ task default: %i[spec rubocop]
30
7
 
31
8
  desc "Generate the 'Prawn by Example' manual"
32
9
  task :manual do
33
- puts "Building manual..."
34
- require File.expand_path(File.join(File.dirname(__FILE__),
35
- %w[manual contents]))
36
- puts "The Prawn manual is available at manual.pdf. Happy Prawning!"
10
+ puts 'Building manual...'
11
+ require File.expand_path(File.join(__dir__, %w[manual contents]))
12
+ prawn_manual_document.render_file('manual.pdf')
13
+ puts 'The Prawn manual is available at manual.pdf. Happy Prawning!'
37
14
  end
38
15
 
39
- spec = Gem::Specification.load "prawn.gemspec"
40
- Gem::PackageTask.new(spec) do |pkg|
41
- pkg.need_zip = true
42
- pkg.need_tar = true
43
- end
44
-
45
- desc "Run a console with Prawn loaded"
16
+ desc 'Run a console with Prawn loaded'
46
17
  task :console do
47
18
  require 'irb'
48
19
  require 'irb/completion'
@@ -52,5 +23,3 @@ task :console do
52
23
  ARGV.clear
53
24
  IRB.start
54
25
  end
55
-
56
- Rubocop::RakeTask.new
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  # bounding_box.rb : Implements a mechanism for shifting the coordinate space
4
4
  #
@@ -155,10 +155,10 @@ module Prawn
155
155
  # Of course, if you use canvas, you will be responsible for ensuring that
156
156
  # you remain within the printable area of your document.
157
157
  #
158
- def bounding_box(pt, *args, &block)
158
+ def bounding_box(point, *args, &block)
159
159
  init_bounding_box(block) do |parent_box|
160
- pt = map_to_absolute(pt)
161
- @bounding_box = BoundingBox.new(self, parent_box, pt, *args)
160
+ point = map_to_absolute(point)
161
+ @bounding_box = BoundingBox.new(self, parent_box, point, *args)
162
162
  end
163
163
  end
164
164
 
@@ -170,28 +170,31 @@ module Prawn
170
170
  # end
171
171
  #
172
172
  def canvas(&block)
173
- init_bounding_box(block, :hold_position => true) do |_|
173
+ init_bounding_box(block, hold_position: true) do |_|
174
174
  # Canvas bbox acts like margin_box in that its parent bounds are unset.
175
- @bounding_box = BoundingBox.new(self, nil, [0,page.dimensions[3]],
176
- :width => page.dimensions[2],
177
- :height => page.dimensions[3]
175
+ @bounding_box = BoundingBox.new(
176
+ self,
177
+ nil,
178
+ [0, page.dimensions[3]],
179
+ width: page.dimensions[2],
180
+ height: page.dimensions[3]
178
181
  )
179
182
  end
180
183
  end
181
184
 
182
185
  private
183
186
 
184
- def init_bounding_box(user_block, options={}, &init_block)
187
+ def init_bounding_box(user_block, options = {})
185
188
  unless user_block
186
189
  raise ArgumentError,
187
- "bounding boxes require a block to be drawn within the box"
190
+ 'bounding boxes require a block to be drawn within the box'
188
191
  end
189
192
 
190
193
  parent_box = @bounding_box
191
194
 
192
195
  original_ypos = y
193
196
 
194
- init_block.call(parent_box)
197
+ yield(parent_box)
195
198
 
196
199
  self.y = @bounding_box.absolute_top
197
200
  user_block.call
@@ -208,9 +211,10 @@ module Prawn
208
211
  self.y = @bounding_box.absolute_bottom
209
212
  end
210
213
 
211
- created_box, @bounding_box = @bounding_box, parent_box
214
+ created_box = @bounding_box
215
+ @bounding_box = parent_box
212
216
 
213
- return created_box
217
+ created_box
214
218
  end
215
219
 
216
220
  # Low level layout helper that simplifies coordinate math.
@@ -219,16 +223,23 @@ module Prawn
219
223
  # is used for.
220
224
  #
221
225
  class BoundingBox
226
+ class NoReferenceBounds < StandardError
227
+ def initialize(message = "Can't find reference bounds: my parent is unset")
228
+ super
229
+ end
230
+ end
222
231
 
223
- def initialize(document, parent, point, options={}) # @private
232
+ # @private
233
+ def initialize(document, parent, point, options = {})
224
234
  unless options[:width]
225
- raise ArgumentError, "BoundingBox needs the :width option to be set"
235
+ raise ArgumentError, 'BoundingBox needs the :width option to be set'
226
236
  end
227
237
 
228
238
  @document = document
229
239
  @parent = parent
230
240
  @x, @y = point
231
- @width, @height = options[:width], options[:height]
241
+ @width = options[:width]
242
+ @height = options[:height]
232
243
  @total_left_padding = 0
233
244
  @total_right_padding = 0
234
245
  @stretched_height = nil
@@ -264,7 +275,6 @@ module Prawn
264
275
  0
265
276
  end
266
277
 
267
-
268
278
  # Temporarily adjust the @x coordinate to allow for left_padding
269
279
  #
270
280
  # Example:
@@ -281,7 +291,7 @@ module Prawn
281
291
  # end
282
292
  #
283
293
  # @private
284
- def indent(left_padding, right_padding = 0, &block)
294
+ def indent(left_padding, right_padding = 0)
285
295
  add_left_padding(left_padding)
286
296
  add_right_padding(right_padding)
287
297
  yield
@@ -320,7 +330,8 @@ module Prawn
320
330
  @width += right_padding
321
331
  end
322
332
 
323
- # Relative right x-coordinate of the bounding box. (Equal to the box width)
333
+ # Relative right x-coordinate of the bounding box. (Equal to the box
334
+ # width)
324
335
  #
325
336
  # Example, position some text 3 pts from the right of the containing box:
326
337
  #
@@ -360,7 +371,7 @@ module Prawn
360
371
  # end
361
372
  #
362
373
  def top_left
363
- [left,top]
374
+ [left, top]
364
375
  end
365
376
 
366
377
  # Relative top-right point of the bounding box
@@ -373,7 +384,7 @@ module Prawn
373
384
  # end
374
385
  #
375
386
  def top_right
376
- [right,top]
387
+ [right, top]
377
388
  end
378
389
 
379
390
  # Relative bottom-right point of the bounding box
@@ -385,7 +396,7 @@ module Prawn
385
396
  # end
386
397
  #
387
398
  def bottom_right
388
- [right,bottom]
399
+ [right, bottom]
389
400
  end
390
401
 
391
402
  # Relative bottom-left point of the bounding box
@@ -397,7 +408,7 @@ module Prawn
397
408
  # end
398
409
  #
399
410
  def bottom_left
400
- [left,bottom]
411
+ [left, bottom]
401
412
  end
402
413
 
403
414
  # Absolute left x-coordinate of the bounding box
@@ -449,10 +460,7 @@ module Prawn
449
460
  end
450
461
 
451
462
  # Width of the bounding box
452
- #
453
- def width
454
- @width
455
- end
463
+ attr_reader :width
456
464
 
457
465
  # Height of the bounding box. If the box is 'stretchy' (unspecified
458
466
  # height attribute), height is calculated as the distance from the top of
@@ -460,8 +468,11 @@ module Prawn
460
468
  #
461
469
  def height
462
470
  return @height if @height
463
- @stretched_height = [(absolute_top - @document.y),
464
- @stretched_height.to_f].max
471
+
472
+ @stretched_height = [
473
+ (absolute_top - @document.y),
474
+ @stretched_height.to_f
475
+ ].max
465
476
  end
466
477
 
467
478
  # an alias for absolute_left
@@ -489,8 +500,9 @@ module Prawn
489
500
  end
490
501
  end
491
502
 
492
- # Returns +false+ when the box has a defined height, +true+ when the height
493
- # is being calculated on the fly based on the current vertical position.
503
+ # Returns +false+ when the box has a defined height, +true+ when the
504
+ # height is being calculated on the fly based on the current vertical
505
+ # position.
494
506
  #
495
507
  def stretchy?
496
508
  !@height
@@ -500,14 +512,15 @@ module Prawn
500
512
  #
501
513
  def reference_bounds
502
514
  if stretchy?
503
- raise "Can't find reference bounds: my parent is unset" unless @parent
515
+ raise NoReferenceBounds unless @parent
516
+
504
517
  @parent.reference_bounds
505
518
  else
506
519
  self
507
520
  end
508
521
  end
509
522
 
510
- alias_method :update_height, :height
523
+ alias update_height height
511
524
 
512
525
  # Returns a deep copy of these bounds (including all parent bounds but
513
526
  # not copying the reference to the Document).
@@ -516,10 +529,13 @@ module Prawn
516
529
  def deep_copy
517
530
  copy = dup
518
531
  # Deep-copy the parent bounds
519
- copy.instance_variable_set("@parent", if BoundingBox === @parent
520
- @parent.deep_copy
521
- end)
522
- copy.instance_variable_set("@document", nil)
532
+ copy.instance_variable_set(
533
+ '@parent',
534
+ if @parent.is_a?(BoundingBox)
535
+ @parent.deep_copy
536
+ end
537
+ )
538
+ copy.instance_variable_set('@document', nil)
523
539
  copy
524
540
  end
525
541
 
@@ -529,11 +545,9 @@ module Prawn
529
545
  #
530
546
  # @private
531
547
  def self.restore_deep_copy(bounds, document)
532
- bounds.instance_variable_set("@document", document)
548
+ bounds.instance_variable_set('@document', document)
533
549
  bounds
534
550
  end
535
-
536
551
  end
537
-
538
552
  end
539
553
  end
@@ -1,16 +1,15 @@
1
- # encoding: utf-8
2
- #
1
+ # frozen_string_literal: true
2
+
3
3
  # column_box.rb: Extends BoundingBox to allow for columns of text
4
4
  #
5
5
  # Author Paul Ostazeski.
6
6
  #
7
7
  # This is free software. Please see the LICENSE and COPYING files for details.
8
8
 
9
- require_relative "bounding_box"
9
+ require_relative 'bounding_box'
10
10
 
11
11
  module Prawn
12
12
  class Document
13
-
14
13
  # @group Experimental API
15
14
 
16
15
  # A column box is a bounding box with the additional property that when
@@ -37,10 +36,10 @@ module Prawn
37
36
 
38
37
  private
39
38
 
40
- def init_column_box(user_block, options={}, &init_block)
39
+ def init_column_box(user_block, options = {})
41
40
  parent_box = @bounding_box
42
41
 
43
- init_block.call(parent_box)
42
+ yield(parent_box)
44
43
 
45
44
  self.y = @bounding_box.absolute_top
46
45
  user_block.call
@@ -53,11 +52,10 @@ module Prawn
53
52
  # work.
54
53
  #
55
54
  class ColumnBox < BoundingBox
56
-
57
- def initialize(document, parent, point, options={}) #:nodoc:
55
+ def initialize(document, parent, point, options = {}) #:nodoc:
58
56
  super
59
57
  @columns = options[:columns] || 3
60
- @spacer = options[:spacer] || @document.font_size
58
+ @spacer = options[:spacer] || @document.font_size
61
59
  @current_column = 0
62
60
  @reflow_margins = options[:reflow_margins]
63
61
  end
@@ -111,7 +109,7 @@ module Prawn
111
109
  def move_past_bottom
112
110
  @current_column = (@current_column + 1) % @columns
113
111
  @document.y = @y
114
- if 0 == @current_column
112
+ if @current_column.zero?
115
113
  if @reflow_margins
116
114
  @y = @parent.absolute_top
117
115
  end