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 +4 -4
- data/lib/obf/utils.rb +7 -3
- data/lib/obf/validator.rb +19 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44736a323f88c6996ad1b669f4b6f9df4ee8a51a
|
4
|
+
data.tar.gz: 4432293b3a3197d5f0542e576a673f09168f88b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
43
|
-
|
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
|
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.
|
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-
|
11
|
+
date: 2017-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|