pdbook 0.1.4 → 0.1.5

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 (3) hide show
  1. data/lib/pdbook.rb +1 -1
  2. data/lib/pdbook/converter.rb +9 -4
  3. metadata +1 -1
data/lib/pdbook.rb CHANGED
@@ -4,5 +4,5 @@ $:.unshift(File.dirname(__FILE__)) unless
4
4
  require 'pdbook/converter'
5
5
 
6
6
  module Pdbook
7
- VERSION = '0.1.4'
7
+ VERSION = '0.1.5'
8
8
  end
@@ -9,11 +9,16 @@ require "prawn/measurement_extensions"
9
9
 
10
10
  module Pdbook
11
11
  class Converter
12
- def initialize(input, output, font = "#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf", options = {:page_size => "A4", :margin => 0.6.in, :compress => true})
12
+ def initialize(input, output, font = "#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf", options = {:page_size => "A4", :margin => 0.6.in, :font_size => 20, :spacing => 10, :compress => true})
13
13
  @input = input
14
14
  @output = output
15
15
  @font = font
16
16
  @options = options
17
+ @options[:page_size] = ENV["page_size"] if ENV["page_size"]
18
+ @options[:margin] = ENV["margin"] if ENV["margin"]
19
+ @options[:font_size] = ENV["font_size"].to_i if ENV["font_size"]
20
+ @options[:spacing] = ENV["spacing"].to_i if ENV["spacing"]
21
+
17
22
  @pdb = Palm::PDB.new(input)
18
23
  @log = Logger.new($STDOUT)
19
24
  end
@@ -29,7 +34,7 @@ module Pdbook
29
34
  render_toc(doc, toc)
30
35
 
31
36
  # render content
32
- doc.text_options.update(:wrap => :character, :size => 24, :spacing => 8)
37
+ doc.text_options.update(:wrap => :character, :size => @options[:font_size], :spacing => @options[:spacing])
33
38
  content.each do |record|
34
39
  render_content(doc, record.data)
35
40
  end
@@ -58,7 +63,7 @@ module Pdbook
58
63
 
59
64
  # print cover
60
65
  unless cover.nil?
61
- doc.text_options.update(:wrap => :character, :size => 48, :spacing => 8)
66
+ doc.text_options.update(:wrap => :character, :size => @options[:font_size]*2, :spacing => @options[:spacing] * 2)
62
67
  doc.bounding_box [doc.bounds.left, 2*doc.bounds.top/3], :width => doc.bounds.width do
63
68
  doc.text cover
64
69
  end
@@ -67,7 +72,7 @@ module Pdbook
67
72
 
68
73
  # print toc
69
74
  unless toc.nil?
70
- doc.text_options.update(:wrap => :character, :size => 24, :spacing => 8)
75
+ doc.text_options.update(:wrap => :character, :size => @options[:font_size], :spacing => @options[:spacing])
71
76
  toc = toc.split("\e")
72
77
  section_cnt = toc.shift.to_i
73
78
  if section_cnt == toc.size
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdbook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francis Chong