bookify 0.1.4 → 0.2.0
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 +4 -4
- data/bin/bookify +1 -1
- data/lib/bookify/node/div.rb +3 -3
- data/lib/bookify/renderer.rb +15 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c19ae24410cf3bff9e047c14761c522eb8b6f9a
|
4
|
+
data.tar.gz: 3fb5a51820720ab13b38ecfe958881a2b5875c09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce75367aef3354ae0149a68ea5ebbd042f9e67c44091df6ce080b08744c859f27e4257fd943a42fc8d9bcaa7f02db3625072ac7889855c2a866b44b197588fab
|
7
|
+
data.tar.gz: 54e149a94930df5edd75741b5af4230d603c7b2b671c868ab4c10e60dcb1fbc8c3c1c64d672ba62312d38550d973e1eb5880be47ec843fc7b43c5384ea53697a
|
data/bin/bookify
CHANGED
data/lib/bookify/node/div.rb
CHANGED
@@ -4,9 +4,9 @@ module Bookify::Node
|
|
4
4
|
html_classes = (node.attr(:class) || "").split(" ")
|
5
5
|
|
6
6
|
if html_classes.include?("page-break")
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
bounds.move_past_bottom
|
8
|
+
|
9
|
+
until bounds.left == 0.0
|
10
10
|
bounds.move_past_bottom
|
11
11
|
end
|
12
12
|
elsif html_classes.include?("section-break")
|
data/lib/bookify/renderer.rb
CHANGED
@@ -1,15 +1,24 @@
|
|
1
1
|
class Bookify::Renderer
|
2
2
|
MARKDOWN_CONVERTER = Redcarpet::Markdown.new(Redcarpet::Render::HTML)
|
3
3
|
|
4
|
-
attr_accessor :input_file, :output_file
|
4
|
+
attr_accessor :input_file, :output_file, :layout, :columns
|
5
|
+
|
6
|
+
def initialize(args)
|
7
|
+
if ["-l", "--landscape"].include?(args[0])
|
8
|
+
args.shift
|
9
|
+
self.layout = :landscape
|
10
|
+
self.columns = 3
|
11
|
+
else
|
12
|
+
self.layout = :portrait
|
13
|
+
self.columns = 2
|
14
|
+
end
|
5
15
|
|
6
|
-
|
7
|
-
self.
|
8
|
-
self.output_file = output_file || input_file.gsub(/\.\w+/, ".pdf")
|
16
|
+
self.input_file = args[0]
|
17
|
+
self.output_file = args[1] || input_file.gsub(/\.\w+/, ".pdf")
|
9
18
|
end
|
10
19
|
|
11
20
|
def render
|
12
|
-
Prawn::Document.generate(output_file, margin: 50) do |pdf|
|
21
|
+
Prawn::Document.generate(output_file, margin: 50, page_layout: layout) do |pdf|
|
13
22
|
font_path = "#{File.dirname(__FILE__)}/../../fonts"
|
14
23
|
|
15
24
|
pdf.font_families["Book Antiqua"] = {
|
@@ -24,7 +33,7 @@ class Bookify::Renderer
|
|
24
33
|
pdf.line_width(0.5)
|
25
34
|
pdf.default_leading 0.5
|
26
35
|
|
27
|
-
pdf.column_box [0, pdf.cursor], columns:
|
36
|
+
pdf.column_box [0, pdf.cursor], columns: columns, width: pdf.bounds.width do
|
28
37
|
doc.children.each { |c| Bookify::Node.render(c, pdf) }
|
29
38
|
end
|
30
39
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bookify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joey Schoblaska
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|