obf 0.9.8.17 → 0.9.8.18

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/lib/obf/pdf.rb +2 -1
  3. data/lib/obf/utils.rb +17 -7
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 963a55b5473b9d4d49a7c115f37d669a414ac8ce5e23f9066516bef8a6136d0f
4
- data.tar.gz: 740e6745dc7c2f59878715cb82a22902a3396f89589a25207ab90aa090112735
3
+ metadata.gz: 68e9d9642a7a14c4324b0518f7f45b599009d40d1caaa6f414b1deeaab377ca1
4
+ data.tar.gz: 3d6ae2cada6b30884bdd964a09ea90c6d7281393aa3781f51d693c35d2d2ec17
5
5
  SHA512:
6
- metadata.gz: 4e18f9bbf2ca719ff45301c65c5108b2e1bbbfb11a4b93703cb3ae9c82aa269ec575ed80d83058c18034be8aca8ff402393fae49fd13bf93369790d6254e08e3
7
- data.tar.gz: de2f834f4e9aa4d9d59b47ffd1bef855dbe959e0837e50e41145565da679688a0053661002d2294176342d24dd08b7dc77b1b1629d444bf6d02e4d55d7654424
6
+ metadata.gz: 6772974b0b9f4d842dba7f7ca6e8bbfafc34dab19816ee4ef0e3239c31626ab9247b5cccb3899dc0b91ca09363bb30acccd788b776764ec83260f87c7e209032
7
+ data.tar.gz: a2f165e74c25da9d3102dc5b968d21efdad12b40f94680489778d52d87e53843e05ea83edc8d35a9c52cf2faa8212de20f975e6be5a40cd51776bc9a2100321f
data/lib/obf/pdf.rb CHANGED
@@ -273,7 +273,8 @@ module OBF::PDF
273
273
  elsif options['symbol_background'] == 'black'
274
274
  bg = 'black'
275
275
  end
276
- image_local_path = image && (image['local_path'] || OBF::Utils.save_image(image, options['zipper'], bg))
276
+ image_local_path = image['local_path'] if image && image['local_path'] && File.exist?(image['local_path'])
277
+ image_local_path ||= image && OBF::Utils.save_image(image, options['zipper'], bg)
277
278
  if image_local_path && File.exist?(image_local_path)
278
279
  pdf.image(image_local_path, :fit => [button_width - 10, button_height - text_height - 5], :position => :center, :vposition => :center) rescue nil
279
280
  File.unlink image_local_path
data/lib/obf/utils.rb CHANGED
@@ -160,7 +160,7 @@ module OBF::Utils
160
160
  end
161
161
 
162
162
  def self.hydra
163
- Typhoeus::Hydra.new(max_concurrency: 5)
163
+ Typhoeus::Hydra.new(max_concurrency: 20)
164
164
  end
165
165
 
166
166
  def self.save_image(image, zipper=nil, background=nil)
@@ -217,10 +217,15 @@ module OBF::Utils
217
217
  if image['content_type'] && image['content_type'].match(/svg/)
218
218
  cmd = "convert -background \"#{background}\" -density 300 -resize #{size}x#{size} -gravity center -extent #{size}x#{size} #{file.path} -flatten #{file.path}.jpg"
219
219
  OBF::Utils.log " #{cmd}"
220
- image['local_path'] = "#{file.path}.jpg"
221
220
  if image['threadable']
222
- thr = Process.detach(Process.spawn(cmd))
223
- return {thread: thr, type: 'svg'}
221
+ thr = Thread.new do
222
+ pid = Process.spawn(cmd)
223
+ Process.wait(pid)
224
+ if $?.exitstatus == 0 && File.exist?("#{file.path}.jpg")
225
+ image['local_path'] = "#{file.path}.jpg"
226
+ end
227
+ end
228
+ return {thread: thr, image: image, type: 'svg'}
224
229
  else
225
230
  `#{cmd}`
226
231
  end
@@ -229,10 +234,15 @@ module OBF::Utils
229
234
  else
230
235
  cmd = "convert #{path} -density 300 -resize #{size}x#{size} -background \"#{background}\" -gravity center -extent #{size}x#{size} -flatten #{path}.jpg"
231
236
  OBF::Utils.log " #{cmd}"
232
- image['local_path'] = "#{path}.jpg"
233
237
  if image['threadable']
234
- thr = Process.detach(Process.spawn(cmd))
235
- return {thread: thr, type: 'not_svg'}
238
+ thr = Thread.new do
239
+ pid = Process.spawn(cmd)
240
+ Process.wait(pid)
241
+ if $?.exitstatus == 0 && File.exist?("#{path}.jpg")
242
+ image['local_path'] = "#{path}.jpg"
243
+ end
244
+ end
245
+ return {thread: thr, image: image, type: 'not_svg'}
236
246
  else
237
247
  `#{cmd}`
238
248
  end
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.9.8.17
4
+ version: 0.9.8.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Whitmer