bookify 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 396b87e252aafd38051125a26d3574b8ced28ac9
4
- data.tar.gz: 9a37c5e6aee7e99d901118fc042f96a2a41a47cf
3
+ metadata.gz: 9c19ae24410cf3bff9e047c14761c522eb8b6f9a
4
+ data.tar.gz: 3fb5a51820720ab13b38ecfe958881a2b5875c09
5
5
  SHA512:
6
- metadata.gz: b73c88347bfc16f70931343527699519f3a229ab17004c80baf06114946bbe1d5f78c98eb33685c5792d3b0ecdfd16db64b5edfca44b6f6b7f21a6c742e597f1
7
- data.tar.gz: 5d1891b74c0871a92c302bd265c464be828868f18f58dcd5acd37756817516b13772c3402b0f98726b868735d2617f33f7ce567099e057b7e0ea313c332e241e
6
+ metadata.gz: ce75367aef3354ae0149a68ea5ebbd042f9e67c44091df6ce080b08744c859f27e4257fd943a42fc8d9bcaa7f02db3625072ac7889855c2a866b44b197588fab
7
+ data.tar.gz: 54e149a94930df5edd75741b5af4230d603c7b2b671c868ab4c10e60dcb1fbc8c3c1c64d672ba62312d38550d973e1eb5880be47ec843fc7b43c5384ea53697a
@@ -2,4 +2,4 @@
2
2
 
3
3
  require "bookify"
4
4
 
5
- Bookify::Renderer.new(ARGV[0], ARGV[1]).render
5
+ Bookify::Renderer.new(ARGV).render
@@ -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
- if bounds.left == 0.0
8
- 2.times { bounds.move_past_bottom }
9
- else
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")
@@ -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
- def initialize(input_file, output_file = nil)
7
- self.input_file = input_file
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: 2, width: pdf.bounds.width do
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.1.4
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-01 00:00:00.000000000 Z
11
+ date: 2017-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake