bookie 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -47,3 +47,7 @@ friends to test soon.
47
47
  ## 0.0.9 (2011.04.28)
48
48
 
49
49
  Add barely useful command line app
50
+
51
+ ## 0.0.10 (2011.04.28)
52
+
53
+ Fix some PDF bugs and make a little draw() helper for emitter.
@@ -121,14 +121,18 @@ module Bookie
121
121
  def build_list(list)
122
122
  items = list.contents
123
123
 
124
- @document.instance_eval do
124
+ draw do
125
125
  font("serif", :size => 9) do
126
126
  items.each do |li|
127
- float { text "•" }
128
- indent(in2pt(0.15)) do
129
- text li.gsub(/\s+/," "),
130
- inline_format: true,
131
- leading: 2
127
+ li_text = li.gsub(/\s+/," ")
128
+
129
+ group do
130
+ float { text "•" }
131
+ indent(in2pt(0.15)) do
132
+ text li_text,
133
+ inline_format: true,
134
+ leading: 2
135
+ end
132
136
  end
133
137
 
134
138
  move_down in2pt(0.05)
@@ -140,30 +144,38 @@ module Bookie
140
144
  end
141
145
 
142
146
  def build_section_heading(section_text)
143
- @document.move_down in2pt(0.1)
147
+ draw do
148
+ start_new_page unless cursor > in2pt(0.4)
144
149
 
145
- @document.float do
146
- @document.font("sans", :style => :bold, :size => 14) do
147
- @document.text(section_text.contents.strip)
150
+ move_down in2pt(0.1)
151
+
152
+ float do
153
+ font("sans", :style => :bold, :size => 14) do
154
+ text(section_text.contents.strip)
155
+ end
148
156
  end
149
- end
150
157
 
151
- @document.move_down in2pt(0.3)
158
+ move_down in2pt(0.3)
159
+ end
152
160
  end
153
161
 
154
162
  def build_paragraph(paragraph)
155
- @document.font("serif", size: 9) do
156
- @document.text(paragraph.contents.strip, align: :justify, leading: 2)
157
- @document.move_down in2pt(0.1)
163
+ draw do
164
+ font("serif", size: 9) do
165
+ text(paragraph.contents.strip, align: :justify, leading: 2)
166
+ end
167
+ move_down in2pt(0.1)
158
168
  end
159
169
  end
160
170
 
161
171
  def build_raw_text(raw_text)
162
172
  sanitized_text = raw_text.contents.gsub(" ", Prawn::Text::NBSP).strip
163
-
164
- @document.font("mono", size: 8) do
165
- @document.text sanitized_text
166
- @document.move_down in2pt(0.1)
173
+
174
+ draw do
175
+ font("mono", size: 8) do
176
+ text sanitized_text
177
+ move_down in2pt(0.1)
178
+ end
167
179
  end
168
180
  end
169
181
 
@@ -172,7 +184,7 @@ module Bookie
172
184
  end
173
185
 
174
186
  def render_header(params)
175
- @document.instance_eval do
187
+ draw do
176
188
  font("sans") do
177
189
  text "<b>#{params[:header]}</b>",
178
190
  size: 12, align: :right, inline_format: true
@@ -191,26 +203,32 @@ module Bookie
191
203
  def register_fonts
192
204
  dejavu_path = File.dirname(__FILE__) + "/../../data/fonts/dejavu"
193
205
 
194
- @document.font_families["sans"] = {
195
- :normal => "#{dejavu_path}/DejaVuSansCondensed.ttf",
196
- :italic => "#{dejavu_path}/DejaVuSansCondensed-Oblique.ttf",
197
- :bold => "#{dejavu_path}/DejaVuSansCondensed-Bold.ttf",
198
- :bold_italic => "#{dejavu_path}/DejaVuSansCondensed-BoldOblique.ttf"
199
- }
206
+ draw do
207
+ font_families["sans"] = {
208
+ :normal => "#{dejavu_path}/DejaVuSansCondensed.ttf",
209
+ :italic => "#{dejavu_path}/DejaVuSansCondensed-Oblique.ttf",
210
+ :bold => "#{dejavu_path}/DejaVuSansCondensed-Bold.ttf",
211
+ :bold_italic => "#{dejavu_path}/DejaVuSansCondensed-BoldOblique.ttf"
212
+ }
200
213
 
201
- @document.font_families["mono"] = {
202
- :normal => "#{dejavu_path}/DejaVuSansMono.ttf",
203
- :italic => "#{dejavu_path}/DejaVuSansMono-Oblique.ttf",
204
- :bold => "#{dejavu_path}/DejaVuSansMono-Bold.ttf",
205
- :bold_italic => "#{dejavu_path}/DejaVuSansMono-BoldOblique.ttf"
206
- }
214
+ font_families["mono"] = {
215
+ :normal => "#{dejavu_path}/DejaVuSansMono.ttf",
216
+ :italic => "#{dejavu_path}/DejaVuSansMono-Oblique.ttf",
217
+ :bold => "#{dejavu_path}/DejaVuSansMono-Bold.ttf",
218
+ :bold_italic => "#{dejavu_path}/DejaVuSansMono-BoldOblique.ttf"
219
+ }
207
220
 
208
- @document.font_families["serif"] = {
209
- :normal => "#{dejavu_path}/DejaVuSerif.ttf",
210
- :italic => "#{dejavu_path}/DejaVuSerif-Italic.ttf",
211
- :bold => "#{dejavu_path}/DejaVuSerif-Bold.ttf",
212
- :bold_italic => "#{dejavu_path}/DejaVuSerif-BoldItalic.ttf"
213
- }
221
+ font_families["serif"] = {
222
+ :normal => "#{dejavu_path}/DejaVuSerif.ttf",
223
+ :italic => "#{dejavu_path}/DejaVuSerif-Italic.ttf",
224
+ :bold => "#{dejavu_path}/DejaVuSerif-Bold.ttf",
225
+ :bold_italic => "#{dejavu_path}/DejaVuSerif-BoldItalic.ttf"
226
+ }
227
+ end
228
+ end
229
+
230
+ def draw(&block)
231
+ @document.instance_eval(&block)
214
232
  end
215
233
 
216
234
 
@@ -1,3 +1,3 @@
1
1
  module Bookie
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
@@ -42,7 +42,7 @@ context "A Parser" do
42
42
 
43
43
  assert_equal 3, parsed_content.length
44
44
 
45
- assert_equal 8, parsed_content[1].contents.length
45
+ assert_equal 7, parsed_content[1].contents.length
46
46
 
47
47
  expected_li4 = "Your project can be pretty much anything Ruby related, "+
48
48
  "as long as it does something useful, and involves writing "+
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: bookie
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.9
5
+ version: 0.0.10
6
6
  platform: ruby
7
7
  authors:
8
8
  - Gregory Brown