obf 0.6.13 → 0.6.14
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/external.rb +16 -11
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8c10c2dae743466f7598663539f5217ce8dcb95
|
4
|
+
data.tar.gz: eaaf655f14ac7f999b4f798883bbe643c3030887
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2086258ef0e206331916219f38cd5dca25a7b70683ec5fd1e41d7167481027bc680e20b09e2f5acae0ab564c12c5d2245fb60b67b3770c56967a86f9c9c80d78
|
7
|
+
data.tar.gz: 8d044b03e5f00e352185503da7ff20ad603143ca492e991ecd9b23b1ca40194a3499775a6f1da27b8bce5a7869273a852376077d17ab35c967cb3c00a9177422
|
data/lib/obf/external.rb
CHANGED
@@ -81,7 +81,7 @@ module OBF::External
|
|
81
81
|
button['sound_id'] = sound['id']
|
82
82
|
end
|
83
83
|
end
|
84
|
-
res['buttons'] << button
|
84
|
+
res['buttons'] << trim_empties(button)
|
85
85
|
OBF::Utils.update_current_progress(idx.to_f / button_count.to_f)
|
86
86
|
end
|
87
87
|
|
@@ -97,7 +97,7 @@ module OBF::External
|
|
97
97
|
'content_type' => original_image['content_type']
|
98
98
|
}
|
99
99
|
if !path_hash
|
100
|
-
image['data']
|
100
|
+
image['data'] ||= OBF::Utils.image_base64(image['url']) if image['url']
|
101
101
|
else
|
102
102
|
if path_hash['images'] && path_hash['images'][image['id']]
|
103
103
|
image['path'] = path_hash['images'][image['id']]['path']
|
@@ -114,7 +114,7 @@ module OBF::External
|
|
114
114
|
end
|
115
115
|
end
|
116
116
|
end
|
117
|
-
res['images'] << image
|
117
|
+
res['images'] << trim_empties(image)
|
118
118
|
end
|
119
119
|
|
120
120
|
sounds.each do |original_sound|
|
@@ -147,7 +147,7 @@ module OBF::External
|
|
147
147
|
sound['path'] = zip_path
|
148
148
|
end
|
149
149
|
|
150
|
-
res['sounds'] << sound
|
150
|
+
res['sounds'] << trim_empties(sound)
|
151
151
|
end
|
152
152
|
|
153
153
|
res['grid'] = OBF::Utils.parse_grid(hash['grid']) # TODO: more robust parsing here
|
@@ -164,6 +164,14 @@ module OBF::External
|
|
164
164
|
return dest_path
|
165
165
|
end
|
166
166
|
|
167
|
+
def self.trim_empties(hash)
|
168
|
+
new_hash = {}
|
169
|
+
hash.each do |key, val|
|
170
|
+
new_hash[key] = val if val != nil
|
171
|
+
end
|
172
|
+
new_hash
|
173
|
+
end
|
174
|
+
|
167
175
|
def self.from_obf(obf_json_or_path, opts)
|
168
176
|
obj = obf_json_or_path
|
169
177
|
if obj.is_a?(String)
|
@@ -174,19 +182,16 @@ module OBF::External
|
|
174
182
|
|
175
183
|
['images', 'sounds'].each do |type|
|
176
184
|
(obj[type] || []).each do |item|
|
177
|
-
item['
|
178
|
-
if !item['data_or_url'] && item['path'] && opts['zipper']
|
185
|
+
if !item['data'] && item['path'] && opts['zipper']
|
179
186
|
content_type = item['content_type']
|
180
187
|
data = opts['zipper'].read(item['path'])
|
181
188
|
str = "data:" + content_type
|
182
189
|
str += ";base64," + Base64.strict_encode64(data)
|
183
|
-
|
184
|
-
item['data_or_url'] = str
|
190
|
+
item['data'] = str
|
185
191
|
end
|
186
|
-
item['data_or_url'] ||= item['url']
|
187
192
|
if item['path']
|
188
|
-
opts[
|
189
|
-
opts[
|
193
|
+
opts[type] ||= {}
|
194
|
+
opts[type][item['path']] ||= item
|
190
195
|
end
|
191
196
|
end
|
192
197
|
end
|