bookie 0.0.9 → 0.0.10
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.
- data/CHANGELOG.md +4 -0
- data/lib/bookie/emitters.rb +56 -38
- data/lib/bookie/version.rb +1 -1
- data/test/units/parser_test.rb +1 -1
- metadata +1 -1
data/CHANGELOG.md
CHANGED
data/lib/bookie/emitters.rb
CHANGED
|
@@ -121,14 +121,18 @@ module Bookie
|
|
|
121
121
|
def build_list(list)
|
|
122
122
|
items = list.contents
|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
draw do
|
|
125
125
|
font("serif", :size => 9) do
|
|
126
126
|
items.each do |li|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
-
|
|
147
|
+
draw do
|
|
148
|
+
start_new_page unless cursor > in2pt(0.4)
|
|
144
149
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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
|
-
|
|
158
|
+
move_down in2pt(0.3)
|
|
159
|
+
end
|
|
152
160
|
end
|
|
153
161
|
|
|
154
162
|
def build_paragraph(paragraph)
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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
|
-
|
|
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
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
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
|
|
data/lib/bookie/version.rb
CHANGED
data/test/units/parser_test.rb
CHANGED
|
@@ -42,7 +42,7 @@ context "A Parser" do
|
|
|
42
42
|
|
|
43
43
|
assert_equal 3, parsed_content.length
|
|
44
44
|
|
|
45
|
-
assert_equal
|
|
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 "+
|