prawn-table 0.1.1 → 0.1.2

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: 1a9ab85b9c6e1e5faa063d37a21fa0dadf061a1a
4
- data.tar.gz: 47f2bf92a9b72a9e7ee01a9761ed5ac4962661d0
3
+ metadata.gz: ad3cd4b7b737957cfc9d5ab8a0673a27606a245b
4
+ data.tar.gz: c2b1d37a6c8e25ebd2de9ef3d322032e8d5667df
5
5
  SHA512:
6
- metadata.gz: 17c4dbc381202ee3d65eb782c62a3428cde3a76d0fbc1058077d6e15edeb99a27c5fbe01dea896023f89e1dc4b0d18518b4efc3eca2294c0db013cb456347255
7
- data.tar.gz: 7fc28e1c4be55935e8a802643d41c46670403befc0cabe51b92adf28b6bd7a0ef98744ef2b71dfd2b85ad05be8d8d0fc8737dff34767bfdc4f80f942c1b49fbd
6
+ metadata.gz: bddf85d78a3bd370b49939fe5808778bb0160c3dfb9360b67d7a49441592ff9501deb1f382eadfe3d4c30bf502fceeb773774302dc380f33dce909e2960447fe
7
+ data.tar.gz: 63131251d4c12ece20b5be3af29e3ad4724d9276dbafad4b9ca71cc506ff8c61f0cba53daadda2e65b92a050e39e7621ef4782ad38e8076d56fd0b40dc63afb4
@@ -473,7 +473,8 @@ module Prawn
473
473
  needed_height = row(0..number_of_header_rows).height
474
474
 
475
475
  # have we got enough room to fit the first row (including header row(s))
476
- return -1 if fits_on_page?(needed_height)
476
+ use_reference_bounds = true
477
+ return -1 if fits_on_page?(needed_height, use_reference_bounds)
477
478
 
478
479
  # If there isn't enough room left on the page to fit the first data row
479
480
  # (including the header), start the table on the next page.
@@ -484,8 +485,13 @@ module Prawn
484
485
  end
485
486
 
486
487
  # do we have enough room to fit a given height on to the current page?
487
- def fits_on_page?(needed_height)
488
- needed_height < @pdf.y - (@pdf.bounds.absolute_bottom - Prawn::FLOAT_PRECISION)
488
+ def fits_on_page?(needed_height, use_reference_bounds = false)
489
+ if use_reference_bounds
490
+ bounds = @pdf.reference_bounds
491
+ else
492
+ bounds = @pdf.bounds
493
+ end
494
+ needed_height < @pdf.y - (bounds.absolute_bottom - Prawn::FLOAT_PRECISION)
489
495
  end
490
496
 
491
497
  # return the header rows
@@ -38,6 +38,9 @@ module Prawn
38
38
  class Cells < Array
39
39
 
40
40
  def fits_on_current_page?(offset, ref_bounds)
41
+ # an empty row array means it definitely fits
42
+ return true if self.empty?
43
+
41
44
  height_with_span < (self[0,0].y + offset) - ref_bounds.absolute_bottom
42
45
  end
43
46
 
@@ -26,23 +26,8 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency('prawn-manual_builder', ">= 0.2.0")
27
27
  spec.add_development_dependency('pdf-reader', '~>1.2')
28
28
 
29
- spec.homepage = "http://prawn.majesticseacreature.com"
29
+ spec.homepage = "https://github.com/prawnpdf/prawn-table"
30
30
  spec.description = <<END_DESC
31
- Prawn is a fast, tiny, and nimble PDF generator for Ruby
32
- END_DESC
33
- spec.post_install_message = <<END_DESC
34
-
35
- ********************************************
36
-
37
-
38
- A lot has changed recently in Prawn.
39
-
40
- Please read the changelog for details:
41
-
42
- https://github.com/prawnpdf/prawn/wiki/CHANGELOG
43
-
44
-
45
- ********************************************
46
-
31
+ Prawn::Table provides tables for the Prawn PDF toolkit
47
32
  END_DESC
48
33
  end
@@ -1576,4 +1576,29 @@ describe "colspan / rowspan" do
1576
1576
  t.cells[2, 2].content.should == "h"
1577
1577
  t.cells[2, 3].content.should == "i"
1578
1578
  end
1579
+
1580
+ it 'illustrates issue #20', issue: 20 do
1581
+ pdf = Prawn::Document.new
1582
+ description = "one\ntwo\nthree"
1583
+ bullets = description.split("\n")
1584
+ bullets.each_with_index do |bullet, ndx|
1585
+ rows = [[]]
1586
+
1587
+ if ndx < 1
1588
+ rows << [ { content: "blah blah blah", colspan: 2, font_style: :bold, size: 12, padding_bottom: 1 }]
1589
+ else
1590
+ rows << [ { content: bullet, width: 440, padding_top: 0, align: :justify } ]
1591
+ end
1592
+ pdf.table(rows, header: true, cell_style: { border_width: 0, inline_format: true })
1593
+ end
1594
+ pdf.render
1595
+ end
1596
+
1597
+ it 'illustrates issue #20 (2) and #22', issue: 22 do
1598
+ pdf = Prawn::Document.new
1599
+ pdf.table [['one', 'two']], position: :center
1600
+ pdf.table [['three', 'four']], position: :center
1601
+ pdf.render
1602
+ pdf.page_count.should == 1
1603
+ end
1579
1604
  end
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.1.1
4
+ version: 0.1.2
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-08-29 00:00:00.000000000 Z
16
+ date: 2014-09-19 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: prawn
@@ -142,7 +142,7 @@ dependencies:
142
142
  - !ruby/object:Gem::Version
143
143
  version: '1.2'
144
144
  description: |2
145
- Prawn is a fast, tiny, and nimble PDF generator for Ruby
145
+ Prawn::Table provides tables for the Prawn PDF toolkit
146
146
  email:
147
147
  - gregory.t.brown@gmail.com
148
148
  - brad@bradediger.com
@@ -195,26 +195,13 @@ files:
195
195
  - spec/spec_helper.rb
196
196
  - spec/table/span_dummy_spec.rb
197
197
  - spec/table_spec.rb
198
- homepage: http://prawn.majesticseacreature.com
198
+ homepage: https://github.com/prawnpdf/prawn-table
199
199
  licenses:
200
200
  - RUBY
201
201
  - GPL-2
202
202
  - GPL-3
203
203
  metadata: {}
204
- post_install_message: |2+
205
-
206
- ********************************************
207
-
208
-
209
- A lot has changed recently in Prawn.
210
-
211
- Please read the changelog for details:
212
-
213
- https://github.com/prawnpdf/prawn/wiki/CHANGELOG
214
-
215
-
216
- ********************************************
217
-
204
+ post_install_message:
218
205
  rdoc_options: []
219
206
  require_paths:
220
207
  - lib