prawn 0.15.0 → 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (269) hide show
  1. data/COPYING +2 -2
  2. data/LICENSE +1 -1
  3. data/README.md +96 -0
  4. data/Rakefile +27 -30
  5. data/data/fonts/Action Man.dfont +0 -0
  6. data/data/fonts/Activa.ttf +0 -0
  7. data/data/fonts/Chalkboard.ttf +0 -0
  8. data/data/fonts/DejaVuSans.ttf +0 -0
  9. data/data/fonts/Dustismo_Roman.ttf +0 -0
  10. data/data/fonts/comicsans.ttf +0 -0
  11. data/data/fonts/gkai00mp.ttf +0 -0
  12. data/data/images/16bit.alpha +0 -0
  13. data/data/images/16bit.dat +0 -0
  14. data/data/images/dice.alpha +0 -0
  15. data/data/images/dice.dat +0 -0
  16. data/data/images/page_white_text.alpha +0 -0
  17. data/data/images/page_white_text.dat +0 -0
  18. data/data/images/rails.dat +0 -0
  19. data/data/images/rails.png +0 -0
  20. data/data/pdfs/nested_pages.pdf +13 -13
  21. data/lib/prawn.rb +21 -85
  22. data/lib/prawn/compatibility.rb +51 -0
  23. data/lib/prawn/core.rb +85 -0
  24. data/lib/prawn/core/annotations.rb +61 -0
  25. data/lib/prawn/core/byte_string.rb +9 -0
  26. data/lib/prawn/core/destinations.rb +90 -0
  27. data/lib/prawn/core/document_state.rb +78 -0
  28. data/lib/prawn/core/literal_string.rb +16 -0
  29. data/lib/prawn/core/name_tree.rb +177 -0
  30. data/lib/prawn/core/object_store.rb +264 -0
  31. data/lib/prawn/core/page.rb +215 -0
  32. data/lib/prawn/core/pdf_object.rb +108 -0
  33. data/lib/prawn/core/reference.rb +115 -0
  34. data/lib/prawn/core/text.rb +268 -0
  35. data/lib/prawn/core/text/formatted/arranger.rb +294 -0
  36. data/lib/prawn/core/text/formatted/line_wrap.rb +273 -0
  37. data/lib/prawn/core/text/formatted/wrap.rb +153 -0
  38. data/lib/prawn/document.rb +122 -155
  39. data/lib/prawn/document/bounding_box.rb +7 -36
  40. data/lib/prawn/document/column_box.rb +10 -38
  41. data/lib/prawn/document/graphics_state.rb +74 -11
  42. data/lib/prawn/document/internals.rb +23 -24
  43. data/lib/prawn/document/page_geometry.rb +136 -0
  44. data/lib/prawn/document/snapshot.rb +6 -7
  45. data/lib/prawn/document/span.rb +10 -12
  46. data/lib/prawn/encoding.rb +10 -9
  47. data/lib/prawn/errors.rb +30 -15
  48. data/lib/prawn/font.rb +104 -136
  49. data/lib/prawn/font/afm.rb +44 -46
  50. data/lib/prawn/font/dfont.rb +3 -4
  51. data/lib/prawn/font/ttf.rb +50 -31
  52. data/lib/prawn/graphics.rb +57 -302
  53. data/lib/prawn/graphics/cap_style.rb +3 -4
  54. data/lib/prawn/graphics/color.rb +5 -13
  55. data/lib/prawn/graphics/dash.rb +31 -53
  56. data/lib/prawn/graphics/gradient.rb +84 -0
  57. data/lib/prawn/graphics/join_style.rb +7 -9
  58. data/lib/prawn/graphics/transformation.rb +9 -10
  59. data/lib/prawn/graphics/transparency.rb +1 -3
  60. data/lib/prawn/images.rb +59 -69
  61. data/lib/prawn/images/image.rb +22 -6
  62. data/lib/prawn/images/jpg.rb +14 -20
  63. data/lib/prawn/images/png.rb +118 -61
  64. data/lib/prawn/layout.rb +15 -10
  65. data/lib/prawn/layout/grid.rb +54 -66
  66. data/lib/prawn/measurement_extensions.rb +6 -10
  67. data/lib/prawn/measurements.rb +21 -27
  68. data/lib/prawn/outline.rb +308 -6
  69. data/lib/prawn/repeater.rb +8 -10
  70. data/lib/prawn/security.rb +33 -55
  71. data/lib/prawn/security/arcfour.rb +0 -1
  72. data/lib/prawn/stamp.rb +3 -5
  73. data/lib/prawn/table.rb +60 -188
  74. data/lib/prawn/table/cell.rb +44 -272
  75. data/lib/prawn/table/cell/image.rb +3 -2
  76. data/lib/prawn/table/cell/in_table.rb +2 -4
  77. data/lib/prawn/table/cell/subtable.rb +2 -2
  78. data/lib/prawn/table/cell/text.rb +18 -41
  79. data/lib/prawn/table/cells.rb +48 -142
  80. data/lib/prawn/text.rb +25 -32
  81. data/lib/prawn/text/box.rb +6 -12
  82. data/lib/prawn/text/formatted.rb +4 -5
  83. data/lib/prawn/text/formatted/box.rb +59 -96
  84. data/lib/prawn/text/formatted/fragment.rb +23 -34
  85. data/lib/prawn/text/formatted/parser.rb +5 -15
  86. data/prawn.gemspec +13 -24
  87. data/spec/annotations_spec.rb +32 -16
  88. data/spec/bounding_box_spec.rb +17 -119
  89. data/spec/cell_spec.rb +42 -112
  90. data/spec/destinations_spec.rb +5 -5
  91. data/spec/document_spec.rb +111 -155
  92. data/spec/extensions/mocha.rb +0 -1
  93. data/spec/font_spec.rb +99 -149
  94. data/spec/formatted_text_arranger_spec.rb +43 -43
  95. data/spec/formatted_text_box_spec.rb +44 -43
  96. data/spec/formatted_text_fragment_spec.rb +8 -8
  97. data/spec/graphics_spec.rb +68 -151
  98. data/spec/grid_spec.rb +15 -26
  99. data/spec/images_spec.rb +30 -51
  100. data/spec/inline_formatted_text_parser_spec.rb +20 -69
  101. data/spec/jpg_spec.rb +4 -4
  102. data/spec/line_wrap_spec.rb +28 -28
  103. data/spec/measurement_units_spec.rb +6 -6
  104. data/spec/name_tree_spec.rb +112 -0
  105. data/spec/object_store_spec.rb +106 -17
  106. data/spec/outline_spec.rb +63 -103
  107. data/spec/pdf_object_spec.rb +170 -0
  108. data/spec/png_spec.rb +25 -25
  109. data/spec/reference_spec.rb +65 -8
  110. data/spec/repeater_spec.rb +10 -10
  111. data/spec/security_spec.rb +12 -44
  112. data/spec/snapshot_spec.rb +7 -7
  113. data/spec/span_spec.rb +15 -10
  114. data/spec/spec_helper.rb +8 -32
  115. data/spec/stamp_spec.rb +30 -29
  116. data/spec/stroke_styles_spec.rb +18 -36
  117. data/spec/table_spec.rb +111 -706
  118. data/spec/template_spec.rb +297 -0
  119. data/spec/text_at_spec.rb +33 -19
  120. data/spec/text_box_spec.rb +64 -100
  121. data/spec/text_rendering_mode_spec.rb +5 -5
  122. data/spec/text_spacing_spec.rb +4 -4
  123. data/spec/text_spec.rb +64 -84
  124. data/spec/transparency_spec.rb +5 -5
  125. metadata +290 -463
  126. checksums.yaml +0 -7
  127. data/.yardopts +0 -10
  128. data/Gemfile +0 -11
  129. data/data/images/16bit.color +0 -0
  130. data/data/images/dice.color +0 -0
  131. data/data/images/indexed_color.dat +0 -0
  132. data/data/images/indexed_color.png +0 -0
  133. data/data/images/page_white_text.color +0 -0
  134. data/lib/prawn/font_metric_cache.rb +0 -47
  135. data/lib/prawn/graphics/patterns.rb +0 -138
  136. data/lib/prawn/image_handler.rb +0 -36
  137. data/lib/prawn/soft_mask.rb +0 -96
  138. data/lib/prawn/table/cell/span_dummy.rb +0 -93
  139. data/lib/prawn/table/column_width_calculator.rb +0 -61
  140. data/lib/prawn/text/formatted/arranger.rb +0 -290
  141. data/lib/prawn/text/formatted/line_wrap.rb +0 -266
  142. data/lib/prawn/text/formatted/wrap.rb +0 -150
  143. data/lib/prawn/utilities.rb +0 -46
  144. data/manual/basic_concepts/adding_pages.rb +0 -27
  145. data/manual/basic_concepts/basic_concepts.rb +0 -34
  146. data/manual/basic_concepts/creation.rb +0 -39
  147. data/manual/basic_concepts/cursor.rb +0 -33
  148. data/manual/basic_concepts/measurement.rb +0 -25
  149. data/manual/basic_concepts/origin.rb +0 -38
  150. data/manual/basic_concepts/other_cursor_helpers.rb +0 -40
  151. data/manual/bounding_box/bounding_box.rb +0 -39
  152. data/manual/bounding_box/bounds.rb +0 -49
  153. data/manual/bounding_box/canvas.rb +0 -24
  154. data/manual/bounding_box/creation.rb +0 -23
  155. data/manual/bounding_box/indentation.rb +0 -46
  156. data/manual/bounding_box/nesting.rb +0 -45
  157. data/manual/bounding_box/russian_boxes.rb +0 -40
  158. data/manual/bounding_box/stretchy.rb +0 -31
  159. data/manual/document_and_page_options/background.rb +0 -27
  160. data/manual/document_and_page_options/document_and_page_options.rb +0 -32
  161. data/manual/document_and_page_options/metadata.rb +0 -23
  162. data/manual/document_and_page_options/page_margins.rb +0 -38
  163. data/manual/document_and_page_options/page_size.rb +0 -34
  164. data/manual/document_and_page_options/print_scaling.rb +0 -20
  165. data/manual/example_file.rb +0 -111
  166. data/manual/example_helper.rb +0 -411
  167. data/manual/example_package.rb +0 -53
  168. data/manual/example_section.rb +0 -46
  169. data/manual/graphics/circle_and_ellipse.rb +0 -22
  170. data/manual/graphics/color.rb +0 -24
  171. data/manual/graphics/common_lines.rb +0 -30
  172. data/manual/graphics/fill_and_stroke.rb +0 -42
  173. data/manual/graphics/fill_rules.rb +0 -37
  174. data/manual/graphics/gradients.rb +0 -37
  175. data/manual/graphics/graphics.rb +0 -58
  176. data/manual/graphics/helper.rb +0 -24
  177. data/manual/graphics/line_width.rb +0 -35
  178. data/manual/graphics/lines_and_curves.rb +0 -41
  179. data/manual/graphics/polygon.rb +0 -29
  180. data/manual/graphics/rectangle.rb +0 -21
  181. data/manual/graphics/rotate.rb +0 -28
  182. data/manual/graphics/scale.rb +0 -41
  183. data/manual/graphics/soft_masks.rb +0 -46
  184. data/manual/graphics/stroke_cap.rb +0 -31
  185. data/manual/graphics/stroke_dash.rb +0 -48
  186. data/manual/graphics/stroke_join.rb +0 -30
  187. data/manual/graphics/translate.rb +0 -29
  188. data/manual/graphics/transparency.rb +0 -35
  189. data/manual/images/absolute_position.rb +0 -23
  190. data/manual/images/fit.rb +0 -21
  191. data/manual/images/horizontal.rb +0 -25
  192. data/manual/images/images.rb +0 -40
  193. data/manual/images/plain_image.rb +0 -18
  194. data/manual/images/scale.rb +0 -22
  195. data/manual/images/vertical.rb +0 -28
  196. data/manual/images/width_and_height.rb +0 -25
  197. data/manual/layout/boxes.rb +0 -27
  198. data/manual/layout/content.rb +0 -25
  199. data/manual/layout/layout.rb +0 -28
  200. data/manual/layout/simple_grid.rb +0 -23
  201. data/manual/manual/cover.rb +0 -36
  202. data/manual/manual/foreword.rb +0 -85
  203. data/manual/manual/how_to_read_this_manual.rb +0 -41
  204. data/manual/manual/manual.rb +0 -34
  205. data/manual/outline/add_subsection_to.rb +0 -61
  206. data/manual/outline/insert_section_after.rb +0 -47
  207. data/manual/outline/outline.rb +0 -32
  208. data/manual/outline/sections_and_pages.rb +0 -67
  209. data/manual/repeatable_content/page_numbering.rb +0 -54
  210. data/manual/repeatable_content/repeatable_content.rb +0 -31
  211. data/manual/repeatable_content/repeater.rb +0 -55
  212. data/manual/repeatable_content/stamp.rb +0 -41
  213. data/manual/security/encryption.rb +0 -31
  214. data/manual/security/permissions.rb +0 -38
  215. data/manual/security/security.rb +0 -28
  216. data/manual/syntax_highlight.rb +0 -52
  217. data/manual/table/basic_block.rb +0 -53
  218. data/manual/table/before_rendering_page.rb +0 -26
  219. data/manual/table/cell_border_lines.rb +0 -24
  220. data/manual/table/cell_borders_and_bg.rb +0 -31
  221. data/manual/table/cell_dimensions.rb +0 -30
  222. data/manual/table/cell_text.rb +0 -38
  223. data/manual/table/column_widths.rb +0 -30
  224. data/manual/table/content_and_subtables.rb +0 -39
  225. data/manual/table/creation.rb +0 -27
  226. data/manual/table/filtering.rb +0 -36
  227. data/manual/table/flow_and_header.rb +0 -17
  228. data/manual/table/image_cells.rb +0 -33
  229. data/manual/table/position.rb +0 -29
  230. data/manual/table/row_colors.rb +0 -20
  231. data/manual/table/span.rb +0 -30
  232. data/manual/table/style.rb +0 -22
  233. data/manual/table/table.rb +0 -52
  234. data/manual/table/width.rb +0 -27
  235. data/manual/text/alignment.rb +0 -44
  236. data/manual/text/color.rb +0 -24
  237. data/manual/text/column_box.rb +0 -32
  238. data/manual/text/fallback_fonts.rb +0 -37
  239. data/manual/text/font.rb +0 -41
  240. data/manual/text/font_size.rb +0 -45
  241. data/manual/text/font_style.rb +0 -23
  242. data/manual/text/formatted_callbacks.rb +0 -60
  243. data/manual/text/formatted_text.rb +0 -54
  244. data/manual/text/free_flowing_text.rb +0 -51
  245. data/manual/text/group.rb +0 -31
  246. data/manual/text/inline.rb +0 -43
  247. data/manual/text/kerning_and_character_spacing.rb +0 -39
  248. data/manual/text/leading.rb +0 -25
  249. data/manual/text/line_wrapping.rb +0 -41
  250. data/manual/text/paragraph_indentation.rb +0 -26
  251. data/manual/text/positioned_text.rb +0 -38
  252. data/manual/text/registering_families.rb +0 -48
  253. data/manual/text/rendering_and_color.rb +0 -37
  254. data/manual/text/right_to_left_text.rb +0 -43
  255. data/manual/text/rotation.rb +0 -43
  256. data/manual/text/single_usage.rb +0 -37
  257. data/manual/text/text.rb +0 -75
  258. data/manual/text/text_box_excess.rb +0 -32
  259. data/manual/text/text_box_extensions.rb +0 -45
  260. data/manual/text/text_box_overflow.rb +0 -44
  261. data/manual/text/utf8.rb +0 -28
  262. data/manual/text/win_ansi_charset.rb +0 -59
  263. data/spec/acceptance/png.rb +0 -23
  264. data/spec/column_box_spec.rb +0 -65
  265. data/spec/extensions/encoding_helpers.rb +0 -9
  266. data/spec/font_metric_cache_spec.rb +0 -52
  267. data/spec/image_handler_spec.rb +0 -54
  268. data/spec/soft_mask_spec.rb +0 -117
  269. data/spec/table/span_dummy_spec.rb +0 -17
data/COPYING CHANGED
@@ -1,2 +1,2 @@
1
- Prawn may be used under Matz's original licensing terms for Ruby, or GPLv2 or GPLv3.
2
- See LICENSE for Matz's terms, or GPLv2 and GPLv3 files.
1
+ Prawn may be used under Matz's terms for Ruby, or GPLv2 or GPLv3. See LICENSE
2
+ for Matz's terms, or GPLv2 and GPLv3 files.
data/LICENSE CHANGED
@@ -1,7 +1,7 @@
1
1
  Prawn is copyrighted free software produced by Gregory Brown along with
2
2
  community contributions. See git log for authorship information.
3
3
 
4
- Licensing terms follow:
4
+ Licensing terms follow (License of Ruby):
5
5
 
6
6
  You can redistribute Prawn and/or modify it under either the terms of the GPLv2
7
7
  or GPLv3 (see GPLv2 and GPLv3 files), or the conditions below:
data/README.md ADDED
@@ -0,0 +1,96 @@
1
+ # Prawn: Fast, Nimble PDF Generation For Ruby
2
+
3
+ Prawn is a pure Ruby PDF generation library that provides a lot of great functionality while trying to remain simple and reasonably performant. Here are some of the important features we provide:
4
+
5
+ * Vector drawing support, including lines, polygons, curves, ellipses, etc.
6
+ * Extensive text rendering support, including flowing text and limited inline formatting options.
7
+ * Support for both PDF builtin fonts as well as embedded TrueType fonts
8
+ * A variety of low level tools for basic layout needs, including a simple grid system
9
+ * PNG and JPG image embedding, with flexible scaling options
10
+ * Reporting tools for rendering complex data tables, with pagination support
11
+ * Security features including encryption and password protection
12
+ * Tools for rendering repeatable content (i.e headers, footers, and page numbers)
13
+ * Comprehensive internationalization features, including full support for UTF-8 based fonts, right-to-left text rendering, fallback font support, and extension points for customizable text wrapping.
14
+ * Support for PDF outlines for document navigation
15
+ * Low level PDF features, allowing users to create custom extensions by dropping down all the way to the PDF object tree layer. (Mostly useful to those with knowledge of the PDF specification)
16
+ * Lots of other stuff!
17
+
18
+ ## Should You Use Prawn?
19
+
20
+ If you are looking for a highly flexible PDF document generation system, Prawn might be the tool for you. It is not a reporting tool or a publishing toolchain, though it could be fairly easily used to build those things.
21
+
22
+ One thing Prawn is not, and will never be, is an HTML to PDF generator. For those needs, consider looking into FlyingSaucer via JRuby, or one of the webkit based tools, like Wicked or PDFKit. We do have basic support for inline styling but it is limited to a very small subset of functionality and is not suitable for rendering rich HTML documents.
23
+
24
+ ## Supported Ruby Versions and Implementations
25
+
26
+ Because Prawn is pure Ruby and virtually all of its dependencies are maintained by our core team, it should run pretty much anywhere, including Rubinius, JRuby, MacRuby, etc. While we officially support MRI 1.8.7 and 1.9.2 only, we will accept patches to fix problems on other Ruby platforms if they aren't too invasive.
27
+
28
+ ## Installing Prawn
29
+
30
+ Prawn is distributed via RubyGems, and can be installed the usual way that you install gems: by simply typing `gem install prawn` on the command line.
31
+
32
+ You can also install from git if you'd like, the _master_ branch contains the latest developments, and _stable_ represents the latest bug fixes to the currently released version of Prawn. If you go this route, using Bundler is encouraged.
33
+
34
+ ## Release Policies
35
+
36
+ We may introduce backwards incompatible changes each time our minor version number is bumped, but that any tiny version number bump should be bug fixes and internal changes only. Be sure to read the release notes each time we cut a new release and lock your gems accordingly. You can find the project CHANGELOG at: https://github.com/sandal/prawn/wiki/CHANGELOG
37
+
38
+ ## Hello World!
39
+
40
+ If the following code runs and produces a working PDF file, you've successfully installed Prawn.
41
+
42
+ require "prawn"
43
+
44
+ Prawn::Document.generate("hello.pdf") do
45
+ text "Hello World!"
46
+ end
47
+
48
+ Of course, you'll probably want to do more interesting things than that...
49
+
50
+ ## Manual
51
+
52
+ Mendicant University student Felipe Doria provided us with a beautiful system for generating a user manual from our examples. This can be generated from the prawn source or you can download a pre-generated snapshot of it at http://prawn.majesticseacreature.com/manual.pdf
53
+
54
+ Note that while we will try to keep the downloadable manual up to date, that it's provided as a convenience only and you should generate the manual yourself if you want to be sure the code in it actually runs and works as expected. To build the manual, here's what you need to do:
55
+
56
+ 1. clone the repository
57
+ 2. switch to the stable branch (optional, stay on master for development version)
58
+ 3. install bundler if necessay
59
+ 4. run `bundle install`
60
+ 5. run `bundle exec rake manual`, which will generate _manual.pdf_ in the project root
61
+
62
+ ## Support
63
+
64
+ The easiest way to get help with Prawn is to post a message to our mailing list:
65
+
66
+ <http://groups.google.com/group/prawn-ruby>
67
+
68
+ Feel free to post any Prawn related question there, our community is very responsive and will be happy to help you figure out how to use Prawn, or help you determine whether it's the right tool for the task you are working on.
69
+
70
+ Please make your posts to the list as specific as possible, including code samples and output where relevant. Do not post any information that should not be shared publicly, and be sure to reduce your example code as much as possible so that those who are responding to your question can more easily see what the issue might be.
71
+
72
+ ## Contributing
73
+
74
+ If you've found a bug, want to submit a patch, or have a feature request, please enter a ticket into our github tracker:
75
+
76
+ <http://github.com/sandal/prawn/issues>
77
+
78
+ We strongly encourage bug reports to come with failing tests or at least a reduced example that demonstrates the problem. Similarly, patches should include tests, API documentation, and an update to the manual where relevant. Feel free to send a pull request early though, if you just want some feedback or a code review before preparing your code to be merged.
79
+
80
+ If you are unsure about whether or not you've found a bug, or want to check to see whether we'd be interested in the feature you want to add before you start working on it, feel free to post to our mailing list.
81
+
82
+ ## Authorship
83
+
84
+ Prawn was originally developed by Gregory Brown, under the auspices of the Ruby Mendicant Project, a grassroots initiative in which the Ruby community collectively provided funding so that Gregory could take several months off of work to focus on this project.
85
+
86
+ Over the last several years, we've received code contributions from over 50 people, which is amazing considering the low-level nature of this project. In 2010, Gregory officially handed the project off to the Prawn core team. Currently active maintainers include Brad Ediger, Daniel Nelson, James Healy, and Jonathan Greenberg.
87
+
88
+ While he was only with us for a short time before moving on to other things, we'd also like to thank Prawn core team emeritus Jamis Buck for his contributions. He was responsible for introducing font subsetting as well as the first implementation of our inline formatting support.
89
+
90
+ You can find the full list of folks who have at least one patch accepted to Prawn on github at https://github.com/sandal/prawn/contributors
91
+
92
+ ## License
93
+
94
+ Prawn is released under a slightly modified form of the License of Ruby, allowing you to choose between Matz's terms, the GPLv2, or GPLv3. For details, please see the LICENSE, GPLv2, and GPLv3 files.
95
+
96
+ If you wish to contribute to Prawn, you will retain your own copyright but must agree to license your code under the same terms as the project itself.
data/Rakefile CHANGED
@@ -1,31 +1,40 @@
1
+ require "rubygems"
1
2
  require "bundler"
2
3
  Bundler.setup
3
4
 
4
5
  require 'rake'
5
- require 'rspec/core/rake_task'
6
- require 'yard'
7
- require 'rubygems/package_task'
8
-
9
- task :default => [:spec]
10
-
11
- desc "Run all rspec files"
12
- RSpec::Core::RakeTask.new("spec") do |c|
13
- c.rspec_opts = "-t ~unresolved"
6
+ require 'rake/testtask'
7
+ require "rake/rdoctask"
8
+ require "rake/gempackagetask"
9
+
10
+ task :default => [:test]
11
+
12
+ desc "Run all tests, test-spec, mocha, and pdf-reader required"
13
+ Rake::TestTask.new do |test|
14
+ # test.ruby_opts << "-w" # .should == true triggers a lot of warnings
15
+ test.libs << "spec"
16
+ test.test_files = Dir[ "spec/*_spec.rb" ]
17
+ test.verbose = true
14
18
  end
15
19
 
16
20
  desc "Show library's code statistics"
17
21
  task :stats do
18
- require 'code_statistics'
19
- CodeStatistics::TEST_TYPES << "Specs"
20
- CodeStatistics.new( ["Prawn", "lib"],
21
- ["Specs", "spec"] ).to_s
22
+ require 'code_statistics'
23
+ CodeStatistics::TEST_TYPES << "Specs"
24
+ CodeStatistics.new( ["Prawn", "lib"],
25
+ ["Specs", "spec"] ).to_s
22
26
  end
23
27
 
24
- YARD::Rake::YardocTask.new do |t|
25
- t.options = ['--output-dir', 'doc/html']
28
+ desc "genrates documentation"
29
+ Rake::RDocTask.new do |rdoc|
30
+ rdoc.rdoc_files.include( "README",
31
+ "COPYING",
32
+ "LICENSE",
33
+ "HACKING", "lib/" )
34
+ rdoc.main = "README"
35
+ rdoc.rdoc_dir = "doc/html"
36
+ rdoc.title = "Prawn Documentation"
26
37
  end
27
- task :docs => :yard
28
-
29
38
 
30
39
  desc "Generate the 'Prawn by Example' manual"
31
40
  task :manual do
@@ -36,19 +45,7 @@ task :manual do
36
45
  end
37
46
 
38
47
  spec = Gem::Specification.load "prawn.gemspec"
39
- Gem::PackageTask.new(spec) do |pkg|
48
+ Rake::GemPackageTask.new(spec) do |pkg|
40
49
  pkg.need_zip = true
41
50
  pkg.need_tar = true
42
51
  end
43
-
44
- desc "Run a console with Prawn loaded"
45
- task :console do
46
- require 'irb'
47
- require 'irb/completion'
48
- require_relative 'lib/prawn'
49
- Prawn.debug = true
50
-
51
- ARGV.clear
52
- IRB.start
53
- end
54
-
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -49,7 +49,7 @@ endobj
49
49
  >>
50
50
  /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
51
51
  >>
52
- /Parent 3 0 R
52
+ /Parent 4 0 R
53
53
  >>
54
54
  endobj
55
55
  7 0 obj
@@ -85,7 +85,7 @@ endobj
85
85
  >>
86
86
  /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
87
87
  >>
88
- /Parent 3 0 R
88
+ /Parent 4 0 R
89
89
  >>
90
90
  endobj
91
91
  10 0 obj
@@ -97,17 +97,17 @@ endobj
97
97
  endobj
98
98
  xref
99
99
  0 11
100
- 0000000000 65535 f
101
- 0000000015 00000 n
102
- 0000000071 00000 n
103
- 0000000120 00000 n
104
- 0000000183 00000 n
105
- 0000000240 00000 n
106
- 0000000494 00000 n
107
- 0000000672 00000 n
108
- 0000000769 00000 n
109
- 0000000994 00000 n
110
- 0000001173 00000 n
100
+ 0000000000 65535 f
101
+ 0000000015 00000 n
102
+ 0000000071 00000 n
103
+ 0000000120 00000 n
104
+ 0000000183 00000 n
105
+ 0000000240 00000 n
106
+ 0000000494 00000 n
107
+ 0000000672 00000 n
108
+ 0000000769 00000 n
109
+ 0000000994 00000 n
110
+ 0000001173 00000 n
111
111
  trailer
112
112
  << /Root 2 0 R
113
113
  /Size 11
data/lib/prawn.rb CHANGED
@@ -1,91 +1,27 @@
1
1
  # Welcome to Prawn, the best PDF Generation library ever.
2
2
  # This documentation covers user level functionality.
3
3
  #
4
- require "set"
5
-
6
- require 'ttfunk'
7
- require "pdf/core"
8
-
9
- module Prawn
10
- VERSION = "0.15.0"
11
-
12
- extend self
13
-
14
- file = __FILE__
15
- file = File.readlink(file) if File.symlink?(file)
16
- dir = File.dirname(file)
17
-
18
- # The base source directory for Prawn as installed on the system
19
- #
20
- #
21
- BASEDIR = File.expand_path(File.join(dir, '..'))
22
- DATADIR = File.expand_path(File.join(dir, '..', 'data'))
23
-
24
- FLOAT_PRECISION = 1.0e-9
25
-
26
- # Whe set to true, Prawn will verify hash options to ensure only valid keys
27
- # are used. Off by default.
28
- #
29
- # Example:
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
- #
35
- attr_accessor :debug # @private
36
-
37
- def verify_options(accepted, actual) # @private
38
- return unless debug || $DEBUG
39
- unless (act=Set[*actual.keys]).subset?(acc=Set[*accepted])
40
- raise Prawn::Errors::UnknownOption,
41
- "\nDetected unknown option(s): #{(act - acc).to_a.inspect}\n" <<
42
- "Accepted options are: #{accepted.inspect}"
43
- end
44
- yield if block_given?
45
- end
46
-
47
- module Configurable # @private
48
- def configuration(*args)
49
- @config ||= Marshal.load(Marshal.dump(default_configuration))
50
- if Hash === args[0]
51
- @config.update(args[0])
52
- elsif args.length > 1
53
- @config.values_at(*args)
54
- elsif args.length == 1
55
- @config[args[0]]
56
- else
57
- @config
58
- end
59
- end
60
-
61
- alias_method :C, :configuration
62
- end
4
+ # Those looking to contribute code or write extensions should look
5
+ # into the lib/prawn/core/* source tree.
6
+ #
7
+ module Prawn #:nodoc:
8
+ VERSION = "1.0.0.rc1"
63
9
  end
64
10
 
65
- require_relative "prawn/errors"
66
-
67
-
68
- require_relative "prawn/utilities"
69
- require_relative "prawn/text"
70
- require_relative "prawn/graphics"
71
- require_relative "prawn/images"
72
- require_relative "prawn/images/image"
73
- require_relative "prawn/images/jpg"
74
- require_relative "prawn/images/png"
75
- require_relative "prawn/stamp"
76
- require_relative "prawn/soft_mask"
77
- require_relative "prawn/security"
78
- require_relative "prawn/document"
79
- require_relative "prawn/font"
80
- require_relative "prawn/encoding"
81
- require_relative "prawn/measurements"
82
- require_relative "prawn/repeater"
83
- require_relative "prawn/outline"
84
- require_relative "prawn/layout"
85
-
86
- require_relative "prawn/image_handler"
87
-
88
-
11
+ require "prawn/core"
12
+ require "prawn/text"
13
+ require "prawn/graphics"
14
+ require "prawn/images"
15
+ require "prawn/images/image"
16
+ require "prawn/images/jpg"
17
+ require "prawn/images/png"
18
+ require "prawn/stamp"
19
+ require "prawn/security"
20
+ require "prawn/document"
21
+ require "prawn/font"
22
+ require "prawn/encoding"
23
+ require "prawn/measurements"
24
+ require "prawn/repeater"
25
+ require "prawn/outline"
26
+ require "prawn/layout"
89
27
 
90
- Prawn.image_handler.register(Prawn::Images::PNG)
91
- Prawn.image_handler.register(Prawn::Images::JPG)
@@ -0,0 +1,51 @@
1
+ # coding: utf-8
2
+ #
3
+ # Why would we ever use Ruby 1.8.7 when we can backport with something
4
+ # as simple as this?
5
+ #
6
+ class String #:nodoc:
7
+ def first_line
8
+ self.each_line { |line| return line }
9
+ end
10
+ unless "".respond_to?(:lines)
11
+ alias_method :lines, :to_a
12
+ end
13
+ unless "".respond_to?(:each_char)
14
+ def each_char #:nodoc:
15
+ # copied from jcode
16
+ if block_given?
17
+ scan(/./m) { |x| yield x }
18
+ else
19
+ scan(/./m)
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ unless File.respond_to?(:binread)
26
+ def File.binread(file) #:nodoc:
27
+ File.open(file,"rb") { |f| f.read }
28
+ end
29
+ end
30
+
31
+ if RUBY_VERSION < "1.9"
32
+
33
+ def ruby_18 #:nodoc:
34
+ yield
35
+ end
36
+
37
+ def ruby_19 #:nodoc:
38
+ false
39
+ end
40
+
41
+ else
42
+
43
+ def ruby_18 #:nodoc:
44
+ false
45
+ end
46
+
47
+ def ruby_19 #:nodoc:
48
+ yield
49
+ end
50
+
51
+ end
data/lib/prawn/core.rb ADDED
@@ -0,0 +1,85 @@
1
+ # encoding: utf-8
2
+ # Prawn : A library for PDF generation in Ruby
3
+ #
4
+ # Copyright April 2008, Gregory Brown. All Rights Reserved.
5
+ #
6
+ # This is free software. Please see the LICENSE and COPYING files for details.
7
+
8
+ require "set"
9
+
10
+ %w[ttfunk/lib].each do |dep|
11
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + "/../../vendor/#{dep}")
12
+ end
13
+
14
+ begin
15
+ require 'ttfunk'
16
+ rescue LoadError
17
+ puts "Failed to load ttfunk. If you are running Prawn from git:"
18
+ puts " git submodule init"
19
+ puts " git submodule update"
20
+ exit
21
+ end
22
+
23
+ module Prawn
24
+ extend self
25
+
26
+ file = __FILE__
27
+ file = File.readlink(file) if File.symlink?(file)
28
+ dir = File.dirname(file)
29
+
30
+ # The base source directory for Prawn as installed on the system
31
+ #
32
+ BASEDIR = File.expand_path(File.join(dir, '..', '..'))
33
+
34
+ # Whe set to true, Prawn will verify hash options to ensure only valid keys
35
+ # are used. Off by default.
36
+ #
37
+ # Example:
38
+ # >> Prawn::Document.new(:tomato => "Juicy")
39
+ # Prawn::Errors::UnknownOption:
40
+ # Detected unknown option(s): [:tomato]
41
+ # Accepted options are: [:page_size, :page_layout, :left_margin, ...]
42
+ #
43
+ attr_accessor :debug
44
+
45
+ def verify_options(accepted, actual) #:nodoc:
46
+ return unless debug || $DEBUG
47
+ unless (act=Set[*actual.keys]).subset?(acc=Set[*accepted])
48
+ raise Prawn::Errors::UnknownOption,
49
+ "\nDetected unknown option(s): #{(act - acc).to_a.inspect}\n" <<
50
+ "Accepted options are: #{accepted.inspect}"
51
+ end
52
+ yield if block_given?
53
+ end
54
+
55
+ module Configurable #:nodoc:
56
+ def configuration(*args)
57
+ @config ||= Marshal.load(Marshal.dump(default_configuration))
58
+ if Hash === args[0]
59
+ @config.update(args[0])
60
+ elsif args.length > 1
61
+ @config.values_at(*args)
62
+ elsif args.length == 1
63
+ @config[args[0]]
64
+ else
65
+ @config
66
+ end
67
+ end
68
+
69
+ alias_method :C, :configuration
70
+ end
71
+ end
72
+
73
+ require "prawn/compatibility"
74
+ require "prawn/errors"
75
+ require "prawn/core/pdf_object"
76
+ require "prawn/core/reference"
77
+ require "prawn/core/page"
78
+ require "prawn/core/object_store"
79
+ require "prawn/core/document_state"
80
+ require "prawn/core/literal_string"
81
+ require "prawn/core/byte_string"
82
+ require "prawn/core/name_tree"
83
+ require "prawn/core/annotations"
84
+ require "prawn/core/destinations"
85
+