obf 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8faab78bba51edf2380fb7fd4f08e42a856befe4
4
- data.tar.gz: 4ef8daa755a432f35b564106d4ad25adb37cf68e
3
+ metadata.gz: 8454639e83fc8b2def96962a5ba2e31791a362e5
4
+ data.tar.gz: 7e1abb111236636a50c09a0304810513ab4d30f2
5
5
  SHA512:
6
- metadata.gz: 46fe4f02a7214a189b6cf83ba403b774c9dfb8370d4a175a8351aee9fade357c29bf121db6f12726343217822466e4882693352b24c879fc48776e0185cd4023
7
- data.tar.gz: d5ad2444bfbdc5c941a28cae7c884e1f405ce10feda7852b9984a0a44b92992e18bb3beef61172fa8af43082978b48c858b539d578ee060a6bcaf20e29f6ebdf
6
+ metadata.gz: 288c13639fdf253583cc2c826c0d52cc9e57a21937207883c70618ca4f7837d23920169806811b3f6fcfd827335336a395290393810160648f91e079fe859411
7
+ data.tar.gz: 14418e8801345139b24dee027718e2a4ad6a9b11ab0112a8485b17f8e206dba3f5d75913a0a551f93de38018e0967aaa654685911081390b3ee1933617d7b3be
data/lib/obf/utils.rb CHANGED
@@ -265,6 +265,10 @@ module OBF::Utils
265
265
  def glob(path)
266
266
  @zipfile.glob(path)
267
267
  end
268
+
269
+ def all_files
270
+ @zipfile.entries.select{|e| e.file? }.map{|e| e.to_s }
271
+ end
268
272
 
269
273
  def read_as_data(path)
270
274
  attrs = {}
data/lib/obf/validator.rb CHANGED
@@ -193,17 +193,54 @@ module OBF
193
193
  end
194
194
  end
195
195
  end
196
- add_check('manifest_boards', 'manifest.json referenced boards') do
197
- end
198
196
 
199
- add_check('manifest_images', 'manifest.json referenced images') do
197
+ found_paths = ['manifest.json']
198
+ if json['paths'] && json['paths']['boards'] && json['paths']['boards'].is_a?(Hash)
199
+ json['paths']['boards'].each do |id, path|
200
+ add_check("manifest_boards[#{id}]", "manifest.json path.boards.#{id}") do
201
+ found_paths << path
202
+ if !zipper.glob(path)
203
+ err "board path (#{path}) not found in the zip package"
204
+ end
205
+ board_json = JSON.parse(zipper.read(path)) rescue nil
206
+ if !board_json || board_json['id'] != id
207
+ err "board at path (#{path}) defined in manifest with id \"#{id}\" but actually has id \"#{board_json['id']}\""
208
+ end
209
+ end
210
+ end
200
211
  end
201
212
 
202
- add_check('manifest_sounds', 'manifest.json referenced sounds') do
213
+ if json['paths'] && json['paths']['images'] && json['paths']['images'].id_a?(Hash)
214
+ json['paths']['images'].each do |id, path|
215
+ add_check("manifest_images[#{id}]", "manifest.json path.images.#{id}") do
216
+ found_paths << path
217
+ if !zipper.glob(path)
218
+ err "image path (#{path}) not found in the zip package"
219
+ end
220
+ end
221
+ end
222
+ end
223
+
224
+ if json['paths'] && json['paths']['sounds'] && json['paths']['sounds'].id_a?(Hash)
225
+ json['paths']['sounds'].each do |id, path|
226
+ add_check("manifest_sounds[#{id}]", "manifest.json path.sounds.#{id}") do
227
+ found_paths << path
228
+ if !zipper.glob(path)
229
+ err "sound path (#{path}) not found in the zip package"
230
+ end
231
+ end
232
+ end
233
+ end
234
+
235
+ actual_paths = zipper.all_files
236
+ add_check('extra_paths', 'manifest.json extra paths') do
237
+ (actual_paths - found_paths).each do |path|
238
+ warn "the file \"#{path}\" isn't listed in manifest.json"
239
+ end
203
240
  end
204
241
 
205
242
  sub_results = []
206
- if json['paths']['boards'] && json['paths']['boards'].is_a?(Hash)
243
+ if json['paths'] && json['paths']['boards'] && json['paths']['boards'].is_a?(Hash)
207
244
  json['paths']['boards'].each do |key, path|
208
245
  sub = Validator.validate_obf(path, {'zipper' => zipper})
209
246
  sub_results << sub
@@ -211,6 +248,7 @@ module OBF
211
248
  end
212
249
  @sub_checks = sub_results
213
250
  end
251
+
214
252
  if zipper.glob('manifest.json').length > 0
215
253
  json = JSON.parse(zipper.read('manifest.json')) rescue nil
216
254
  if json['root'] && json['format'] && json['format'].match(/^open-board-/)
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.3
4
+ version: 0.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Whitmer