prawn-table-continued 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/COPYING +2 -0
  3. data/GPLv2 +340 -0
  4. data/GPLv3 +674 -0
  5. data/Gemfile +3 -0
  6. data/LICENSE +56 -0
  7. data/lib/prawn/table/cell/image.rb +69 -0
  8. data/lib/prawn/table/cell/in_table.rb +33 -0
  9. data/lib/prawn/table/cell/span_dummy.rb +93 -0
  10. data/lib/prawn/table/cell/subtable.rb +66 -0
  11. data/lib/prawn/table/cell/text.rb +155 -0
  12. data/lib/prawn/table/cell.rb +787 -0
  13. data/lib/prawn/table/cells.rb +261 -0
  14. data/lib/prawn/table/column_width_calculator.rb +182 -0
  15. data/lib/prawn/table/version.rb +5 -0
  16. data/lib/prawn/table.rb +711 -0
  17. data/manual/contents.rb +13 -0
  18. data/manual/example_helper.rb +8 -0
  19. data/manual/images/prawn.png +0 -0
  20. data/manual/images/stef.jpg +0 -0
  21. data/manual/table/basic_block.rb +53 -0
  22. data/manual/table/before_rendering_page.rb +26 -0
  23. data/manual/table/cell_border_lines.rb +24 -0
  24. data/manual/table/cell_borders_and_bg.rb +31 -0
  25. data/manual/table/cell_dimensions.rb +36 -0
  26. data/manual/table/cell_text.rb +38 -0
  27. data/manual/table/column_widths.rb +30 -0
  28. data/manual/table/content_and_subtables.rb +39 -0
  29. data/manual/table/creation.rb +27 -0
  30. data/manual/table/filtering.rb +36 -0
  31. data/manual/table/flow_and_header.rb +17 -0
  32. data/manual/table/image_cells.rb +33 -0
  33. data/manual/table/position.rb +29 -0
  34. data/manual/table/row_colors.rb +20 -0
  35. data/manual/table/span.rb +30 -0
  36. data/manual/table/style.rb +33 -0
  37. data/manual/table/table.rb +52 -0
  38. data/manual/table/width.rb +27 -0
  39. data/prawn-table.gemspec +36 -0
  40. data/spec/cell_spec.rb +652 -0
  41. data/spec/extensions/encoding_helpers.rb +11 -0
  42. data/spec/extensions/file_fixture_helper.rb +15 -0
  43. data/spec/fixtures/files/prawn.png +0 -0
  44. data/spec/spec_helper.rb +50 -0
  45. data/spec/table/span_dummy_spec.rb +26 -0
  46. data/spec/table_spec.rb +1626 -0
  47. metadata +234 -0
@@ -0,0 +1,15 @@
1
+ require 'pathname'
2
+
3
+ module FileFixtureHelper
4
+ FIXTURES_PATH = Pathname.new(File.expand_path("../fixtures", __dir__)).freeze
5
+ FILE_FIXTURES_PATH = FIXTURES_PATH.join("files").freeze
6
+
7
+ def file_fixture(relative_path)
8
+ pathname = FILE_FIXTURES_PATH.join(relative_path)
9
+
10
+ raise ArgumentError, "File '#{pathname}' not found" unless pathname.file?
11
+
12
+ pathname
13
+ end
14
+ end
15
+
Binary file
@@ -0,0 +1,50 @@
1
+ # encoding: utf-8
2
+
3
+ puts "Prawn specs: Running on Ruby Version: #{RUBY_VERSION}"
4
+
5
+ require "bundler"
6
+ Bundler.setup
7
+
8
+ if ENV["COVERAGE"]
9
+ require "simplecov"
10
+ SimpleCov.start do
11
+ add_filter "/spec/"
12
+ end
13
+ end
14
+
15
+ require_relative "../lib/prawn/table"
16
+
17
+ Prawn.debug = true
18
+
19
+ require "rspec"
20
+ require "pdf/reader"
21
+ require "pdf/inspector"
22
+
23
+ # Requires supporting ruby files with custom matchers and macros, etc,
24
+ # in spec/extensions/ and its subdirectories.
25
+ Dir[File.dirname(__FILE__) + "/extensions/**/*.rb"].each {|f| require f }
26
+
27
+ RSpec.configure do |config|
28
+ config.include EncodingHelpers
29
+ config.include FileFixtureHelper
30
+ end
31
+
32
+ def create_pdf(klass=Prawn::Document)
33
+ @pdf = klass.new(:margin => 0)
34
+ end
35
+
36
+ RSpec::Matchers.define :have_parseable_xobjects do
37
+ match do |actual|
38
+ expect { PDF::Inspector::XObject.analyze(actual.render) }.not_to raise_error
39
+ true
40
+ end
41
+ failure_message_for_should do |actual|
42
+ "expected that #{actual}'s XObjects could be successfully parsed"
43
+ end
44
+ end
45
+
46
+ # Make some methods public to assist in testing
47
+ module Prawn::Graphics
48
+ public :map_to_absolute
49
+ end
50
+
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+
3
+ require File.join(File.expand_path(File.dirname(__FILE__)), "..", "spec_helper")
4
+ require 'set'
5
+
6
+ describe "Prawn::Table::Cell::SpanDummy" do
7
+ before(:each) do
8
+ @pdf = Prawn::Document.new
9
+ @table = @pdf.table([
10
+ [{:content => "A1-2", :colspan => 2}, {:content => "A-B3", :rowspan => 2}],
11
+ [{:content => "B1-2", :colspan => 2}]
12
+ ], :row_colors => [nil, 'EFEFEF'])
13
+ @colspan_master = @table.cells[0,0]
14
+ @colspan_dummy = @colspan_master.dummy_cells.first
15
+ @rowspan_master = @table.cells[0,2]
16
+ @rowspan_dummy = @table.cells[1,2]
17
+ end
18
+
19
+ it "colspan dummy delegates background_color to the master cell" do
20
+ expect(@colspan_dummy.background_color).to eq @colspan_master.background_color
21
+ end
22
+
23
+ it "rowspan dummy delegates background_color to the master cell" do
24
+ expect(@rowspan_dummy.background_color).to eq @rowspan_master.background_color
25
+ end
26
+ end