json_check 0.0.3 → 0.0.4
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/json_check.rb +15 -14
- 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: 32c38a04db2895fbfb2982e8dfaad61220f14adb
|
4
|
+
data.tar.gz: bca09c6b39dcbc5ad182e9ad9e2d03980a5b9d33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ae324b7bf3f035986590d8313f9493aa3749fbd303e0c12099343d4d00dde022487c0f3294b6307f22f4421e7e70e62aa5cd18a9b8b1bc5f4e522b8e2aca7b2
|
7
|
+
data.tar.gz: 294af175dea635249ab4b1a4ba34e6958413547381e614950f7ee35b8666c619967e78a88a93fe3fc11c0fdc148c958d96101fd008dff950af11f948e4d02b73
|
data/lib/json_check.rb
CHANGED
@@ -19,7 +19,7 @@ module JSON_check
|
|
19
19
|
|
20
20
|
@@permissible_params = {
|
21
21
|
'Integer' => ['null', 'required', 'enum', 'compare'],
|
22
|
-
'Float' => ['null', 'required', 'enum', 'compare'],
|
22
|
+
'Float' => ['null', 'required', 'enum', 'compare', 'integer'],
|
23
23
|
'String' => ['null', 'required', 'enum', 'mask'],
|
24
24
|
'Boolean' => ['null', 'required', 'enum'],
|
25
25
|
'URL' => ['null', 'required', 'mask'],
|
@@ -177,7 +177,7 @@ module JSON_check
|
|
177
177
|
change_status
|
178
178
|
end
|
179
179
|
when 'Float'
|
180
|
-
unless check_float value, c_p[
|
180
|
+
unless check_float value, c_p['null'], c_p['integer']
|
181
181
|
add({key=>value}, num != last, "It must be Float")
|
182
182
|
failure = true
|
183
183
|
change_status
|
@@ -212,7 +212,7 @@ module JSON_check
|
|
212
212
|
unless failure or value.nil?
|
213
213
|
status = 0
|
214
214
|
attempt = 0
|
215
|
-
while status != 200 and attempt <
|
215
|
+
while status != 200 and attempt < 8
|
216
216
|
status = url_status(value)
|
217
217
|
attempt += 1
|
218
218
|
end
|
@@ -343,31 +343,31 @@ module JSON_check
|
|
343
343
|
end
|
344
344
|
case ptn['type']
|
345
345
|
when 'Integer'
|
346
|
-
unless check_int value,
|
346
|
+
unless check_int value, ptn['null']
|
347
347
|
add([value], num != last, "It must be Integer")
|
348
348
|
failure = true
|
349
349
|
change_status
|
350
350
|
end
|
351
351
|
when 'Float'
|
352
|
-
unless check_float value,
|
352
|
+
unless check_float value, ptn['null'], ptn['integer']
|
353
353
|
add([value], num != last, "It must be Float")
|
354
354
|
failure = true
|
355
355
|
change_status
|
356
356
|
end
|
357
357
|
when 'String'
|
358
|
-
unless check_str value,
|
358
|
+
unless check_str value, ptn['null']
|
359
359
|
add([value], num != last, "It must be String")
|
360
360
|
failure = true
|
361
361
|
change_status
|
362
362
|
end
|
363
363
|
when 'Boolean'
|
364
|
-
unless check_bool value,
|
364
|
+
unless check_bool value, ptn['null']
|
365
365
|
add([value], num != last, "It must be Boolean")
|
366
366
|
failure = true
|
367
367
|
change_status
|
368
368
|
end
|
369
369
|
when 'URL'
|
370
|
-
unless check_url value,
|
370
|
+
unless check_url value, ptn['null']
|
371
371
|
add([value], num != last, "It must be URL")
|
372
372
|
failure = true
|
373
373
|
change_status
|
@@ -375,7 +375,7 @@ module JSON_check
|
|
375
375
|
unless failure
|
376
376
|
status = 0
|
377
377
|
attempt = 0
|
378
|
-
while status != 200 and attempt <
|
378
|
+
while status != 200 and attempt < 8
|
379
379
|
status = url_status(value)
|
380
380
|
attempt += 1
|
381
381
|
end
|
@@ -392,7 +392,7 @@ module JSON_check
|
|
392
392
|
end
|
393
393
|
end
|
394
394
|
when 'Array'
|
395
|
-
unless check_array value,
|
395
|
+
unless check_array value, ptn['null']
|
396
396
|
add([value], num != last, "It must be Array")
|
397
397
|
failure = true
|
398
398
|
change_status
|
@@ -410,7 +410,7 @@ module JSON_check
|
|
410
410
|
num += 1
|
411
411
|
next
|
412
412
|
when 'Hash'
|
413
|
-
unless check_hash value,
|
413
|
+
unless check_hash value, ptn['null']
|
414
414
|
add([value], num != last, "It must be Hash")
|
415
415
|
failure = true
|
416
416
|
change_status
|
@@ -521,9 +521,10 @@ module JSON_check
|
|
521
521
|
return arg.class == Fixnum
|
522
522
|
end
|
523
523
|
|
524
|
-
def self.check_float arg, null
|
524
|
+
def self.check_float arg, null, integer
|
525
525
|
return true if null && arg.class == NilClass
|
526
|
-
return
|
526
|
+
return true if integer && arg.class == Fixnum
|
527
|
+
return arg.class == Float
|
527
528
|
end
|
528
529
|
|
529
530
|
def self.check_null arg
|
@@ -611,7 +612,7 @@ module JSON_check
|
|
611
612
|
begin
|
612
613
|
link = URI.parse(url)
|
613
614
|
resp = Net::HTTP.start(link.host){|http|
|
614
|
-
http.read_timeout =
|
615
|
+
http.read_timeout = 30
|
615
616
|
http.head(link)
|
616
617
|
}
|
617
618
|
http_status = resp.code.to_i
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json_check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Motin Artem
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|