obf 0.6.13 → 0.6.14

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/external.rb +16 -11
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 38e2b9153c3f65d8e3fab0216892f769e76a5a3a
4
- data.tar.gz: decef2e81054b457e762409c0254c1ffac52390f
3
+ metadata.gz: a8c10c2dae743466f7598663539f5217ce8dcb95
4
+ data.tar.gz: eaaf655f14ac7f999b4f798883bbe643c3030887
5
5
  SHA512:
6
- metadata.gz: 61d0060ed0bfbfadaec1e36404bee843301f8ff55e03af4558b698b46a0a946dd5f2a7e067f6759412734a496b315b7f3626c0b9153c8f7b6c1ff651715627fd
7
- data.tar.gz: ea976460fc413420d3a6bcd9e1523a32c6418aebfea70064d1074fe1cf47ba57c73211bc0260db4d49a4fb17ab703235a3e323b3c291525c2d425c7db82e3623
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'] = OBF::Utils.image_base64(image['url']) if image['url']
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['data_or_url'] = item['data']
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
- record = klass.create(:user => opts['user'])
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[list] ||= {}
189
- opts[list][item['path']] ||= item
193
+ opts[type] ||= {}
194
+ opts[type][item['path']] ||= item
190
195
  end
191
196
  end
192
197
  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.6.13
4
+ version: 0.6.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Whitmer