paperback 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d547d9dcf1d897e3a74e10857252bdabafbeb0c
4
- data.tar.gz: aee41bd4ddade2e7c53605e7705fcceb1cf5a289
3
+ metadata.gz: 2e11bb71dec04963fa615cc0b522af8ab818a671
4
+ data.tar.gz: 7d5c5b5a1e45bf30b62303415e5697681867f57d
5
5
  SHA512:
6
- metadata.gz: 6ca6b67b21a9a148620774be64a61b775843e271aca16a6d19b68427ecfffa2a6d70c42e643354fccd8e1ecd70f241cd469a6eb5fc1ad983cb9b5c96d68e5851
7
- data.tar.gz: e83264962cf64b1c16921a0074c3a340d49a56d348f61310d1bce014e316a4520758420fa790ecd3b0a6df30ade576a1fcb786207d8296e7c76a3291e8d7e3ab
6
+ metadata.gz: 03c36ef11c1a27ff57254d004f1ddb697920f726b7e29e72845d4f72e62f259bc987889d6db65a00af662cc2aaefc0916feadc69c4d44195431c7679020d0bd2
7
+ data.tar.gz: 3d7c478f33e894a6303d0fd1546a8e4e21c8f4df5509900081b04ca6a229fa4858f8357e220b26101727724bb960df2aa19b06c5278e3feae357ef4e34889075
@@ -31,11 +31,11 @@ For example:
31
31
  Options:
32
32
  EOM
33
33
 
34
- opts.on('-h', '--help', 'Display this message', ' ') do
34
+ opts.on('-h', '--help', 'Display this message') do
35
35
  STDERR.puts opts, ''
36
36
  exit 0
37
37
  end
38
- opts.on('--version', 'Print version number', ' ') do
38
+ opts.on('--version', 'Print version number') do
39
39
  puts 'paperback ' + Paperback::VERSION
40
40
  exit 0
41
41
  end
@@ -45,17 +45,24 @@ Options:
45
45
 
46
46
  #
47
47
 
48
+ opts.on('-c', '--comment TEXT', 'Add TEXT comment to output') do |val|
49
+ options[:comment] = val
50
+ end
51
+
48
52
  opts.on('--no-encrypt', 'Skip encryption of input') do |val|
49
53
  options[:encrypt] = val
50
54
  end
51
55
 
52
- opts.on('-c', '--comment TEXT', 'Add TEXT comment to output') do |val|
53
- options[:comment] = val
56
+ opts.on('--passphrase-out FILE', 'Write generated passphrase to FILE',
57
+ ' ') do |val|
58
+ options[:passphrase_file] = val
54
59
  end
55
60
 
56
- opts.on('--passphrase-out FILE',
57
- 'Write generated passphrase to FILE') do |val|
58
- options[:passphrase_file] = val
61
+ #
62
+
63
+ opts.on('--sixword-font-size SIZE', 'Size of sixword text') do |val|
64
+ options[:extra_draw_opts] ||= {}
65
+ options[:extra_draw_opts][:sixword_font_size] = Float(val)
59
66
  end
60
67
  end
61
68
 
@@ -1,12 +1,13 @@
1
1
  module Paperback
2
2
  module CLI
3
3
  def self.create_backup(input:, output:, encrypt: true, qr_base64: true,
4
- qr_level: :l, comment: nil, passphrase_file: nil)
4
+ qr_level: :l, comment: nil, passphrase_file: nil,
5
+ extra_draw_opts: {})
5
6
  prep = Paperback::Preparer.new(filename: input, encrypt: encrypt,
6
7
  qr_base64: qr_base64, qr_level: qr_level,
7
8
  passphrase_file: passphrase_file,
8
9
  comment: comment)
9
- prep.render(output_filename: output)
10
+ prep.render(output_filename: output, extra_draw_opts: extra_draw_opts)
10
11
  end
11
12
  end
12
13
  end
@@ -27,7 +27,8 @@ module Paperback; class Document
27
27
 
28
28
  # High level method to draw the paperback content on the pdf document
29
29
  def draw_paperback(qr_code:, sixword_lines:, sixword_bytes:,
30
- labels:, passphrase_sha: nil, passphrase_len: nil)
30
+ labels:, passphrase_sha: nil, passphrase_len: nil,
31
+ sixword_font_size: nil)
31
32
  unless qr_code.is_a?(RQRCode::QRCode)
32
33
  raise ArgumentError.new('qr_code must be RQRCode::QRCode')
33
34
  end
@@ -51,7 +52,8 @@ module Paperback; class Document
51
52
 
52
53
  pdf.start_new_page
53
54
 
54
- draw_sixword(lines: sixword_lines, sixword_bytes: sixword_bytes)
55
+ draw_sixword(lines: sixword_lines, sixword_bytes: sixword_bytes,
56
+ font_size: sixword_font_size)
55
57
 
56
58
  pdf.number_pages('<page> of <total>', align: :right,
57
59
  at: [pdf.bounds.right - 100, -2])
@@ -114,7 +116,10 @@ module Paperback; class Document
114
116
  # @param [Integer] columns The number of text columns on the page
115
117
  # @param [Integer] hunks_per_row The number of 6-word sentences per line
116
118
  # @param [Integer] sixword_bytes Bytesize of the sixword encoded data
117
- def draw_sixword(lines:, sixword_bytes:, columns: 3, hunks_per_row: 1)
119
+ def draw_sixword(lines:, sixword_bytes:, columns: 3, hunks_per_row: 1,
120
+ font_size: nil)
121
+ font_size ||= 11
122
+
118
123
  debug_draw_axes
119
124
 
120
125
  numbered = lines.each_slice(hunks_per_row).each_with_index.map { |row, i|
@@ -134,7 +139,7 @@ module Paperback; class Document
134
139
 
135
140
  pdf.column_box([0, pdf.cursor], columns: columns, width: pdf.bounds.width) do
136
141
  pdf.font('Times-Roman') do
137
- pdf.font_size(11) do
142
+ pdf.font_size(font_size) do
138
143
  pdf.text(numbered.join("\n"))
139
144
  end
140
145
  end
@@ -63,7 +63,7 @@ module Paperback
63
63
  @log ||= Paperback.class_log(self)
64
64
  end
65
65
 
66
- def render(output_filename:)
66
+ def render(output_filename:, extra_draw_opts: {})
67
67
  log.debug('Preparer#render')
68
68
 
69
69
  opts = {
@@ -85,6 +85,8 @@ module Paperback
85
85
  end
86
86
  end
87
87
 
88
+ opts.merge!(extra_draw_opts)
89
+
88
90
  @document.render(output_file: output_filename, draw_opts: opts)
89
91
 
90
92
  log.info('Render complete')
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module Paperback
3
3
  # version string
4
- VERSION = '0.0.2'
4
+ VERSION = '0.0.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperback
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Brody