obf 0.8.4 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/obf/pdf.rb +14 -12
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5632f5b2f1f0a39e5959b450b224ceaf0156e70b
4
- data.tar.gz: 51e0052c09a107e280d3309d38e54e7ca1f88f11
3
+ metadata.gz: ab2c55d56ca5f570a188f3936a58324965cfb5f9
4
+ data.tar.gz: b0dc51874a5a7a7b3f010d6f243cd109909ab506
5
5
  SHA512:
6
- metadata.gz: dbeb5f66b6ba30025ca2212f90cac5fd46510a4875a93b511aeca856fc5329b1cb04a471add5ffafcd8984327e3fb7103d9aff0addb7ff86de72d58872df6acc
7
- data.tar.gz: 13f8c5a2705a34e2ecf61327ff96c8c619e297cd38fcf3fb45b2f3b733a563950df29f31982e438b286c344be00c3ade07f887e9baf37f813b1c93c2e5d7201e
6
+ metadata.gz: 4b90045b54cdb8f01cef1ef31e2c003a4f7ff908d8337f4cab8bb1d06553ecfed2eaeb490de01b3952874501093b1474733bc0a78f112e489d6d6ac53b66c7a4
7
+ data.tar.gz: 2353646c0179cebd7832a883c5f2242a22e0047119eeb4f8be4ba1aa5b258877ed111cacd466db1abb51b42f3f0fc4fab26dc36c26fd81a3c0b7e306a82e4a6d
@@ -32,8 +32,6 @@ module OBF::PDF
32
32
  end
33
33
 
34
34
  def self.build_pdf(obj, dest_path, zipper, opts={})
35
- character_classes = RTL_SCRIPTS.map{ |script| "\\p{#{script}}" }.join
36
- rtl_regex = /[#{character_classes}]/
37
35
  OBF::Utils.as_progress_percent(0, 1.0) do
38
36
  # parse obf, draw as pdf
39
37
  pdf = Prawn::Document.new(
@@ -76,6 +74,10 @@ module OBF::PDF
76
74
  end
77
75
  end
78
76
 
77
+ def self.rtl_regex
78
+ @res ||= /[#{RTL_SCRIPTS.map{ |script| "\\p{#{script}}" }.join}]/
79
+ end
80
+
79
81
  def self.build_page(pdf, obj, options)
80
82
  OBF::Utils.as_progress_percent(0, 1.0) do
81
83
  doc_width = 11*72 - 72
@@ -152,19 +154,19 @@ module OBF::PDF
152
154
 
153
155
  text = (button['label'] || button['vocalization']).to_s
154
156
  direction = text.match(rtl_regex) ? :rtl : :ltr
155
- if opts['text_case'] == 'upper'
157
+ if options['text_case'] == 'upper'
156
158
  text = text.upcase
157
- elsif opts['text_case'] == 'lower'
159
+ elsif options['text_case'] == 'lower'
158
160
  text = text.downcase
159
161
  end
160
162
  pdf.text_box text, :at => [0, vertical], :width => button_width, :height => text_height, :align => :center, :valign => :center, :overflow => :shrink_to_fit, :direction => direction
161
- if opts['text_only']
163
+ if options['text_only']
162
164
  # render text
163
165
  pdf.fill_color "000000"
164
166
  text = (button['label'] || button['vocalization']).to_s
165
- if opts['text_case'] == 'upper'
167
+ if options['text_case'] == 'upper'
166
168
  text = text.upcase
167
- elsif opts['text_case'] == 'lower'
169
+ elsif options['text_case'] == 'lower'
168
170
  text = text.downcase
169
171
  end
170
172
  pdf.text_box text, :at => [0, 0], :width => button_width, :height => button_height, :align => :center, :valign => :center, :overflow => :shrink_to_fit, :direction => direction
@@ -187,12 +189,12 @@ module OBF::PDF
187
189
  if options['pages'] && button['load_board']
188
190
  page = options['pages'][button['load_board']['id']]
189
191
  if page
190
- page_vertical = options['text_on_top'] ? 5 + text_height : button_height - 5
192
+ page_vertical = options['text_on_top'] ? -2 + text_height : button_height + 2
191
193
  pdf.fill_color "ffffff"
192
194
  pdf.stroke_color "eeeeee"
193
- pdf.fill_and_stroke_rounded_rectangle [button_width - 25, page_vertical], 20, text_height, 5
195
+ pdf.fill_and_stroke_rounded_rectangle [button_width - 18, page_vertical], 20, text_height, 5
194
196
  pdf.fill_color "000000"
195
- pdf.formatted_text_box [{:text => page, :anchor => "page#{page}"}], :at => [button_width - 25, page_vertical], :width => 20, :height => text_height, :align => :center, :valign => :center
197
+ pdf.formatted_text_box [{:text => page, :anchor => "page#{page}"}], :at => [button_width - 18, page_vertical], :width => 20, :height => text_height, :align => :center, :valign => :center
196
198
  end
197
199
  end
198
200
 
@@ -200,9 +202,9 @@ module OBF::PDF
200
202
  pdf.fill_color "000000"
201
203
  vertical = options['text_on_top'] ? button_height : text_height
202
204
  text = (button['label'] || button['vocalization']).to_s
203
- if opts['text_case'] == 'upper'
205
+ if options['text_case'] == 'upper'
204
206
  text = text.upcase
205
- elsif opts['text_case'] == 'lower'
207
+ elsif options['text_case'] == 'lower'
206
208
  text = text.downcase
207
209
  end
208
210
  pdf.text_box text, :at => [0, vertical], :width => button_width, :height => text_height, :align => :center, :valign => :center, :overflow => :shrink_to_fit
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: obf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.4
4
+ version: 0.8.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Whitmer