bookify 1.6.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/bookify +1 -1
- data/lib/bookify/renderer.rb +23 -13
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d440b7412142dae84f47b9653733a33f826d5057
|
4
|
+
data.tar.gz: 515bbecc3fd4ee92fca7434812e4ca00a60d21ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a7fffa9f6cac1980f5dd80cb97bdafc73ba13fdf6c0879a74e2a63e14527ba4701146e32068f1da29776870e20a0c77b099d01e2d021755c47586c8f5d8ad64
|
7
|
+
data.tar.gz: 9afd804f9f1d614dab9d21995d6ef08a3c944a43acafc2304fa091755c1bf5d3e4b4109daf502a16abe031d127b18d331a538060bac01e63e33094ad6930c166
|
data/bin/bookify
CHANGED
data/lib/bookify/renderer.rb
CHANGED
@@ -1,20 +1,30 @@
|
|
1
1
|
class Bookify::Renderer
|
2
2
|
MARKDOWN_CONVERTER = Redcarpet::Markdown.new(Redcarpet::Render::HTML, tables: true)
|
3
3
|
|
4
|
-
attr_accessor :input_file, :output_file, :layout, :columns
|
4
|
+
attr_accessor :input_file, :output_file, :layout, :columns, :input_text
|
5
5
|
|
6
|
-
def
|
6
|
+
def self.from_args(args)
|
7
7
|
if ["-l", "--landscape"].include?(args[0])
|
8
8
|
args.shift
|
9
|
-
|
10
|
-
|
9
|
+
layout = :landscape
|
10
|
+
columns = 3
|
11
11
|
else
|
12
|
-
|
13
|
-
|
12
|
+
layout = :portrait
|
13
|
+
columns = 2
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
input_file = args[0]
|
17
|
+
output_file = args[1] || input_file.split("/").last.gsub(/\.\w+/, ".pdf")
|
18
|
+
|
19
|
+
new(layout: layout, columns: columns, input_file: input_file, output_file: output_file)
|
20
|
+
end
|
21
|
+
|
22
|
+
def initialize(layout: :landscape, columns: 2, output_file:, input_file: nil, input_text: nil)
|
23
|
+
@layout = layout
|
24
|
+
@columns = columns
|
25
|
+
@output_file = output_file
|
26
|
+
@input_file = input_file
|
27
|
+
@input_text = input_text
|
18
28
|
end
|
19
29
|
|
20
30
|
def render
|
@@ -22,10 +32,10 @@ class Bookify::Renderer
|
|
22
32
|
font_path = "#{File.dirname(__FILE__)}/../../fonts"
|
23
33
|
|
24
34
|
pdf.font_families["Book Antiqua"] = {
|
25
|
-
normal:
|
26
|
-
bold:
|
27
|
-
italic:
|
28
|
-
bold_italic: {
|
35
|
+
normal: {file: "#{font_path}/BookAntiqua.ttf"},
|
36
|
+
bold: {file: "#{font_path}/BookAntiqua-Bold.ttf"},
|
37
|
+
italic: {file: "#{font_path}/BookAntiqua-Italic.ttf"},
|
38
|
+
bold_italic: {file: "#{font_path}/BookAntiqua-BoldItalic.ttf"},
|
29
39
|
}
|
30
40
|
|
31
41
|
pdf.fill_color "000000"
|
@@ -42,7 +52,7 @@ class Bookify::Renderer
|
|
42
52
|
private
|
43
53
|
|
44
54
|
def markdown
|
45
|
-
@markdown ||= File.read(input_file)
|
55
|
+
@markdown ||= (input_text || File.read(input_file))
|
46
56
|
end
|
47
57
|
|
48
58
|
def doc
|