obf 0.9.8.6 → 0.9.8.7
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 +4 -4
- data/lib/obf/pdf.rb +4 -4
- data/lib/obf/utils.rb +15 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e9744e7a34a7cf34c098f19e1fbc6ef9eb6ceb3e1c7eebfc3fb7d80779b502c
|
4
|
+
data.tar.gz: 3a707ec782d9a9df24409a9e2ef4c3c96b8b59de9693a587c044826c6fe72cbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efcf27be7401b4d904608f968e174b44b79c85b9346cbd174a1da9917e0e58faa4197338f5ba9cfaabd15c3e409bb603083f119e3a8ac73c10869a285d919a41
|
7
|
+
data.tar.gz: fe94deb30f15448d792b4abcc7695c7e049f821d7a89250518410c320e6e82aaffca13bc1dcef256fc3eb390d473f37fa079f475cf85e83845c50af156de67b1
|
data/lib/obf/pdf.rb
CHANGED
@@ -64,7 +64,7 @@ module OBF::PDF
|
|
64
64
|
multi_render = obj['boards'].length > 20
|
65
65
|
obj['boards'].each_with_index do |board, idx|
|
66
66
|
started = Time.now.to_i
|
67
|
-
|
67
|
+
OBF::Utils.log "starting pdf of board #{idx} #{board['name'] || board['id']} at #{started}"
|
68
68
|
pre = idx.to_f / obj['boards'].length.to_f
|
69
69
|
post = (idx + 1).to_f / obj['boards'].length.to_f
|
70
70
|
OBF::Utils.as_progress_percent(pre, post) do
|
@@ -101,7 +101,7 @@ module OBF::PDF
|
|
101
101
|
})
|
102
102
|
end
|
103
103
|
end
|
104
|
-
|
104
|
+
OBF::Utils.log " finished pdf of board #{idx}/#{obj['boards'].length} #{Time.now.to_i - started}s"
|
105
105
|
end
|
106
106
|
else
|
107
107
|
build_page(pdf, obj, {
|
@@ -185,7 +185,7 @@ module OBF::PDF
|
|
185
185
|
button_width = (grid_width - (padding * (obj['grid']['columns'] - 1))) / obj['grid']['columns'].to_f
|
186
186
|
|
187
187
|
# Grab all the images per board in parallel
|
188
|
-
|
188
|
+
OBF::Utils.log " batch-retrieving remote images"
|
189
189
|
hydra = Typhoeus::Hydra.hydra
|
190
190
|
grabs = []
|
191
191
|
obj['buttons'].each do |btn|
|
@@ -204,7 +204,7 @@ module OBF::PDF
|
|
204
204
|
grab[:image]['raw_data'] = grab[:req].response.body
|
205
205
|
grab[:image]['content_type'] = grab[:req].response.headers['Content-Type'] if grab[:req].response.headers['Content-Type']
|
206
206
|
end
|
207
|
-
|
207
|
+
OBF::Utils.log " done with #{grabs.length} remote images!"
|
208
208
|
|
209
209
|
obj['grid']['order'].each_with_index do |buttons, row|
|
210
210
|
buttons.each_with_index do |button_id, col|
|
data/lib/obf/utils.rb
CHANGED
@@ -132,6 +132,7 @@ module OBF::Utils
|
|
132
132
|
str
|
133
133
|
end
|
134
134
|
|
135
|
+
|
135
136
|
def self.save_image(image, zipper=nil, background=nil)
|
136
137
|
if image['data']
|
137
138
|
if !image['content_type']
|
@@ -146,9 +147,9 @@ module OBF::Utils
|
|
146
147
|
image['content_type'] = types[0] && types[0].to_s
|
147
148
|
end
|
148
149
|
elsif image['url']
|
149
|
-
|
150
|
+
OBF::Utils.log " retrieving #{image['url']}"
|
150
151
|
url_data = get_url(image['url'])
|
151
|
-
|
152
|
+
OBF::Utils.log " done!"
|
152
153
|
image['raw_data'] = url_data['data']
|
153
154
|
image['content_type'] = url_data['content_type']
|
154
155
|
elsif image['symbol']
|
@@ -184,17 +185,17 @@ module OBF::Utils
|
|
184
185
|
size = 400
|
185
186
|
path = file.path
|
186
187
|
if image['content_type'] && image['content_type'].match(/svg/)
|
187
|
-
|
188
|
+
OBF::Utils.log " convert -background \"#{background}\" -density 300 -resize #{size}x#{size} -gravity center -extent #{size}x#{size} #{file.path} -flatten #{file.path}.jpg"
|
188
189
|
`convert -background "#{background}" -density 300 -resize #{size}x#{size} -gravity center -extent #{size}x#{size} #{file.path} -flatten #{file.path}.jpg`
|
189
190
|
# `rsvg-convert -w #{size} -h #{size} -a #{file.path} > #{file.path}.png`
|
190
191
|
path = "#{file.path}.jpg"
|
191
192
|
else
|
192
|
-
|
193
|
+
OBF::Utils.log " convert #{path} -density 300 -resize #{size}x#{size} -background "#{background}" -gravity center -extent #{size}x#{size} -flatten #{path}.jpg"
|
193
194
|
`convert #{path} -density 300 -resize #{size}x#{size} -background "#{background}" -gravity center -extent #{size}x#{size} -flatten #{path}.jpg`
|
194
195
|
path = "#{path}.jpg"
|
195
196
|
end
|
196
197
|
|
197
|
-
|
198
|
+
OBF::Utils.log " finished image"
|
198
199
|
path
|
199
200
|
end
|
200
201
|
end
|
@@ -344,7 +345,7 @@ module OBF::Utils
|
|
344
345
|
file.close
|
345
346
|
end
|
346
347
|
end
|
347
|
-
|
348
|
+
OBF::Utils.log "file not found, #{path}" if !File.exist?(path)
|
348
349
|
data = `identify -verbose #{path}`
|
349
350
|
data.split(/\n/).each do |line|
|
350
351
|
pre, post = line.sub(/^\s+/, '').split(/:\s/, 2)
|
@@ -410,6 +411,14 @@ module OBF::Utils
|
|
410
411
|
attrs
|
411
412
|
end
|
412
413
|
end
|
414
|
+
|
415
|
+
def self.log(str)
|
416
|
+
if defined?(Rails)
|
417
|
+
Rails.logger.info(str)
|
418
|
+
else
|
419
|
+
puts str
|
420
|
+
end
|
421
|
+
end
|
413
422
|
|
414
423
|
def self.load_zip(path, &block)
|
415
424
|
require 'zip'
|