prawn 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +4 -2
- data/lib/prawn.rb +5 -3
- data/lib/prawn/document.rb +7 -7
- data/lib/prawn/document/bounding_box.rb +1 -1
- data/lib/prawn/document/column_box.rb +3 -3
- data/lib/prawn/document/internals.rb +1 -1
- data/lib/prawn/font.rb +24 -8
- data/lib/prawn/font/afm.rb +4 -4
- data/lib/prawn/font_metric_cache.rb +1 -1
- data/lib/prawn/grid.rb +3 -1
- data/lib/prawn/image_handler.rb +3 -1
- data/lib/prawn/images/jpg.rb +1 -1
- data/lib/prawn/measurement_extensions.rb +1 -1
- data/lib/prawn/outline.rb +3 -1
- data/lib/prawn/security.rb +1 -1
- data/lib/prawn/security/arcfour.rb +4 -2
- data/lib/prawn/table.rb +14 -2
- data/lib/prawn/table/cell.rb +1 -1
- data/lib/prawn/table/cells.rb +1 -50
- data/lib/prawn/table/column_width_calculator.rb +131 -10
- data/lib/prawn/text.rb +1 -1
- data/lib/prawn/text/formatted.rb +2 -0
- data/lib/prawn/text/formatted/arranger.rb +1 -1
- data/lib/prawn/text/formatted/box.rb +5 -5
- data/lib/prawn/text/formatted/line_wrap.rb +1 -1
- data/lib/prawn/text/formatted/wrap.rb +2 -0
- data/lib/prawn/utilities.rb +3 -3
- data/manual/absolute_position.pdf +0 -0
- data/manual/basic_concepts/adding_pages.rb +3 -3
- data/manual/basic_concepts/basic_concepts.rb +6 -6
- data/manual/basic_concepts/cursor.rb +5 -5
- data/manual/basic_concepts/measurement.rb +2 -2
- data/manual/basic_concepts/origin.rb +3 -3
- data/manual/basic_concepts/other_cursor_helpers.rb +6 -6
- data/manual/bounding_box/bounding_box.rb +6 -6
- data/manual/bounding_box/bounds.rb +6 -6
- data/manual/bounding_box/canvas.rb +2 -2
- data/manual/bounding_box/creation.rb +3 -3
- data/manual/bounding_box/indentation.rb +9 -9
- data/manual/bounding_box/nesting.rb +8 -8
- data/manual/bounding_box/russian_boxes.rb +1 -1
- data/manual/bounding_box/stretchy.rb +8 -8
- data/manual/{manual/manual.rb → contents.rb} +6 -9
- data/manual/{manual/cover.rb → cover.rb} +6 -6
- data/manual/document_and_page_options/background.rb +2 -2
- data/manual/document_and_page_options/document_and_page_options.rb +4 -4
- data/manual/document_and_page_options/metadata.rb +2 -2
- data/manual/document_and_page_options/page_margins.rb +2 -2
- data/manual/document_and_page_options/page_size.rb +3 -3
- data/manual/example_helper.rb +5 -409
- data/manual/graphics/circle_and_ellipse.rb +4 -4
- data/manual/graphics/color.rb +4 -4
- data/manual/graphics/common_lines.rb +5 -5
- data/manual/graphics/fill_and_stroke.rb +5 -5
- data/manual/graphics/fill_rules.rb +1 -1
- data/manual/graphics/gradients.rb +1 -1
- data/manual/graphics/graphics.rb +8 -8
- data/manual/graphics/helper.rb +1 -1
- data/manual/graphics/line_width.rb +5 -5
- data/manual/graphics/lines_and_curves.rb +5 -5
- data/manual/graphics/polygon.rb +4 -4
- data/manual/graphics/rectangle.rb +3 -3
- data/manual/graphics/rotate.rb +5 -5
- data/manual/graphics/scale.rb +5 -5
- data/manual/graphics/soft_masks.rb +1 -1
- data/manual/graphics/stroke_cap.rb +3 -3
- data/manual/graphics/stroke_dash.rb +1 -1
- data/manual/graphics/stroke_join.rb +4 -4
- data/manual/graphics/translate.rb +5 -5
- data/manual/graphics/transparency.rb +5 -5
- data/manual/{manual/how_to_read_this_manual.rb → how_to_read_this_manual.rb} +16 -17
- data/manual/images/absolute_position.rb +3 -3
- data/manual/images/fit.rb +2 -2
- data/manual/images/horizontal.rb +3 -3
- data/manual/images/images.rb +7 -7
- data/manual/images/plain_image.rb +1 -1
- data/manual/images/scale.rb +3 -3
- data/manual/images/vertical.rb +3 -3
- data/manual/images/width_and_height.rb +3 -3
- data/manual/layout/boxes.rb +4 -4
- data/manual/layout/content.rb +3 -3
- data/manual/layout/layout.rb +5 -5
- data/manual/layout/simple_grid.rb +2 -2
- data/manual/outline/add_subsection_to.rb +7 -7
- data/manual/outline/insert_section_after.rb +5 -5
- data/manual/outline/outline.rb +6 -6
- data/manual/outline/sections_and_pages.rb +9 -9
- data/manual/repeatable_content/page_numbering.rb +3 -3
- data/manual/repeatable_content/repeatable_content.rb +5 -5
- data/manual/repeatable_content/repeater.rb +4 -4
- data/manual/repeatable_content/stamp.rb +4 -4
- data/manual/security/encryption.rb +2 -2
- data/manual/security/permissions.rb +2 -2
- data/manual/security/security.rb +5 -5
- data/manual/table/basic_block.rb +5 -5
- data/manual/table/before_rendering_page.rb +1 -1
- data/manual/table/cell_border_lines.rb +4 -4
- data/manual/table/cell_borders_and_bg.rb +4 -4
- data/manual/table/cell_dimensions.rb +3 -3
- data/manual/table/cell_text.rb +6 -6
- data/manual/table/column_widths.rb +4 -4
- data/manual/table/content_and_subtables.rb +5 -5
- data/manual/table/creation.rb +2 -2
- data/manual/table/filtering.rb +6 -6
- data/manual/table/flow_and_header.rb +2 -2
- data/manual/table/image_cells.rb +1 -1
- data/manual/table/position.rb +1 -1
- data/manual/table/row_colors.rb +3 -3
- data/manual/table/span.rb +1 -1
- data/manual/table/style.rb +3 -3
- data/manual/table/table.rb +7 -7
- data/manual/table/width.rb +3 -3
- data/manual/text/alignment.rb +1 -1
- data/manual/text/color.rb +1 -1
- data/manual/text/column_box.rb +1 -1
- data/manual/text/fallback_fonts.rb +3 -3
- data/manual/text/font.rb +7 -7
- data/manual/text/font_size.rb +9 -9
- data/manual/text/font_style.rb +3 -3
- data/manual/text/formatted_callbacks.rb +3 -3
- data/manual/text/formatted_text.rb +3 -3
- data/manual/text/free_flowing_text.rb +6 -6
- data/manual/text/inline.rb +5 -5
- data/manual/text/kerning_and_character_spacing.rb +7 -7
- data/manual/text/leading.rb +4 -4
- data/manual/text/line_wrapping.rb +4 -4
- data/manual/text/paragraph_indentation.rb +3 -3
- data/manual/text/positioned_text.rb +3 -3
- data/manual/text/registering_families.rb +6 -6
- data/manual/text/rendering_and_color.rb +2 -2
- data/manual/text/right_to_left_text.rb +2 -2
- data/manual/text/rotation.rb +4 -4
- data/manual/text/single_usage.rb +3 -3
- data/manual/text/text.rb +9 -9
- data/manual/text/text_box_excess.rb +2 -2
- data/manual/text/text_box_extensions.rb +3 -3
- data/manual/text/text_box_overflow.rb +4 -4
- data/manual/text/utf8.rb +5 -5
- data/manual/text/win_ansi_charset.rb +1 -1
- data/prawn.gemspec +5 -3
- data/spec/acceptance/png.rb +5 -3
- data/spec/cell_spec.rb +1 -0
- data/spec/column_box_spec.rb +1 -1
- data/spec/extensions/encoding_helpers.rb +2 -0
- data/spec/extensions/mocha.rb +2 -0
- data/spec/font_spec.rb +15 -0
- data/spec/measurement_units_spec.rb +2 -0
- data/spec/repeater_spec.rb +2 -0
- data/spec/soft_mask_spec.rb +2 -0
- data/spec/stamp_spec.rb +2 -0
- data/spec/table_spec.rb +103 -10
- data/spec/text_spec.rb +1 -1
- data/spec/transparency_spec.rb +2 -0
- metadata +42 -18
- data/lib/prawn/layout.rb +0 -17
- data/manual/example_file.rb +0 -111
- data/manual/example_package.rb +0 -53
- data/manual/example_section.rb +0 -46
- data/manual/syntax_highlight.rb +0 -52
data/spec/text_spec.rb
CHANGED
|
@@ -410,7 +410,7 @@ describe "#text" do
|
|
|
410
410
|
end
|
|
411
411
|
|
|
412
412
|
describe "#shrink_to_fit with special utf-8 text" do
|
|
413
|
-
it "Should not throw an exception",
|
|
413
|
+
it "Should not throw an exception",
|
|
414
414
|
:unresolved, :issue => 603 do
|
|
415
415
|
pages = 0
|
|
416
416
|
doc = Prawn::Document.new(page_size: 'A4', margin: [2, 2, 2, 2]) do |pdf|
|
data/spec/transparency_spec.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: prawn
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gregory Brown
|
|
@@ -12,7 +12,7 @@ authors:
|
|
|
12
12
|
autorequire:
|
|
13
13
|
bindir: bin
|
|
14
14
|
cert_chain: []
|
|
15
|
-
date: 2014-
|
|
15
|
+
date: 2014-06-27 00:00:00.000000000 Z
|
|
16
16
|
dependencies:
|
|
17
17
|
- !ruby/object:Gem::Dependency
|
|
18
18
|
name: ttfunk
|
|
@@ -20,28 +20,28 @@ dependencies:
|
|
|
20
20
|
requirements:
|
|
21
21
|
- - "~>"
|
|
22
22
|
- !ruby/object:Gem::Version
|
|
23
|
-
version: 1.
|
|
23
|
+
version: 1.2.0
|
|
24
24
|
type: :runtime
|
|
25
25
|
prerelease: false
|
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
|
27
27
|
requirements:
|
|
28
28
|
- - "~>"
|
|
29
29
|
- !ruby/object:Gem::Version
|
|
30
|
-
version: 1.
|
|
30
|
+
version: 1.2.0
|
|
31
31
|
- !ruby/object:Gem::Dependency
|
|
32
32
|
name: pdf-core
|
|
33
33
|
requirement: !ruby/object:Gem::Requirement
|
|
34
34
|
requirements:
|
|
35
35
|
- - "~>"
|
|
36
36
|
- !ruby/object:Gem::Version
|
|
37
|
-
version: 0.2.
|
|
37
|
+
version: 0.2.5
|
|
38
38
|
type: :runtime
|
|
39
39
|
prerelease: false
|
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
|
41
41
|
requirements:
|
|
42
42
|
- - "~>"
|
|
43
43
|
- !ruby/object:Gem::Version
|
|
44
|
-
version: 0.2.
|
|
44
|
+
version: 0.2.5
|
|
45
45
|
- !ruby/object:Gem::Dependency
|
|
46
46
|
name: pdf-inspector
|
|
47
47
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -88,16 +88,16 @@ dependencies:
|
|
|
88
88
|
name: rspec
|
|
89
89
|
requirement: !ruby/object:Gem::Requirement
|
|
90
90
|
requirements:
|
|
91
|
-
- -
|
|
91
|
+
- - '='
|
|
92
92
|
- !ruby/object:Gem::Version
|
|
93
|
-
version:
|
|
93
|
+
version: 2.14.1
|
|
94
94
|
type: :development
|
|
95
95
|
prerelease: false
|
|
96
96
|
version_requirements: !ruby/object:Gem::Requirement
|
|
97
97
|
requirements:
|
|
98
|
-
- -
|
|
98
|
+
- - '='
|
|
99
99
|
- !ruby/object:Gem::Version
|
|
100
|
-
version:
|
|
100
|
+
version: 2.14.1
|
|
101
101
|
- !ruby/object:Gem::Dependency
|
|
102
102
|
name: mocha
|
|
103
103
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -140,6 +140,20 @@ dependencies:
|
|
|
140
140
|
- - ">="
|
|
141
141
|
- !ruby/object:Gem::Version
|
|
142
142
|
version: '0'
|
|
143
|
+
- !ruby/object:Gem::Dependency
|
|
144
|
+
name: prawn-manual_builder
|
|
145
|
+
requirement: !ruby/object:Gem::Requirement
|
|
146
|
+
requirements:
|
|
147
|
+
- - ">="
|
|
148
|
+
- !ruby/object:Gem::Version
|
|
149
|
+
version: 0.1.1
|
|
150
|
+
type: :development
|
|
151
|
+
prerelease: false
|
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
153
|
+
requirements:
|
|
154
|
+
- - ">="
|
|
155
|
+
- !ruby/object:Gem::Version
|
|
156
|
+
version: 0.1.1
|
|
143
157
|
- !ruby/object:Gem::Dependency
|
|
144
158
|
name: pdf-reader
|
|
145
159
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -154,6 +168,20 @@ dependencies:
|
|
|
154
168
|
- - "~>"
|
|
155
169
|
- !ruby/object:Gem::Version
|
|
156
170
|
version: '1.2'
|
|
171
|
+
- !ruby/object:Gem::Dependency
|
|
172
|
+
name: rubocop
|
|
173
|
+
requirement: !ruby/object:Gem::Requirement
|
|
174
|
+
requirements:
|
|
175
|
+
- - '='
|
|
176
|
+
- !ruby/object:Gem::Version
|
|
177
|
+
version: 0.20.1
|
|
178
|
+
type: :development
|
|
179
|
+
prerelease: false
|
|
180
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
181
|
+
requirements:
|
|
182
|
+
- - '='
|
|
183
|
+
- !ruby/object:Gem::Version
|
|
184
|
+
version: 0.20.1
|
|
157
185
|
description: |2
|
|
158
186
|
Prawn is a fast, tiny, and nimble PDF generator for Ruby
|
|
159
187
|
email:
|
|
@@ -257,7 +285,6 @@ files:
|
|
|
257
285
|
- lib/prawn/images/image.rb
|
|
258
286
|
- lib/prawn/images/jpg.rb
|
|
259
287
|
- lib/prawn/images/png.rb
|
|
260
|
-
- lib/prawn/layout.rb
|
|
261
288
|
- lib/prawn/measurement_extensions.rb
|
|
262
289
|
- lib/prawn/measurements.rb
|
|
263
290
|
- lib/prawn/outline.rb
|
|
@@ -285,6 +312,7 @@ files:
|
|
|
285
312
|
- lib/prawn/text/formatted/parser.rb
|
|
286
313
|
- lib/prawn/text/formatted/wrap.rb
|
|
287
314
|
- lib/prawn/utilities.rb
|
|
315
|
+
- manual/absolute_position.pdf
|
|
288
316
|
- manual/basic_concepts/adding_pages.rb
|
|
289
317
|
- manual/basic_concepts/basic_concepts.rb
|
|
290
318
|
- manual/basic_concepts/creation.rb
|
|
@@ -300,16 +328,15 @@ files:
|
|
|
300
328
|
- manual/bounding_box/nesting.rb
|
|
301
329
|
- manual/bounding_box/russian_boxes.rb
|
|
302
330
|
- manual/bounding_box/stretchy.rb
|
|
331
|
+
- manual/contents.rb
|
|
332
|
+
- manual/cover.rb
|
|
303
333
|
- manual/document_and_page_options/background.rb
|
|
304
334
|
- manual/document_and_page_options/document_and_page_options.rb
|
|
305
335
|
- manual/document_and_page_options/metadata.rb
|
|
306
336
|
- manual/document_and_page_options/page_margins.rb
|
|
307
337
|
- manual/document_and_page_options/page_size.rb
|
|
308
338
|
- manual/document_and_page_options/print_scaling.rb
|
|
309
|
-
- manual/example_file.rb
|
|
310
339
|
- manual/example_helper.rb
|
|
311
|
-
- manual/example_package.rb
|
|
312
|
-
- manual/example_section.rb
|
|
313
340
|
- manual/graphics/circle_and_ellipse.rb
|
|
314
341
|
- manual/graphics/color.rb
|
|
315
342
|
- manual/graphics/common_lines.rb
|
|
@@ -330,6 +357,7 @@ files:
|
|
|
330
357
|
- manual/graphics/stroke_join.rb
|
|
331
358
|
- manual/graphics/translate.rb
|
|
332
359
|
- manual/graphics/transparency.rb
|
|
360
|
+
- manual/how_to_read_this_manual.rb
|
|
333
361
|
- manual/images/absolute_position.rb
|
|
334
362
|
- manual/images/fit.rb
|
|
335
363
|
- manual/images/horizontal.rb
|
|
@@ -342,9 +370,6 @@ files:
|
|
|
342
370
|
- manual/layout/content.rb
|
|
343
371
|
- manual/layout/layout.rb
|
|
344
372
|
- manual/layout/simple_grid.rb
|
|
345
|
-
- manual/manual/cover.rb
|
|
346
|
-
- manual/manual/how_to_read_this_manual.rb
|
|
347
|
-
- manual/manual/manual.rb
|
|
348
373
|
- manual/outline/add_subsection_to.rb
|
|
349
374
|
- manual/outline/insert_section_after.rb
|
|
350
375
|
- manual/outline/outline.rb
|
|
@@ -356,7 +381,6 @@ files:
|
|
|
356
381
|
- manual/security/encryption.rb
|
|
357
382
|
- manual/security/permissions.rb
|
|
358
383
|
- manual/security/security.rb
|
|
359
|
-
- manual/syntax_highlight.rb
|
|
360
384
|
- manual/table/basic_block.rb
|
|
361
385
|
- manual/table/before_rendering_page.rb
|
|
362
386
|
- manual/table/cell_border_lines.rb
|
data/lib/prawn/layout.rb
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# This is free software. Please see the LICENSE and COPYING files for details.
|
|
2
|
-
|
|
3
|
-
require_relative "table"
|
|
4
|
-
require_relative "grid"
|
|
5
|
-
|
|
6
|
-
module Prawn
|
|
7
|
-
module Errors
|
|
8
|
-
|
|
9
|
-
# This error is raised when table data is malformed
|
|
10
|
-
#
|
|
11
|
-
InvalidTableData = Class.new(StandardError)
|
|
12
|
-
|
|
13
|
-
# This error is raised when an empty or nil table is rendered
|
|
14
|
-
#
|
|
15
|
-
EmptyTable = Class.new(StandardError)
|
|
16
|
-
end
|
|
17
|
-
end
|
data/manual/example_file.rb
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
module Prawn
|
|
4
|
-
|
|
5
|
-
# The Prawn::ExampleFile class is a utility class to ease the manipulation
|
|
6
|
-
# and extraction of source code and comments from the actual example files
|
|
7
|
-
#
|
|
8
|
-
class ExampleFile
|
|
9
|
-
attr_reader :package, :filename
|
|
10
|
-
|
|
11
|
-
# Stores the file data, filename and parent, which will be either an
|
|
12
|
-
# ExampleSection or an ExamplePackage.
|
|
13
|
-
#
|
|
14
|
-
# Available boolean options are:
|
|
15
|
-
#
|
|
16
|
-
# <tt>:eval_source</tt>:: Evals the example source code (default: true)
|
|
17
|
-
# <tt>:full_source</tt>:: Extract the full source code when true. Extract
|
|
18
|
-
# only the code between the generate block when false (default: false)
|
|
19
|
-
#
|
|
20
|
-
def initialize(parent, filename, options={})
|
|
21
|
-
@parent = parent.is_a?(String) ? ExamplePackage.new(parent) : parent
|
|
22
|
-
|
|
23
|
-
@filename = filename
|
|
24
|
-
@data = read_file(@parent.folder_name, filename)
|
|
25
|
-
|
|
26
|
-
@options = {:eval_source => true, :full_source => false}.merge(options)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
# Return the example source code excluding the initial comments and
|
|
30
|
-
# require calls
|
|
31
|
-
#
|
|
32
|
-
def full_source
|
|
33
|
-
@data.gsub(/# encoding.*?\n.*require.*?\n\n/m, "\n").strip
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
# Return the example source contained inside the first generate block or
|
|
37
|
-
# the full source if no generate block is found
|
|
38
|
-
#
|
|
39
|
-
def generate_block_source
|
|
40
|
-
block = @data.slice(/\w+\.generate.*? do\n(.*)end/m, 1)
|
|
41
|
-
|
|
42
|
-
return full_source unless block
|
|
43
|
-
|
|
44
|
-
block.gsub(/^( ){2}/, "")
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
# Return either the full_source or the generate_block_source according
|
|
48
|
-
# to the options
|
|
49
|
-
#
|
|
50
|
-
def source
|
|
51
|
-
@options[:full_source] ? full_source : generate_block_source
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
# Return true if the example source should be evaluated inline within
|
|
55
|
-
# the manual according to the options
|
|
56
|
-
#
|
|
57
|
-
def eval?
|
|
58
|
-
@options[:eval_source]
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
# Retrieve the comments between the encoding declaration and the require
|
|
62
|
-
# call for example_helper.rb
|
|
63
|
-
#
|
|
64
|
-
# Then removes the '#' signs, reflows the line breaks and return the result
|
|
65
|
-
#
|
|
66
|
-
def introduction_text
|
|
67
|
-
intro = @data.slice(/# encoding.*?\n(.*)require File\.expand_path/m, 1)
|
|
68
|
-
intro.gsub!(/\n# (?=\S)/m, ' ')
|
|
69
|
-
intro.gsub!(/^#/, '')
|
|
70
|
-
intro.gsub!("\n", "\n\n")
|
|
71
|
-
intro.rstrip!
|
|
72
|
-
intro
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
# Returns a human friendly version of the example file name
|
|
76
|
-
#
|
|
77
|
-
def name
|
|
78
|
-
@name ||= @filename[/(.*)\.rb/, 1].gsub("_", " ").capitalize
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
# Returns this example's parent original folder name
|
|
82
|
-
#
|
|
83
|
-
def parent_folder_name
|
|
84
|
-
@parent.folder_name
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
# Returns the human friendly version of this example parent name
|
|
88
|
-
#
|
|
89
|
-
def parent_name
|
|
90
|
-
@parent.name
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
# Renders this example to a pdf
|
|
94
|
-
#
|
|
95
|
-
def render(pdf)
|
|
96
|
-
pdf.render_example(self)
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
private
|
|
100
|
-
|
|
101
|
-
# Read the data from a file in a given package
|
|
102
|
-
#
|
|
103
|
-
def read_file(folder_name, filename)
|
|
104
|
-
data = File.read(File.expand_path(File.join(
|
|
105
|
-
File.dirname(__FILE__), folder_name, filename)))
|
|
106
|
-
|
|
107
|
-
data.encode(::Encoding::UTF_8)
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
end
|
|
111
|
-
end
|
data/manual/example_package.rb
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
module Prawn
|
|
4
|
-
|
|
5
|
-
# The Prawn::ExamplePackage class is a utility class to handle the packaging
|
|
6
|
-
# of individual examples within a hierarchy when building the manual
|
|
7
|
-
#
|
|
8
|
-
class ExamplePackage
|
|
9
|
-
attr_reader :intro_block, :folder_name
|
|
10
|
-
|
|
11
|
-
def initialize(folder_name)
|
|
12
|
-
@folder_name = folder_name
|
|
13
|
-
@hierarchy = []
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
# Stores a new ExampleSection in the hierarchy and yields it to a block
|
|
17
|
-
#
|
|
18
|
-
def section(name)
|
|
19
|
-
s = ExampleSection.new(self, name)
|
|
20
|
-
yield s
|
|
21
|
-
@hierarchy << s
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
# Stores a new ExampleFile in the hierarchy
|
|
25
|
-
#
|
|
26
|
-
def example(filename, options={})
|
|
27
|
-
@hierarchy << ExampleFile.new(self, "#{filename}.rb", options)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
# Stores a block with code to be evaluated when rendering the package cover
|
|
31
|
-
#
|
|
32
|
-
def intro(&block)
|
|
33
|
-
@intro_block = block
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
# Returns a human friendly version of the package name
|
|
37
|
-
#
|
|
38
|
-
def name
|
|
39
|
-
@name ||= @folder_name.gsub("_", " ").capitalize
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
# Renders a cover page for the package to a pdf and iterates the examples
|
|
43
|
-
# hierarchy delegating the examples and sections to be rendered as well
|
|
44
|
-
#
|
|
45
|
-
def render(pdf)
|
|
46
|
-
pdf.render_package_cover(self)
|
|
47
|
-
|
|
48
|
-
@hierarchy.each do |node|
|
|
49
|
-
node.render(pdf)
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
data/manual/example_section.rb
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
module Prawn
|
|
4
|
-
|
|
5
|
-
# The Prawn::ExampleSection class is a utility class to handle sections
|
|
6
|
-
# of related examples within an ExamplePackage
|
|
7
|
-
#
|
|
8
|
-
class ExampleSection
|
|
9
|
-
attr_reader :name
|
|
10
|
-
|
|
11
|
-
def initialize(package, name)
|
|
12
|
-
@package = package
|
|
13
|
-
@name = name
|
|
14
|
-
@examples = []
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
# Stores a new ExampleFile in the examples list
|
|
18
|
-
#
|
|
19
|
-
def example(filename, options={})
|
|
20
|
-
@examples << ExampleFile.new(self, "#{filename}.rb", options)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
# Returns this example's package original folder name
|
|
24
|
-
#
|
|
25
|
-
def folder_name
|
|
26
|
-
@package.folder_name
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
# Returns the human friendly version of this section's package name
|
|
30
|
-
#
|
|
31
|
-
def package_name
|
|
32
|
-
@package.name
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
# Renders the section to a pdf and iterates the examples list delegating the
|
|
36
|
-
# examples to be rendered as well
|
|
37
|
-
#
|
|
38
|
-
def render(pdf)
|
|
39
|
-
pdf.render_section(self)
|
|
40
|
-
|
|
41
|
-
@examples.each do |example|
|
|
42
|
-
example.render(pdf)
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
data/manual/syntax_highlight.rb
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
require "coderay"
|
|
4
|
-
|
|
5
|
-
# Registers a to_prawn method on CodeRay. It returns an array of hashes to be
|
|
6
|
-
# used with formatted_text.
|
|
7
|
-
#
|
|
8
|
-
# Usage:
|
|
9
|
-
#
|
|
10
|
-
# CodeRay.scan(string, :ruby).to_prawn
|
|
11
|
-
#
|
|
12
|
-
class PrawnEncoder < CodeRay::Encoders::Encoder
|
|
13
|
-
register_for :to_prawn
|
|
14
|
-
|
|
15
|
-
COLORS = { :default => "FFFFFF",
|
|
16
|
-
|
|
17
|
-
:comment => "AEAEAE",
|
|
18
|
-
:constant => "88A5D2",
|
|
19
|
-
:instance_variable => "E8ED97",
|
|
20
|
-
:integer => "C8FF0E",
|
|
21
|
-
:float => "C8FF0E",
|
|
22
|
-
:inline_delimiter => "EF804F", # #{} within a string
|
|
23
|
-
:keyword => "FEE100",
|
|
24
|
-
|
|
25
|
-
# BUG: There appear to be some problem with this token. Method
|
|
26
|
-
# definitions are considered as ident tokens
|
|
27
|
-
#
|
|
28
|
-
:method => "FF5C00",
|
|
29
|
-
:string => "56D65E",
|
|
30
|
-
:symbol => "C8FF0E"
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
def setup(options)
|
|
34
|
-
super
|
|
35
|
-
@out = []
|
|
36
|
-
@open = []
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def text_token(text, kind)
|
|
40
|
-
color = COLORS[kind] || COLORS[@open.last] || COLORS[:default]
|
|
41
|
-
|
|
42
|
-
@out << {:text => text, :color => color}
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def begin_group(kind)
|
|
46
|
-
@open << kind
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def end_group(kind)
|
|
50
|
-
@open.pop
|
|
51
|
-
end
|
|
52
|
-
end
|