prawn-table 0.0.3 → 0.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2398c8fa511b1600ca8d94521f5240c5d46ccffd
4
- data.tar.gz: 7d39efe42ebc61bf000f59648c4ad1b2c6472e2b
3
+ metadata.gz: 5bb26b3cd806b99d95c80bc1b14e54727e53ce60
4
+ data.tar.gz: 9526ad3d0b13f33fc113000409e43e1674604447
5
5
  SHA512:
6
- metadata.gz: 2bd16b4346b7950c2ab4702d37ff8fa721470a9d16e7974ef0e6cde0d6910fd90221bd0bd3e814008518ba8c625857da6953b081e427b1c0f95f73ea44d0b90c
7
- data.tar.gz: 92172c843aee8ed8ffdc2044389a20a3b25a869ba6005b8b5b748243215681b0a3953bc17f234d043669408222293773d21c9ed81927ffb47573fa482d9bb61f
6
+ metadata.gz: 46f037412934af66b44aebb2b59e46f62161b84426e5d176ebc222211fc9984d8aef573e9c6aff85fb34f8d33757d16192c8de763150ae6735df47746b2e4462
7
+ data.tar.gz: ad550c5d510339f9464f84c2b8628222701d6163bbb5b05d8e76f08431939c4c41d17e6db93b01c650a6c3743d16176a18f506a1a2b30412ff1552161ad1a176
data/lib/prawn/table.rb CHANGED
@@ -320,7 +320,11 @@ module Prawn
320
320
  cells_this_page = []
321
321
 
322
322
  @cells.each do |cell|
323
- if cell.height > (cell.y + offset) - ref_bounds.absolute_bottom &&
323
+ # we only need to run this test on the first cell in a row
324
+ # check if the rows height fits on the page
325
+ # check if the row is not the first on that page (wouldn't make sense to go to next page in this case)
326
+ if cell.column == 0 &&
327
+ row(cell.row).height_with_span > (cell.y + offset) - ref_bounds.absolute_bottom &&
324
328
  cell.row > started_new_page_at_row
325
329
  # Ink all cells on the current page
326
330
  if defined?(@before_rendering_page) && @before_rendering_page
@@ -182,6 +182,13 @@ module Prawn
182
182
  aggregate_cell_values(:row, :height_ignoring_span, :max)
183
183
  end
184
184
 
185
+ # Returns the total height of all rows in the selected set
186
+ # including spanned cells if the cell is the master cell
187
+ #
188
+ def height_with_span
189
+ aggregate_cell_values(:row, :height, :max)
190
+ end
191
+
185
192
  # Supports setting arbitrary properties on a group of cells.
186
193
  #
187
194
  # table.cells.row(3..6).background_color = 'cc0000'
data/spec/table_spec.rb CHANGED
@@ -804,6 +804,24 @@ describe "Prawn::Table" do
804
804
  'Line 2', 'Line 3']
805
805
  end
806
806
 
807
+ context 'when the last row of first page of a table has a rowspan > 1' do
808
+ it 'should move the cells below that rowspan cell to the next page' do
809
+ pdf = Prawn::Document.new
810
+
811
+ pdf.y = 100 # not enough room for the rowspan cell
812
+ pdf.table [
813
+ ['R0C0', 'R0C1', 'R0C2'],
814
+ ['R1C0', {content: 'R1C1', rowspan: 2}, 'R1C2'],
815
+ ['R2C0', 'R2C2'],
816
+ ]
817
+
818
+ output = PDF::Inspector::Page.analyze(pdf.render)
819
+ # Ensure we output the cells of row 2 on the new page only
820
+ output.pages[0][:strings].should == ['R0C0', 'R0C1', 'R0C2']
821
+ output.pages[1][:strings].should == ['R1C0', 'R1C1', 'R1C2', 'R2C0', 'R2C2']
822
+ end
823
+ end
824
+
807
825
  it "should draw background before borders, but only within pages" do
808
826
  seq = sequence("drawing_order")
809
827
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prawn-table
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregory Brown
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2014-07-17 00:00:00.000000000 Z
16
+ date: 2014-07-23 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: prawn