obf 0.8.1 → 0.8.2

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: 7fa4899ce714401f07c3efb5de7b5f852ed973e8
4
- data.tar.gz: 5531558fe14f1d255b15188e47cf47147e934278
3
+ metadata.gz: 44736a323f88c6996ad1b669f4b6f9df4ee8a51a
4
+ data.tar.gz: 4432293b3a3197d5f0542e576a673f09168f88b2
5
5
  SHA512:
6
- metadata.gz: 1a757ced5cd7b21d16acca423951a43e16f879a02219e791689e68c58aeb470d5c18af3e6bdebe19f7c5bcbed33e9674dd2b710d9b3cffb621ce3485ab9242db
7
- data.tar.gz: 63fa5a8561e226e320fb6566867d2e1643cc53cb2de793cefe444223af1605e7141393f8f72d81297f0c2dc14bc985dc68012675c0d85333a124afb1665f807a
6
+ metadata.gz: 3669f2ae9bc8864dd926c614a6d5d090b4056a3e013b08013a3ffdbc845e1c127fe92e6b11c4d675a12d1cc8c12d52c4fa570a6fdb8215080202d7d2146ade5f
7
+ data.tar.gz: 6376f5ef17a123d6186608310eec61144fcd92e62570b74815b7468b2aabf0afbcdc63dbcf447626438be7f31016400836509b156c2756e6d5ee57044238ace2
data/lib/obf/utils.rb CHANGED
@@ -39,10 +39,14 @@ module OBF::Utils
39
39
  else
40
40
  json = JSON.parse(File.read(path)) rescue nil
41
41
  if json
42
- if json['format'] && json['format'].match(/^open-board-/)
43
- return :obf
42
+ if json.is_a?(Hash)
43
+ if json['format'] && json['format'].match(/^open-board-/)
44
+ return :obf
45
+ end
46
+ return :json_not_obf
47
+ else
48
+ return :json_not_object
44
49
  end
45
- return :unknown
46
50
  end
47
51
 
48
52
  begin
data/lib/obf/validator.rb CHANGED
@@ -44,7 +44,8 @@ module OBF
44
44
  elsif type == :obz
45
45
  validate_obz(path)
46
46
  else
47
- {
47
+ hint =
48
+ res = {
48
49
  :filename => fn,
49
50
  :filesize => filesize,
50
51
  :valid => false,
@@ -53,9 +54,25 @@ module OBF
53
54
  'type' => 'valid_file',
54
55
  'description' => 'valid .obf or .obz file',
55
56
  'valid' => false,
56
- 'error' => 'file must be an .obf JSON file or a .obz zip package'
57
+ 'error' => 'file must be a single .obf JSON file or a .obz zip package'
57
58
  }]
58
59
  }
60
+ if type == :json_not_obf
61
+ res[:results] << {
62
+ 'type' => 'json_parse',
63
+ 'description' => 'valid JSON object',
64
+ 'valid' => false,
65
+ 'error' => 'file contains a JSON object but it does not appear to be an OBF-formatted object'
66
+ }
67
+ elsif type == :json_not_object
68
+ res[:results] << {
69
+ 'type' => 'json_parse',
70
+ 'description' => 'valid JSON object',
71
+ 'valid' => false,
72
+ 'error' => 'file contains valid JSON, but a type other than Object. OBF files do not support arrays, strings, etc. as the root object'
73
+ }
74
+ end
75
+ res
59
76
  end
60
77
  end
61
78
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: obf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Whitmer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-28 00:00:00.000000000 Z
11
+ date: 2017-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json