bookify 1.6.0 → 2.0.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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/bookify +1 -1
  3. data/lib/bookify/renderer.rb +23 -13
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d96db32548138e5c5f80dfdc38a2fc6bcf203ac0
4
- data.tar.gz: 2b8ea9ae6d7ea625d3378a924d9ca006925088c5
3
+ metadata.gz: d440b7412142dae84f47b9653733a33f826d5057
4
+ data.tar.gz: 515bbecc3fd4ee92fca7434812e4ca00a60d21ea
5
5
  SHA512:
6
- metadata.gz: f5073d6cd1e2ce2d165bfd70904a36bf0cd7fda9ddb1909726a881dea8a286b9ce896fb9980dea638beb5908093b789d3b697c2d55a36fa7e1ea3ea2275eca89
7
- data.tar.gz: 2563947ea6512089a5a7747888e5540748e1246f069c054af3e04eecc05882b1ee376ddf0e1b51461209c9457b072fea616095f160aa75ef174966fd1c4182ca
6
+ metadata.gz: 4a7fffa9f6cac1980f5dd80cb97bdafc73ba13fdf6c0879a74e2a63e14527ba4701146e32068f1da29776870e20a0c77b099d01e2d021755c47586c8f5d8ad64
7
+ data.tar.gz: 9afd804f9f1d614dab9d21995d6ef08a3c944a43acafc2304fa091755c1bf5d3e4b4109daf502a16abe031d127b18d331a538060bac01e63e33094ad6930c166
data/bin/bookify CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  require "bookify"
4
4
 
5
- Bookify::Renderer.new(ARGV).render
5
+ Bookify::Renderer.from_args(ARGV).render
@@ -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 initialize(args)
6
+ def self.from_args(args)
7
7
  if ["-l", "--landscape"].include?(args[0])
8
8
  args.shift
9
- self.layout = :landscape
10
- self.columns = 3
9
+ layout = :landscape
10
+ columns = 3
11
11
  else
12
- self.layout = :portrait
13
- self.columns = 2
12
+ layout = :portrait
13
+ columns = 2
14
14
  end
15
15
 
16
- self.input_file = args[0]
17
- self.output_file = args[1] || input_file.split("/").last.gsub(/\.\w+/, ".pdf")
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: { file: "#{font_path}/BookAntiqua.ttf" },
26
- bold: { file: "#{font_path}/BookAntiqua-Bold.ttf" },
27
- italic: { file: "#{font_path}/BookAntiqua-Italic.ttf" },
28
- bold_italic: { file: "#{font_path}/BookAntiqua-BoldItalic.ttf" }
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bookify
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joey Schoblaska