prawn 0.13.0 → 2.4.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 +5 -5
- checksums.yaml.gz.sig +0 -0
- data/.yardopts +10 -0
- data/GPLv2 +20 -21
- data/Gemfile +3 -16
- data/Rakefile +17 -39
- data/lib/prawn/document/bounding_box.rb +85 -42
- data/lib/prawn/document/column_box.rb +21 -11
- data/lib/prawn/document/internals.rb +40 -147
- data/lib/prawn/document/span.rb +25 -17
- data/lib/prawn/document.rb +286 -245
- data/lib/prawn/encoding.rb +68 -101
- data/lib/prawn/errors.rb +47 -43
- data/lib/prawn/font.rb +204 -155
- data/lib/prawn/font_metric_cache.rb +25 -21
- data/lib/prawn/fonts/afm.rb +292 -0
- data/lib/prawn/{font → fonts}/dfont.rb +7 -13
- data/lib/prawn/fonts/otf.rb +11 -0
- data/lib/prawn/fonts/ttc.rb +36 -0
- data/lib/prawn/{font → fonts}/ttf.rb +142 -80
- data/lib/prawn/graphics/blend_mode.rb +65 -0
- data/lib/prawn/graphics/cap_style.rb +6 -5
- data/lib/prawn/graphics/color.rb +47 -44
- data/lib/prawn/graphics/dash.rb +30 -13
- data/lib/prawn/graphics/join_style.rb +13 -6
- data/lib/prawn/graphics/patterns.rb +221 -90
- data/lib/prawn/graphics/transformation.rb +21 -12
- data/lib/prawn/graphics/transparency.rb +21 -17
- data/lib/prawn/graphics.rb +155 -128
- data/lib/prawn/{layout/grid.rb → grid.rb} +110 -47
- data/lib/prawn/image_handler.rb +16 -2
- data/lib/prawn/images/image.rb +4 -2
- data/lib/prawn/images/jpg.rb +39 -30
- data/lib/prawn/images/png.rb +132 -169
- data/lib/prawn/images.rb +70 -62
- data/lib/prawn/measurement_extensions.rb +15 -10
- data/lib/prawn/measurements.rb +22 -23
- data/lib/prawn/outline.rb +301 -13
- data/lib/prawn/repeater.rb +19 -17
- data/lib/prawn/security/arcfour.rb +54 -0
- data/lib/prawn/security.rb +108 -86
- data/lib/prawn/soft_mask.rb +40 -41
- data/lib/prawn/stamp.rb +29 -12
- data/lib/prawn/text/box.rb +27 -29
- data/lib/prawn/text/formatted/arranger.rb +110 -67
- data/lib/prawn/text/formatted/box.rb +233 -165
- data/lib/prawn/text/formatted/fragment.rb +27 -27
- data/lib/prawn/text/formatted/line_wrap.rb +137 -97
- data/lib/prawn/text/formatted/parser.rb +149 -127
- data/lib/prawn/text/formatted/wrap.rb +57 -37
- data/lib/prawn/text/formatted.rb +6 -4
- data/lib/prawn/text.rb +105 -73
- data/lib/prawn/transformation_stack.rb +44 -0
- data/lib/prawn/utilities.rb +11 -21
- data/lib/prawn/version.rb +5 -0
- data/lib/prawn/view.rb +101 -0
- data/lib/prawn.rb +42 -68
- data/{data/images/fractal.jpg → manual/absolute_position.pdf} +0 -0
- data/manual/basic_concepts/adding_pages.rb +9 -10
- data/manual/basic_concepts/basic_concepts.rb +33 -24
- data/manual/basic_concepts/creation.rb +10 -11
- data/manual/basic_concepts/cursor.rb +9 -10
- data/manual/basic_concepts/measurement.rb +10 -11
- data/manual/basic_concepts/origin.rb +8 -9
- data/manual/basic_concepts/other_cursor_helpers.rb +17 -18
- data/manual/basic_concepts/view.rb +48 -0
- data/manual/bounding_box/bounding_box.rb +31 -29
- data/manual/bounding_box/bounds.rb +17 -18
- data/manual/bounding_box/canvas.rb +8 -9
- data/manual/bounding_box/creation.rb +8 -9
- data/manual/bounding_box/indentation.rb +22 -23
- data/manual/bounding_box/nesting.rb +32 -25
- data/manual/bounding_box/russian_boxes.rb +19 -19
- data/manual/bounding_box/stretchy.rb +18 -20
- data/manual/contents.rb +35 -0
- data/manual/cover.rb +43 -0
- data/manual/document_and_page_options/background.rb +16 -14
- data/manual/document_and_page_options/document_and_page_options.rb +26 -23
- data/manual/document_and_page_options/metadata.rb +21 -19
- data/manual/document_and_page_options/page_margins.rb +20 -22
- data/manual/document_and_page_options/page_size.rb +15 -15
- data/manual/document_and_page_options/print_scaling.rb +23 -0
- data/manual/example_helper.rb +5 -408
- data/manual/graphics/blend_mode.rb +52 -0
- data/manual/graphics/circle_and_ellipse.rb +8 -9
- data/manual/graphics/color.rb +11 -13
- data/manual/graphics/common_lines.rb +13 -12
- data/manual/graphics/fill_and_stroke.rb +10 -11
- data/manual/graphics/fill_rules.rb +13 -12
- data/manual/graphics/gradients.rb +28 -22
- data/manual/graphics/graphics.rb +52 -46
- data/manual/graphics/helper.rb +20 -10
- data/manual/graphics/line_width.rb +13 -12
- data/manual/graphics/lines_and_curves.rb +13 -14
- data/manual/graphics/polygon.rb +10 -12
- data/manual/graphics/rectangle.rb +7 -8
- data/manual/graphics/rotate.rb +9 -12
- data/manual/graphics/scale.rb +19 -18
- data/manual/graphics/soft_masks.rb +5 -7
- data/manual/graphics/stroke_cap.rb +10 -11
- data/manual/graphics/stroke_dash.rb +16 -17
- data/manual/graphics/stroke_join.rb +10 -11
- data/manual/graphics/translate.rb +13 -13
- data/manual/graphics/transparency.rb +11 -13
- data/manual/{manual/how_to_read_this_manual.rb → how_to_read_this_manual.rb} +23 -25
- data/manual/images/absolute_position.rb +9 -10
- data/manual/images/fit.rb +9 -10
- data/manual/images/horizontal.rb +13 -14
- data/manual/images/images.rb +31 -30
- data/manual/images/plain_image.rb +6 -7
- data/manual/images/scale.rb +12 -13
- data/manual/images/vertical.rb +19 -17
- data/manual/images/width_and_height.rb +13 -14
- data/manual/layout/boxes.rb +14 -15
- data/manual/layout/content.rb +12 -13
- data/manual/layout/layout.rb +19 -20
- data/manual/layout/simple_grid.rb +8 -9
- data/manual/outline/add_subsection_to.rb +26 -27
- data/manual/outline/insert_section_after.rb +19 -20
- data/manual/outline/outline.rb +23 -22
- data/manual/outline/sections_and_pages.rb +24 -25
- data/manual/repeatable_content/alternate_page_numbering.rb +36 -0
- data/manual/repeatable_content/page_numbering.rb +20 -19
- data/manual/repeatable_content/repeatable_content.rb +26 -22
- data/manual/repeatable_content/repeater.rb +18 -19
- data/manual/repeatable_content/stamp.rb +18 -19
- data/manual/security/encryption.rb +8 -11
- data/manual/security/permissions.rb +20 -15
- data/manual/security/security.rb +20 -20
- data/manual/table.rb +16 -0
- data/manual/text/alignment.rb +17 -18
- data/manual/text/color.rb +13 -13
- data/manual/text/column_box.rb +10 -12
- data/manual/text/fallback_fonts.rb +29 -25
- data/manual/text/font.rb +17 -18
- data/manual/text/font_size.rb +21 -22
- data/manual/text/font_style.rb +12 -10
- data/manual/text/formatted_callbacks.rb +36 -26
- data/manual/text/formatted_text.rb +41 -34
- data/manual/text/free_flowing_text.rb +28 -29
- data/manual/text/inline.rb +23 -26
- data/manual/text/kerning_and_character_spacing.rb +20 -21
- data/manual/text/leading.rb +10 -11
- data/manual/text/line_wrapping.rb +40 -21
- data/manual/text/paragraph_indentation.rb +17 -12
- data/manual/text/positioned_text.rb +19 -20
- data/manual/text/registering_families.rb +33 -30
- data/manual/text/rendering_and_color.rb +11 -12
- data/manual/text/right_to_left_text.rb +31 -20
- data/manual/text/rotation.rb +36 -27
- data/manual/text/single_usage.rb +13 -14
- data/manual/text/text.rb +62 -62
- data/manual/text/text_box_excess.rb +22 -19
- data/manual/text/text_box_extensions.rb +21 -18
- data/manual/text/text_box_overflow.rb +28 -21
- data/manual/text/utf8.rb +16 -17
- data/manual/text/win_ansi_charset.rb +29 -26
- data/prawn.gemspec +45 -43
- data/spec/extensions/encoding_helpers.rb +4 -3
- data/spec/prawn/document/bounding_box_spec.rb +550 -0
- data/spec/prawn/document/column_box_spec.rb +75 -0
- data/spec/prawn/document/security_spec.rb +176 -0
- data/spec/prawn/document_annotations_spec.rb +76 -0
- data/spec/prawn/document_destinations_spec.rb +15 -0
- data/spec/prawn/document_grid_spec.rb +99 -0
- data/spec/prawn/document_reference_spec.rb +27 -0
- data/spec/prawn/document_span_spec.rb +44 -0
- data/spec/prawn/document_spec.rb +805 -0
- data/spec/prawn/font_metric_cache_spec.rb +54 -0
- data/spec/prawn/font_spec.rb +544 -0
- data/spec/prawn/graphics/blend_mode_spec.rb +63 -0
- data/spec/prawn/graphics/transparency_spec.rb +81 -0
- data/spec/prawn/graphics_spec.rb +872 -0
- data/spec/prawn/graphics_stroke_styles_spec.rb +229 -0
- data/spec/prawn/image_handler_spec.rb +53 -0
- data/spec/prawn/images/jpg_spec.rb +20 -0
- data/spec/prawn/images/png_spec.rb +283 -0
- data/spec/prawn/images_spec.rb +229 -0
- data/spec/prawn/measurements_extensions_spec.rb +24 -0
- data/spec/prawn/outline_spec.rb +512 -0
- data/spec/prawn/repeater_spec.rb +166 -0
- data/spec/prawn/soft_mask_spec.rb +74 -0
- data/spec/prawn/stamp_spec.rb +173 -0
- data/spec/prawn/text/box_spec.rb +1110 -0
- data/spec/prawn/text/formatted/arranger_spec.rb +466 -0
- data/spec/prawn/text/formatted/box_spec.rb +849 -0
- data/spec/prawn/text/formatted/fragment_spec.rb +343 -0
- data/spec/prawn/text/formatted/line_wrap_spec.rb +495 -0
- data/spec/prawn/text/formatted/parser_spec.rb +697 -0
- data/spec/prawn/text_draw_text_spec.rb +150 -0
- data/spec/prawn/text_rendering_mode_spec.rb +48 -0
- data/spec/prawn/text_spacing_spec.rb +95 -0
- data/spec/prawn/text_spec.rb +603 -0
- data/spec/prawn/text_with_inline_formatting_spec.rb +35 -0
- data/spec/prawn/transformation_stack_spec.rb +66 -0
- data/spec/prawn/view_spec.rb +63 -0
- data/spec/prawn_manual_spec.rb +35 -0
- data/spec/spec_helper.rb +22 -21
- data.tar.gz.sig +0 -0
- metadata +168 -307
- metadata.gz.sig +0 -0
- data/README.md +0 -109
- data/data/encodings/win_ansi.txt +0 -29
- data/data/images/16bit.alpha +0 -0
- data/data/images/16bit.dat +0 -0
- data/data/images/16bit.png +0 -0
- data/data/images/arrow.png +0 -0
- data/data/images/arrow2.png +0 -0
- data/data/images/barcode_issue.png +0 -0
- data/data/images/dice.alpha +0 -0
- data/data/images/dice.dat +0 -0
- data/data/images/dice.png +0 -0
- data/data/images/dice_interlaced.png +0 -0
- data/data/images/indexed_color.dat +0 -0
- data/data/images/indexed_color.png +0 -0
- data/data/images/letterhead.jpg +0 -0
- data/data/images/page_white_text.alpha +0 -0
- data/data/images/page_white_text.dat +0 -0
- data/data/images/page_white_text.png +0 -0
- data/data/images/pigs.jpg +0 -0
- data/data/images/prawn.png +0 -0
- data/data/images/ruport.png +0 -0
- data/data/images/ruport_data.dat +0 -0
- data/data/images/ruport_transparent.png +0 -0
- data/data/images/ruport_type0.png +0 -0
- data/data/images/stef.jpg +0 -0
- data/data/images/tru256.bmp +0 -0
- data/data/images/web-links.dat +0 -1
- data/data/images/web-links.png +0 -0
- data/data/pdfs/complex_template.pdf +0 -0
- data/data/pdfs/contains_ttf_font.pdf +0 -0
- data/data/pdfs/encrypted.pdf +0 -0
- data/data/pdfs/form.pdf +1 -819
- data/data/pdfs/hexagon.pdf +0 -61
- data/data/pdfs/indirect_reference.pdf +0 -86
- data/data/pdfs/multipage_template.pdf +0 -127
- data/data/pdfs/nested_pages.pdf +0 -118
- data/data/pdfs/page_without_mediabox.pdf +0 -193
- data/data/pdfs/resources_as_indirect_object.pdf +0 -83
- data/data/pdfs/two_hexagons.pdf +0 -90
- data/data/pdfs/version_1_6.pdf +0 -61
- data/data/shift_jis_text.txt +0 -1
- data/lib/pdf/core/annotations.rb +0 -60
- data/lib/pdf/core/byte_string.rb +0 -9
- data/lib/pdf/core/destinations.rb +0 -90
- data/lib/pdf/core/document_state.rb +0 -78
- data/lib/pdf/core/filter_list.rb +0 -51
- data/lib/pdf/core/filters.rb +0 -36
- data/lib/pdf/core/graphics_state.rb +0 -68
- data/lib/pdf/core/literal_string.rb +0 -16
- data/lib/pdf/core/name_tree.rb +0 -177
- data/lib/pdf/core/object_store.rb +0 -320
- data/lib/pdf/core/outline.rb +0 -315
- data/lib/pdf/core/page.rb +0 -212
- data/lib/pdf/core/page_geometry.rb +0 -126
- data/lib/pdf/core/pdf_object.rb +0 -124
- data/lib/pdf/core/reference.rb +0 -103
- data/lib/pdf/core/stream.rb +0 -98
- data/lib/pdf/core/text.rb +0 -275
- data/lib/pdf/core.rb +0 -35
- data/lib/prawn/compatibility.rb +0 -91
- data/lib/prawn/document/graphics_state.rb +0 -73
- data/lib/prawn/document/snapshot.rb +0 -89
- data/lib/prawn/font/afm.rb +0 -203
- data/lib/prawn/layout.rb +0 -20
- data/lib/prawn/table/cell/image.rb +0 -70
- data/lib/prawn/table/cell/in_table.rb +0 -27
- data/lib/prawn/table/cell/span_dummy.rb +0 -92
- data/lib/prawn/table/cell/subtable.rb +0 -65
- data/lib/prawn/table/cell/text.rb +0 -153
- data/lib/prawn/table/cell.rb +0 -770
- data/lib/prawn/table/cells.rb +0 -295
- data/lib/prawn/table.rb +0 -643
- data/manual/example_file.rb +0 -116
- data/manual/example_package.rb +0 -53
- data/manual/example_section.rb +0 -46
- data/manual/manual/cover.rb +0 -35
- data/manual/manual/foreword.rb +0 -85
- data/manual/manual/manual.rb +0 -35
- data/manual/syntax_highlight.rb +0 -52
- data/manual/table/basic_block.rb +0 -53
- data/manual/table/before_rendering_page.rb +0 -26
- data/manual/table/cell_border_lines.rb +0 -24
- data/manual/table/cell_borders_and_bg.rb +0 -31
- data/manual/table/cell_dimensions.rb +0 -30
- data/manual/table/cell_text.rb +0 -38
- data/manual/table/column_widths.rb +0 -30
- data/manual/table/content_and_subtables.rb +0 -39
- data/manual/table/creation.rb +0 -27
- data/manual/table/filtering.rb +0 -36
- data/manual/table/flow_and_header.rb +0 -17
- data/manual/table/image_cells.rb +0 -33
- data/manual/table/position.rb +0 -29
- data/manual/table/row_colors.rb +0 -20
- data/manual/table/span.rb +0 -30
- data/manual/table/style.rb +0 -22
- data/manual/table/table.rb +0 -52
- data/manual/table/width.rb +0 -27
- data/manual/templates/full_template.rb +0 -25
- data/manual/templates/page_template.rb +0 -48
- data/manual/templates/templates.rb +0 -27
- data/manual/text/group.rb +0 -29
- data/spec/acceptance/png.rb +0 -23
- data/spec/annotations_spec.rb +0 -74
- data/spec/bounding_box_spec.rb +0 -493
- data/spec/cell_spec.rb +0 -628
- data/spec/column_box_spec.rb +0 -33
- data/spec/destinations_spec.rb +0 -15
- data/spec/document_spec.rb +0 -761
- data/spec/extensions/mocha.rb +0 -44
- data/spec/filters_spec.rb +0 -34
- data/spec/font_metric_cache_spec.rb +0 -52
- data/spec/font_spec.rb +0 -464
- data/spec/formatted_text_arranger_spec.rb +0 -421
- data/spec/formatted_text_box_spec.rb +0 -650
- data/spec/formatted_text_fragment_spec.rb +0 -298
- data/spec/graphics_spec.rb +0 -651
- data/spec/grid_spec.rb +0 -85
- data/spec/image_handler_spec.rb +0 -42
- data/spec/images_spec.rb +0 -157
- data/spec/inline_formatted_text_parser_spec.rb +0 -564
- data/spec/jpg_spec.rb +0 -25
- data/spec/line_wrap_spec.rb +0 -333
- data/spec/measurement_units_spec.rb +0 -23
- data/spec/name_tree_spec.rb +0 -112
- data/spec/object_store_spec.rb +0 -170
- data/spec/outline_spec.rb +0 -448
- data/spec/pdf_object_spec.rb +0 -172
- data/spec/png_spec.rb +0 -240
- data/spec/reference_spec.rb +0 -82
- data/spec/repeater_spec.rb +0 -158
- data/spec/security_spec.rb +0 -158
- data/spec/snapshot_spec.rb +0 -186
- data/spec/soft_mask_spec.rb +0 -117
- data/spec/span_spec.rb +0 -44
- data/spec/stamp_spec.rb +0 -158
- data/spec/stream_spec.rb +0 -58
- data/spec/stroke_styles_spec.rb +0 -211
- data/spec/table/span_dummy_spec.rb +0 -17
- data/spec/table_spec.rb +0 -1355
- data/spec/template_spec.rb +0 -351
- data/spec/text_at_spec.rb +0 -130
- data/spec/text_box_spec.rb +0 -1030
- data/spec/text_rendering_mode_spec.rb +0 -45
- data/spec/text_spacing_spec.rb +0 -93
- data/spec/text_spec.rb +0 -425
- data/spec/text_with_inline_formatting_spec.rb +0 -35
- data/spec/transparency_spec.rb +0 -89
data/spec/cell_spec.rb
DELETED
@@ -1,628 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
|
4
|
-
|
5
|
-
module CellHelpers
|
6
|
-
|
7
|
-
# Build, but do not draw, a cell on @pdf.
|
8
|
-
def cell(options={})
|
9
|
-
at = options[:at] || [0, @pdf.cursor]
|
10
|
-
Prawn::Table::Cell::Text.new(@pdf, at, options)
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "Prawn::Table::Cell" do
|
16
|
-
before(:each) do
|
17
|
-
@pdf = Prawn::Document.new
|
18
|
-
end
|
19
|
-
|
20
|
-
describe "Prawn::Document#cell" do
|
21
|
-
include CellHelpers
|
22
|
-
|
23
|
-
it "should draw the cell" do
|
24
|
-
Prawn::Table::Cell::Text.any_instance.expects(:draw).once
|
25
|
-
@pdf.cell(:content => "text")
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should return a Cell" do
|
29
|
-
@pdf.cell(:content => "text").should be_a_kind_of Prawn::Table::Cell
|
30
|
-
end
|
31
|
-
|
32
|
-
it "accepts :content => nil in a hash" do
|
33
|
-
@pdf.cell(:content => nil).should be_a_kind_of(Prawn::Table::Cell::Text)
|
34
|
-
@pdf.make_cell(:content => nil).should be_a_kind_of(Prawn::Table::Cell::Text)
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should convert nil, Numeric, and Date values to strings" do
|
38
|
-
[nil, 123, 123.45, Date.today].each do |value|
|
39
|
-
c = @pdf.cell(:content => value)
|
40
|
-
c.should be_a_kind_of Prawn::Table::Cell::Text
|
41
|
-
c.content.should == value.to_s
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should allow inline styling with a hash argument" do
|
46
|
-
# used for table([[{:text => "...", :font_style => :bold, ...}, ...]])
|
47
|
-
c = Prawn::Table::Cell.make(@pdf,
|
48
|
-
{:content => 'hello', :font_style => :bold})
|
49
|
-
c.should be_a_kind_of Prawn::Table::Cell::Text
|
50
|
-
c.content.should == "hello"
|
51
|
-
c.font.name.should == 'Helvetica-Bold'
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should draw text at the given point plus padding, with the given " +
|
55
|
-
"size and style" do
|
56
|
-
@pdf.expects(:bounding_box).yields
|
57
|
-
@pdf.expects(:move_down)
|
58
|
-
@pdf.expects(:draw_text!).with { |text, options| text == "hello world" }
|
59
|
-
|
60
|
-
@pdf.cell(:content => "hello world",
|
61
|
-
:at => [10, 20],
|
62
|
-
:padding => [30, 40],
|
63
|
-
:size => 7,
|
64
|
-
:font_style => :bold)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
describe "Prawn::Document#make_cell" do
|
69
|
-
it "should not draw the cell" do
|
70
|
-
Prawn::Table::Cell::Text.any_instance.expects(:draw).never
|
71
|
-
@pdf.make_cell("text")
|
72
|
-
end
|
73
|
-
|
74
|
-
it "should return a Cell" do
|
75
|
-
@pdf.make_cell("text", :size => 7).should be_a_kind_of Prawn::Table::Cell
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe "#style" do
|
80
|
-
include CellHelpers
|
81
|
-
|
82
|
-
it "should set each property in turn" do
|
83
|
-
c = cell(:content => "text")
|
84
|
-
|
85
|
-
c.expects(:padding=).with(50)
|
86
|
-
c.expects(:size=).with(7)
|
87
|
-
|
88
|
-
c.style(:padding => 50, :size => 7)
|
89
|
-
end
|
90
|
-
|
91
|
-
it "ignores unknown properties" do
|
92
|
-
c = cell(:content => 'text')
|
93
|
-
|
94
|
-
c.style(:foobarbaz => 'frobnitz')
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
describe "cell width" do
|
99
|
-
include CellHelpers
|
100
|
-
|
101
|
-
it "should be calculated for text" do
|
102
|
-
c = cell(:content => "text")
|
103
|
-
c.width.should == @pdf.width_of("text") + c.padding[1] + c.padding[3]
|
104
|
-
end
|
105
|
-
|
106
|
-
it "should be overridden by manual :width" do
|
107
|
-
c = cell(:content => "text", :width => 400)
|
108
|
-
c.width.should == 400
|
109
|
-
end
|
110
|
-
|
111
|
-
it "should incorporate padding when specified" do
|
112
|
-
c = cell(:content => "text", :padding => [1, 2, 3, 4])
|
113
|
-
c.width.should be_within(0.01).of(@pdf.width_of("text") + 6)
|
114
|
-
end
|
115
|
-
|
116
|
-
it "should allow width to be reset after it has been calculated" do
|
117
|
-
# to ensure that if we memoize width, it can still be overridden
|
118
|
-
c = cell(:content => "text")
|
119
|
-
c.width
|
120
|
-
c.width = 400
|
121
|
-
c.width.should == 400
|
122
|
-
end
|
123
|
-
|
124
|
-
it "should return proper width with size set" do
|
125
|
-
text = "text " * 4
|
126
|
-
c = cell(:content => text, :size => 7)
|
127
|
-
c.width.should ==
|
128
|
-
@pdf.width_of(text, :size => 7) + c.padding[1] + c.padding[3]
|
129
|
-
end
|
130
|
-
|
131
|
-
it "content_width should exclude padding" do
|
132
|
-
c = cell(:content => "text", :padding => 10)
|
133
|
-
c.content_width.should == @pdf.width_of("text")
|
134
|
-
end
|
135
|
-
|
136
|
-
it "content_width should exclude padding even with manual :width" do
|
137
|
-
c = cell(:content => "text", :padding => 10, :width => 400)
|
138
|
-
c.content_width.should be_within(0.01).of(380)
|
139
|
-
end
|
140
|
-
|
141
|
-
it "should have a reasonable minimum width that can fit @content" do
|
142
|
-
c = cell(:content => "text", :padding => 10)
|
143
|
-
min_content_width = c.min_width - c.padding[1] - c.padding[3]
|
144
|
-
|
145
|
-
@pdf.height_of("text", :width => min_content_width).should be <
|
146
|
-
(5 * @pdf.height_of("text"))
|
147
|
-
end
|
148
|
-
|
149
|
-
it "should defer min_width's evaluation of padding" do
|
150
|
-
c = cell(:content => "text", :padding => 100)
|
151
|
-
c.padding = 0
|
152
|
-
|
153
|
-
# Make sure we use the new value of padding in calculating min_width
|
154
|
-
c.min_width.should be < 100
|
155
|
-
end
|
156
|
-
|
157
|
-
it "should defer min_width's evaluation of size" do
|
158
|
-
c = cell(:content => "text", :size => 50)
|
159
|
-
c.size = 8
|
160
|
-
c.padding = 0
|
161
|
-
c.min_width.should be < 10
|
162
|
-
end
|
163
|
-
|
164
|
-
end
|
165
|
-
|
166
|
-
describe "cell height" do
|
167
|
-
include CellHelpers
|
168
|
-
|
169
|
-
it "should be calculated for text" do
|
170
|
-
c = cell(:content => "text")
|
171
|
-
c.height.should ==
|
172
|
-
@pdf.height_of("text", :width => @pdf.width_of("text")) +
|
173
|
-
c.padding[0] + c.padding[3]
|
174
|
-
end
|
175
|
-
|
176
|
-
it "should be overridden by manual :height" do
|
177
|
-
c = cell(:content => "text", :height => 400)
|
178
|
-
c.height.should == 400
|
179
|
-
end
|
180
|
-
|
181
|
-
it "should incorporate :padding when specified" do
|
182
|
-
c = cell(:content => "text", :padding => [1, 2, 3, 4])
|
183
|
-
c.height.should be_within(0.01).of(1 + 3 +
|
184
|
-
@pdf.height_of("text", :width => @pdf.width_of("text")))
|
185
|
-
end
|
186
|
-
|
187
|
-
it "should allow height to be reset after it has been calculated" do
|
188
|
-
# to ensure that if we memoize height, it can still be overridden
|
189
|
-
c = cell(:content => "text")
|
190
|
-
c.height
|
191
|
-
c.height = 400
|
192
|
-
c.height.should == 400
|
193
|
-
end
|
194
|
-
|
195
|
-
it "should return proper height for blocks of text" do
|
196
|
-
content = "words " * 10
|
197
|
-
c = cell(:content => content, :width => 100)
|
198
|
-
c.height.should == @pdf.height_of(content, :width => 100) +
|
199
|
-
c.padding[0] + c.padding[2]
|
200
|
-
end
|
201
|
-
|
202
|
-
it "should return proper height for blocks of text with size set" do
|
203
|
-
content = "words " * 10
|
204
|
-
c = cell(:content => content, :width => 100, :size => 7)
|
205
|
-
|
206
|
-
correct_content_height = nil
|
207
|
-
@pdf.font_size(7) do
|
208
|
-
correct_content_height = @pdf.height_of(content, :width => 100)
|
209
|
-
end
|
210
|
-
|
211
|
-
c.height.should == correct_content_height + c.padding[0] + c.padding[2]
|
212
|
-
end
|
213
|
-
|
214
|
-
it "content_height should exclude padding" do
|
215
|
-
c = cell(:content => "text", :padding => 10)
|
216
|
-
c.content_height.should == @pdf.height_of("text")
|
217
|
-
end
|
218
|
-
|
219
|
-
it "content_height should exclude padding even with manual :height" do
|
220
|
-
c = cell(:content => "text", :padding => 10, :height => 400)
|
221
|
-
c.content_height.should be_within(0.01).of(380)
|
222
|
-
end
|
223
|
-
end
|
224
|
-
|
225
|
-
describe "cell padding" do
|
226
|
-
include CellHelpers
|
227
|
-
|
228
|
-
it "should default to zero" do
|
229
|
-
c = cell(:content => "text")
|
230
|
-
c.padding.should == [5, 5, 5, 5]
|
231
|
-
end
|
232
|
-
|
233
|
-
it "should accept a numeric value, setting all padding" do
|
234
|
-
c = cell(:content => "text", :padding => 10)
|
235
|
-
c.padding.should == [10, 10, 10, 10]
|
236
|
-
end
|
237
|
-
|
238
|
-
it "should accept [v,h]" do
|
239
|
-
c = cell(:content => "text", :padding => [20, 30])
|
240
|
-
c.padding.should == [20, 30, 20, 30]
|
241
|
-
end
|
242
|
-
|
243
|
-
it "should accept [t,h,b]" do
|
244
|
-
c = cell(:content => "text", :padding => [10, 20, 30])
|
245
|
-
c.padding.should == [10, 20, 30, 20]
|
246
|
-
end
|
247
|
-
|
248
|
-
it "should accept [t,l,b,r]" do
|
249
|
-
c = cell(:content => "text", :padding => [10, 20, 30, 40])
|
250
|
-
c.padding.should == [10, 20, 30, 40]
|
251
|
-
end
|
252
|
-
|
253
|
-
it "should reject other formats" do
|
254
|
-
lambda{
|
255
|
-
cell(:content => "text", :padding => [10])
|
256
|
-
}.should raise_error(ArgumentError)
|
257
|
-
end
|
258
|
-
end
|
259
|
-
|
260
|
-
describe "background_color" do
|
261
|
-
include CellHelpers
|
262
|
-
|
263
|
-
it "should fill a rectangle with the given background color" do
|
264
|
-
@pdf.stubs(:mask).yields
|
265
|
-
@pdf.expects(:mask).with(:fill_color).yields
|
266
|
-
|
267
|
-
@pdf.stubs(:fill_color)
|
268
|
-
@pdf.expects(:fill_color).with('123456')
|
269
|
-
@pdf.expects(:fill_rectangle).checking do |(x, y), w, h|
|
270
|
-
x.should be_within(0.01).of(0)
|
271
|
-
y.should be_within(0.01).of(@pdf.cursor)
|
272
|
-
w.should be_within(0.01).of(29.344)
|
273
|
-
h.should be_within(0.01).of(23.872)
|
274
|
-
end
|
275
|
-
@pdf.cell(:content => "text", :background_color => '123456')
|
276
|
-
end
|
277
|
-
|
278
|
-
it "should draw the background in the right place if cell is drawn at a " +
|
279
|
-
"different location" do
|
280
|
-
@pdf.stubs(:mask).yields
|
281
|
-
@pdf.expects(:mask).with(:fill_color).yields
|
282
|
-
|
283
|
-
@pdf.stubs(:fill_color)
|
284
|
-
@pdf.expects(:fill_color).with('123456')
|
285
|
-
@pdf.expects(:fill_rectangle).checking do |(x, y), w, h|
|
286
|
-
x.should be_within(0.01).of(12.0)
|
287
|
-
y.should be_within(0.01).of(34.0)
|
288
|
-
w.should be_within(0.01).of(29.344)
|
289
|
-
h.should be_within(0.01).of(23.872)
|
290
|
-
end
|
291
|
-
c = @pdf.make_cell(:content => "text", :background_color => '123456')
|
292
|
-
c.draw([12.0, 34.0])
|
293
|
-
end
|
294
|
-
end
|
295
|
-
|
296
|
-
describe "color" do
|
297
|
-
it "should set fill color when :text_color is provided" do
|
298
|
-
pdf = Prawn::Document.new
|
299
|
-
pdf.stubs(:fill_color)
|
300
|
-
pdf.expects(:fill_color).with('555555')
|
301
|
-
pdf.cell :content => 'foo', :text_color => '555555'
|
302
|
-
end
|
303
|
-
|
304
|
-
it "should reset the fill color to the original one" do
|
305
|
-
pdf = Prawn::Document.new
|
306
|
-
pdf.fill_color = '333333'
|
307
|
-
pdf.cell :content => 'foo', :text_color => '555555'
|
308
|
-
pdf.fill_color.should == '333333'
|
309
|
-
end
|
310
|
-
end
|
311
|
-
|
312
|
-
describe "Borders" do
|
313
|
-
it "should draw all borders by default" do
|
314
|
-
@pdf.expects(:stroke_line).times(4)
|
315
|
-
@pdf.cell(:content => "text")
|
316
|
-
end
|
317
|
-
|
318
|
-
it "should draw all borders when requested" do
|
319
|
-
@pdf.expects(:stroke_line).times(4)
|
320
|
-
@pdf.cell(:content => "text", :borders => [:top, :right, :bottom, :left])
|
321
|
-
end
|
322
|
-
|
323
|
-
# Only roughly verifying the integer coordinates so that we don't have to
|
324
|
-
# do any FP closeness arithmetic. Can plug in that math later if this goes
|
325
|
-
# wrong.
|
326
|
-
it "should draw top border when requested" do
|
327
|
-
@pdf.expects(:stroke_line).checking do |from, to|
|
328
|
-
@pdf.map_to_absolute(from).map{|x| x.round}.should == [36, 756]
|
329
|
-
@pdf.map_to_absolute(to).map{|x| x.round}.should == [65, 756]
|
330
|
-
end
|
331
|
-
@pdf.cell(:content => "text", :borders => [:top])
|
332
|
-
end
|
333
|
-
|
334
|
-
it "should draw bottom border when requested" do
|
335
|
-
@pdf.expects(:stroke_line).checking do |from, to|
|
336
|
-
@pdf.map_to_absolute(from).map{|x| x.round}.should == [36, 732]
|
337
|
-
@pdf.map_to_absolute(to).map{|x| x.round}.should == [65, 732]
|
338
|
-
end
|
339
|
-
@pdf.cell(:content => "text", :borders => [:bottom])
|
340
|
-
end
|
341
|
-
|
342
|
-
it "should draw left border when requested" do
|
343
|
-
@pdf.expects(:stroke_line).checking do |from, to|
|
344
|
-
@pdf.map_to_absolute(from).map{|x| x.round}.should == [36, 756]
|
345
|
-
@pdf.map_to_absolute(to).map{|x| x.round}.should == [36, 732]
|
346
|
-
end
|
347
|
-
@pdf.cell(:content => "text", :borders => [:left])
|
348
|
-
end
|
349
|
-
|
350
|
-
it "should draw right border when requested" do
|
351
|
-
@pdf.expects(:stroke_line).checking do |from, to|
|
352
|
-
@pdf.map_to_absolute(from).map{|x| x.round}.should == [65, 756]
|
353
|
-
@pdf.map_to_absolute(to).map{|x| x.round}.should == [65, 732]
|
354
|
-
end
|
355
|
-
@pdf.cell(:content => "text", :borders => [:right])
|
356
|
-
end
|
357
|
-
|
358
|
-
it "should draw borders at the same location when in or out of bbox" do
|
359
|
-
@pdf.expects(:stroke_line).checking do |from, to|
|
360
|
-
@pdf.map_to_absolute(from).map{|x| x.round}.should == [36, 756]
|
361
|
-
@pdf.map_to_absolute(to).map{|x| x.round}.should == [65, 756]
|
362
|
-
end
|
363
|
-
@pdf.bounding_box([0, @pdf.cursor], :width => @pdf.bounds.width) do
|
364
|
-
@pdf.cell(:content => "text", :borders => [:top])
|
365
|
-
end
|
366
|
-
end
|
367
|
-
|
368
|
-
it "should set border color with :border_..._color" do
|
369
|
-
@pdf.ignores(:stroke_color=).with("000000")
|
370
|
-
@pdf.expects(:stroke_color=).with("ff0000")
|
371
|
-
|
372
|
-
c = @pdf.cell(:content => "text", :border_top_color => "ff0000")
|
373
|
-
c.border_top_color.should == "ff0000"
|
374
|
-
c.border_colors[0].should == "ff0000"
|
375
|
-
end
|
376
|
-
|
377
|
-
it "should set border colors with :border_color" do
|
378
|
-
@pdf.ignores(:stroke_color=).with("000000")
|
379
|
-
@pdf.expects(:stroke_color=).with("ff0000")
|
380
|
-
@pdf.expects(:stroke_color=).with("00ff00")
|
381
|
-
@pdf.expects(:stroke_color=).with("0000ff")
|
382
|
-
@pdf.expects(:stroke_color=).with("ff00ff")
|
383
|
-
|
384
|
-
c = @pdf.cell(:content => "text",
|
385
|
-
:border_color => %w[ff0000 00ff00 0000ff ff00ff])
|
386
|
-
|
387
|
-
c.border_colors.should == %w[ff0000 00ff00 0000ff ff00ff]
|
388
|
-
end
|
389
|
-
|
390
|
-
it "border_..._width should return 0 if border not selected" do
|
391
|
-
c = @pdf.cell(:content => "text", :borders => [:top])
|
392
|
-
c.border_bottom_width.should == 0
|
393
|
-
end
|
394
|
-
|
395
|
-
it "should set border width with :border_..._width" do
|
396
|
-
@pdf.ignores(:line_width=).with(1)
|
397
|
-
@pdf.expects(:line_width=).with(2)
|
398
|
-
|
399
|
-
c = @pdf.cell(:content => "text", :border_bottom_width => 2)
|
400
|
-
c.border_bottom_width.should == 2
|
401
|
-
c.border_widths[2].should == 2
|
402
|
-
end
|
403
|
-
|
404
|
-
it "should set border widths with :border_width" do
|
405
|
-
@pdf.ignores(:line_width=).with(1)
|
406
|
-
@pdf.expects(:line_width=).with(2)
|
407
|
-
@pdf.expects(:line_width=).with(3)
|
408
|
-
@pdf.expects(:line_width=).with(4)
|
409
|
-
@pdf.expects(:line_width=).with(5)
|
410
|
-
|
411
|
-
c = @pdf.cell(:content => "text",
|
412
|
-
:border_width => [2, 3, 4, 5])
|
413
|
-
c.border_widths.should == [2, 3, 4, 5]
|
414
|
-
end
|
415
|
-
|
416
|
-
it "should set default border lines to :solid" do
|
417
|
-
c = @pdf.cell(:content => "text")
|
418
|
-
c.border_top_line.should == :solid
|
419
|
-
c.border_right_line.should == :solid
|
420
|
-
c.border_bottom_line.should == :solid
|
421
|
-
c.border_left_line.should == :solid
|
422
|
-
c.border_lines.should == [:solid] * 4
|
423
|
-
end
|
424
|
-
|
425
|
-
it "should set border line with :border_..._line" do
|
426
|
-
c = @pdf.cell(:content => "text", :border_bottom_line => :dotted)
|
427
|
-
c.border_bottom_line.should == :dotted
|
428
|
-
c.border_lines[2].should == :dotted
|
429
|
-
end
|
430
|
-
|
431
|
-
it "should set border lines with :border_lines" do
|
432
|
-
c = @pdf.cell(:content => "text",
|
433
|
-
:border_lines => [:solid, :dotted, :dashed, :solid])
|
434
|
-
c.border_lines.should == [:solid, :dotted, :dashed, :solid]
|
435
|
-
end
|
436
|
-
end
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
describe "Text cell attributes" do
|
444
|
-
include CellHelpers
|
445
|
-
|
446
|
-
it "should pass through text options like :align to Text::Box" do
|
447
|
-
c = cell(:content => "text", :align => :right)
|
448
|
-
|
449
|
-
box = Prawn::Text::Box.new("text", :document => @pdf)
|
450
|
-
|
451
|
-
Prawn::Text::Box.expects(:new).checking do |text, options|
|
452
|
-
text.should == "text"
|
453
|
-
options[:align].should == :right
|
454
|
-
end.at_least_once.returns(box)
|
455
|
-
|
456
|
-
c.draw
|
457
|
-
end
|
458
|
-
|
459
|
-
it "should use font_style for Text::Box#style" do
|
460
|
-
c = cell(:content => "text", :font_style => :bold)
|
461
|
-
|
462
|
-
box = Prawn::Text::Box.new("text", :document => @pdf)
|
463
|
-
|
464
|
-
Prawn::Text::Box.expects(:new).checking do |text, options|
|
465
|
-
text.should == "text"
|
466
|
-
options[:style].should == :bold
|
467
|
-
end.at_least_once.returns(box)
|
468
|
-
|
469
|
-
c.draw
|
470
|
-
end
|
471
|
-
|
472
|
-
it "supports variant styles of the current font" do
|
473
|
-
font_path = "#{Prawn::BASEDIR}/data/fonts/Action Man.dfont"
|
474
|
-
@pdf.font_families.merge!("Action Man" => {
|
475
|
-
:normal => { :file => font_path, :font => "ActionMan" },
|
476
|
-
:bold => { :file => font_path, :font => "ActionMan-Bold" },
|
477
|
-
})
|
478
|
-
@pdf.font "Action Man"
|
479
|
-
|
480
|
-
c = cell(:content => "text", :font_style => :bold)
|
481
|
-
|
482
|
-
box = Prawn::Text::Box.new("text", :document => @pdf)
|
483
|
-
Prawn::Text::Box.expects(:new).checking do |text, options|
|
484
|
-
text.should == "text"
|
485
|
-
options[:style].should == :bold
|
486
|
-
@pdf.font.family.should == 'Action Man'
|
487
|
-
end.at_least_once.returns(box)
|
488
|
-
|
489
|
-
c.draw
|
490
|
-
end
|
491
|
-
|
492
|
-
|
493
|
-
it "uses the style of the current font if none given" do
|
494
|
-
font_path = "#{Prawn::BASEDIR}/data/fonts/Action Man.dfont"
|
495
|
-
@pdf.font_families.merge!("Action Man" => {
|
496
|
-
:normal => { :file => font_path, :font => "ActionMan" },
|
497
|
-
:bold => { :file => font_path, :font => "ActionMan-Bold" },
|
498
|
-
})
|
499
|
-
@pdf.font "Action Man", :style => :bold
|
500
|
-
|
501
|
-
c = cell(:content => "text")
|
502
|
-
|
503
|
-
box = Prawn::Text::Box.new("text", :document => @pdf)
|
504
|
-
Prawn::Text::Box.expects(:new).checking do |text, options|
|
505
|
-
text.should == "text"
|
506
|
-
@pdf.font.family.should == 'Action Man'
|
507
|
-
@pdf.font.options[:style].should == :bold
|
508
|
-
end.at_least_once.returns(box)
|
509
|
-
|
510
|
-
c.draw
|
511
|
-
end
|
512
|
-
|
513
|
-
it "should allow inline formatting in cells" do
|
514
|
-
c = cell(:content => "foo <b>bar</b> baz", :inline_format => true)
|
515
|
-
|
516
|
-
box = Prawn::Text::Formatted::Box.new([], :document => @pdf)
|
517
|
-
|
518
|
-
Prawn::Text::Formatted::Box.expects(:new).checking do |array, options|
|
519
|
-
array[0][:text].should == "foo "
|
520
|
-
array[0][:styles].should == []
|
521
|
-
|
522
|
-
array[1][:text].should == "bar"
|
523
|
-
array[1][:styles].should == [:bold]
|
524
|
-
|
525
|
-
array[2][:text].should == " baz"
|
526
|
-
array[2][:styles].should == []
|
527
|
-
end.at_least_once.returns(box)
|
528
|
-
|
529
|
-
c.draw
|
530
|
-
end
|
531
|
-
|
532
|
-
end
|
533
|
-
|
534
|
-
describe "Font handling" do
|
535
|
-
include CellHelpers
|
536
|
-
|
537
|
-
it "should allow only :font_style to be specified, defaulting to the " +
|
538
|
-
"document's font" do
|
539
|
-
c = cell(:content => "text", :font_style => :bold)
|
540
|
-
c.font.name.should == 'Helvetica-Bold'
|
541
|
-
end
|
542
|
-
|
543
|
-
it "should accept a font name for :font" do
|
544
|
-
c = cell(:content => "text", :font => 'Helvetica-Bold')
|
545
|
-
c.font.name.should == 'Helvetica-Bold'
|
546
|
-
end
|
547
|
-
|
548
|
-
it "should allow style to be changed after initialize" do
|
549
|
-
c = cell(:content => "text")
|
550
|
-
c.font_style = :bold
|
551
|
-
c.font.name.should == 'Helvetica-Bold'
|
552
|
-
end
|
553
|
-
|
554
|
-
it "should default to the document's font, if none is specified" do
|
555
|
-
c = cell(:content => "text")
|
556
|
-
c.font.should == @pdf.font
|
557
|
-
end
|
558
|
-
|
559
|
-
it "should use the metrics of the selected font (even if it is a variant " +
|
560
|
-
"of the document's font) to calculate width" do
|
561
|
-
c = cell(:content => "text", :font_style => :bold)
|
562
|
-
font = @pdf.find_font('Helvetica-Bold')
|
563
|
-
c.content_width.should == font.compute_width_of("text")
|
564
|
-
end
|
565
|
-
|
566
|
-
it "should properly calculate inline-formatted text" do
|
567
|
-
c = cell(:content => "<b>text</b>", :inline_format => true)
|
568
|
-
font = @pdf.find_font('Helvetica-Bold')
|
569
|
-
c.content_width.should == font.compute_width_of("text")
|
570
|
-
end
|
571
|
-
end
|
572
|
-
end
|
573
|
-
|
574
|
-
describe "Image cells" do
|
575
|
-
before(:each) do
|
576
|
-
create_pdf
|
577
|
-
end
|
578
|
-
|
579
|
-
describe "with default options" do
|
580
|
-
before(:each) do
|
581
|
-
@cell = Prawn::Table::Cell.make(@pdf,
|
582
|
-
:image => "#{Prawn::DATADIR}/images/prawn.png")
|
583
|
-
end
|
584
|
-
|
585
|
-
it "should create a Cell::Image" do
|
586
|
-
@cell.should be_a_kind_of(Prawn::Table::Cell::Image)
|
587
|
-
end
|
588
|
-
|
589
|
-
it "should pull the natural width and height from the image" do
|
590
|
-
@cell.natural_content_width.should == 141
|
591
|
-
@cell.natural_content_height.should == 142
|
592
|
-
end
|
593
|
-
end
|
594
|
-
|
595
|
-
describe "hash syntax" do
|
596
|
-
before(:each) do
|
597
|
-
@table = @pdf.make_table([[{
|
598
|
-
:image => "#{Prawn::DATADIR}/images/prawn.png",
|
599
|
-
:scale => 2,
|
600
|
-
:fit => [100, 200],
|
601
|
-
:image_width => 123,
|
602
|
-
:image_height => 456,
|
603
|
-
:position => :center,
|
604
|
-
:vposition => :center
|
605
|
-
}]])
|
606
|
-
@cell = @table.cells[0, 0]
|
607
|
-
end
|
608
|
-
|
609
|
-
|
610
|
-
it "should create a Cell::Image" do
|
611
|
-
@cell.should be_a_kind_of(Prawn::Table::Cell::Image)
|
612
|
-
end
|
613
|
-
|
614
|
-
it "should pass through image options" do
|
615
|
-
@pdf.expects(:embed_image).checking do |_, _, options|
|
616
|
-
options[:scale].should == 2
|
617
|
-
options[:fit].should == [100, 200]
|
618
|
-
options[:width].should == 123
|
619
|
-
options[:height].should == 456
|
620
|
-
options[:position].should == :center
|
621
|
-
options[:vposition].should == :center
|
622
|
-
end
|
623
|
-
|
624
|
-
@table.draw
|
625
|
-
end
|
626
|
-
end
|
627
|
-
|
628
|
-
end
|
data/spec/column_box_spec.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
|
4
|
-
|
5
|
-
describe "A column box" do
|
6
|
-
it "has sensible left and right values" do
|
7
|
-
create_pdf
|
8
|
-
@pdf.column_box [0, @pdf.cursor], :width => @pdf.bounds.width,
|
9
|
-
:height => 200, :columns => 3, :spacer => 25 do
|
10
|
-
left = @pdf.bounds.left
|
11
|
-
right = @pdf.bounds.right
|
12
|
-
|
13
|
-
@pdf.bounds.move_past_bottom # next column
|
14
|
-
|
15
|
-
@pdf.bounds.left.should be > left
|
16
|
-
@pdf.bounds.left.should be > right
|
17
|
-
@pdf.bounds.right.should be > @pdf.bounds.left
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
it "includes spacers between columns but not at the end" do
|
22
|
-
create_pdf
|
23
|
-
@pdf.column_box [0, @pdf.cursor], :width => 500,
|
24
|
-
:height => 200, :columns => 3, :spacer => 25 do
|
25
|
-
@pdf.bounds.width.should == 150 # (500 - (25 * 2)) / 3
|
26
|
-
|
27
|
-
@pdf.bounds.move_past_bottom
|
28
|
-
@pdf.bounds.move_past_bottom
|
29
|
-
|
30
|
-
@pdf.bounds.right.should == 500
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
data/spec/destinations_spec.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
|
4
|
-
|
5
|
-
describe "When creating destinations" do
|
6
|
-
|
7
|
-
before(:each) { create_pdf }
|
8
|
-
|
9
|
-
it "should add entry to Dests name tree" do
|
10
|
-
@pdf.dests.data.empty?.should == true
|
11
|
-
@pdf.add_dest "candy", "chocolate"
|
12
|
-
@pdf.dests.data.size.should == 1
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|