pdf-wrapper 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/CHANGELOG +3 -0
  2. data/Rakefile +1 -1
  3. data/lib/pdf/wrapper/table.rb +17 -6
  4. metadata +2 -2
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ v0.2.1 (18th November 2008)
2
+ - Small bugfix to prevent unnecesary STDERR output by pango
3
+
1
4
  v0.2.0 (15th September 2008)
2
5
  - API INCOMPATIBLE CHANGE: render() and render_file() are now deprecated.
3
6
  - Use the output parameter of the constructor instead
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ require 'rake/testtask'
6
6
  require "rake/gempackagetask"
7
7
  require 'spec/rake/spectask'
8
8
 
9
- PKG_VERSION = "0.2.0"
9
+ PKG_VERSION = "0.2.1"
10
10
  PKG_NAME = "pdf-wrapper"
11
11
  PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
12
12
 
@@ -84,15 +84,20 @@ module PDF
84
84
  # TODO: when calculating the min cell width, we basically want the width of the widest character. At the
85
85
  # moment I'm stripping all pango markup tags from the string, which means if any character is made
86
86
  # intentioanlly large, we'll miss it and it might not fit into our table cell.
87
- # TODO: allow column widths to be set manually
88
87
 
89
88
  # calculate the min and max width of every cell in the table
90
89
  t.cells.each_with_index do |row, row_idx|
91
90
  row.each_with_index do |cell, col_idx|
92
91
  opts = t.options_for(col_idx, row_idx).only(default_text_options.keys)
93
92
  padding = opts[:padding] || 3
94
- cell.min_width = text_width(cell.data.to_s.dup.gsub(/<.+?>/,"").gsub(/\b|\B/,"\n"), opts) + (padding * 4)
95
- cell.max_width = text_width(cell.data, opts) + (padding * 4)
93
+ if opts[:markup] == :pango
94
+ str = cell.data.to_s.dup.gsub(/<.+?>/,"").gsub("&amp;","&").gsub("&lt;","<").gsub("&gt;",">")
95
+ opts.delete(:markup)
96
+ else
97
+ str = cell.data.to_s.dup
98
+ end
99
+ cell.min_width = text_width(str.gsub(/\b|\B/,"\n"), opts) + (padding * 4)
100
+ cell.max_width = text_width(str, opts) + (padding * 4)
96
101
  end
97
102
  end
98
103
 
@@ -101,15 +106,21 @@ module PDF
101
106
  t.headers.each_with_index do |cell, col_idx|
102
107
  opts = t.options_for(col_idx, :headers).only(default_text_options.keys)
103
108
  padding = opts[:padding] || 3
104
- cell.min_width = text_width(cell.data.to_s.dup.gsub(/<.+?>/,"").gsub(/\b|\B/,"\n"), opts) + (padding * 4)
105
- cell.max_width = text_width(cell.data, opts) + (padding * 4)
109
+ if opts[:markup] == :pango
110
+ str = cell.data.to_s.dup.gsub(/<.+?>/,"").gsub("&amp;","&").gsub("&lt;","<").gsub("&gt;",">")
111
+ opts.delete(:markup)
112
+ else
113
+ str = cell.data.to_s.dup
114
+ end
115
+ cell.min_width = text_width(str.gsub(/\b|\B/,"\n"), opts) + (padding * 4)
116
+ cell.max_width = text_width(str, opts) + (padding * 4)
106
117
  end
107
118
  end
108
119
 
109
120
  # let the table decide on the actual widths it will use for each col
110
121
  t.calc_col_widths!
111
122
 
112
- # now that we know how wide each column will be, we can calculate the
123
+ # now that we know how wide each column will be, we can calculate the
113
124
  # height of every cell in the table
114
125
  t.cells.each_with_index do |row, row_idx|
115
126
  row.each_with_index do |cell, col_idx|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdf-wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Healy
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-09-16 00:00:00 +10:00
12
+ date: 2008-11-18 00:00:00 +11:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency