json_checker 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/json_checker/html_output.rb +11 -12
- data/lib/json_checker/json_fetcher.rb +11 -6
- data/lib/json_checker/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OTRkN2Y3Y2ZhNTgwM2IxOTM3N2ZiMjMyMWRhZDJkNmRlY2FlYjJiZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZjUwZmYxYzQyMjIzZDk2ZjhmYmZhMzcwNGJhMDk5MGYyZjNlYTQ4Mg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NjI2MGM2ZTVjYjhhYmFiZWZiNjA2NzVlNTk1ODQ4YWQ4YTkxN2RiOWRiZmRj
|
10
|
+
MDBjMjcwNTY0MDg1ZmM0NDM2ZTg2YWI3MjJmNjgzNzIzYzZmNTIyYjM5NDY2
|
11
|
+
ZjM2MmEyZDIwYjcwNDlkYjIyNGEyYTk4NzkyNWNhNWMxZDU3ODY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YThiYjhjMWU4MmM5MjJmMDM1ZGNmOTc4OTIyYjE0ZTA5NmRmZTM5Yzk3NDQ0
|
14
|
+
NGYyOWE3MDhmZmI4ZjYzNGY1YmJjYTRjZmIxNjg5MmI3NWU1ZTdkY2QwY2Q0
|
15
|
+
ZmMxNTEzNTc4NmFhZGY4OWNkNWFjODYzZjM5ZmQwMzM2YTAxYTE=
|
@@ -10,18 +10,13 @@ module JsonChecker
|
|
10
10
|
item = "<h2>#{title}</h2>"
|
11
11
|
item << "<div class=\"validation\" style=\"overflow-x:auto;\">
|
12
12
|
<table><tr><th>Status</th><th>Key</th><th>Expected</th><th>Value</th></tr>"
|
13
|
-
|
13
|
+
|
14
14
|
values.each do |value|
|
15
|
-
item
|
15
|
+
item << value
|
16
16
|
end
|
17
17
|
|
18
18
|
item << "</table></div>"
|
19
|
-
|
20
|
-
if @reportItems.nil?
|
21
|
-
@reportItems = Array.new()
|
22
|
-
end
|
23
|
-
|
24
|
-
@reportItems << item
|
19
|
+
HTMLOutput.add_item(item)
|
25
20
|
end
|
26
21
|
|
27
22
|
def self.add_comparation_item(title, json)
|
@@ -31,10 +26,7 @@ module JsonChecker
|
|
31
26
|
end
|
32
27
|
|
33
28
|
item = "<h2>#{title}</h2>" + "<div class=\"diff\">" + json + "</div>"
|
34
|
-
|
35
|
-
@reportItems = Array.new()
|
36
|
-
end
|
37
|
-
@reportItems << item
|
29
|
+
HTMLOutput.add_item(item)
|
38
30
|
end
|
39
31
|
|
40
32
|
def self.generate_output()
|
@@ -48,6 +40,13 @@ module JsonChecker
|
|
48
40
|
htmlOutput.save_to_file(output)
|
49
41
|
end
|
50
42
|
|
43
|
+
def self.add_item(item)
|
44
|
+
if @reportItems.nil?
|
45
|
+
@reportItems = Array.new()
|
46
|
+
end
|
47
|
+
@reportItems << item
|
48
|
+
end
|
49
|
+
|
51
50
|
def add_style()
|
52
51
|
return "<style>
|
53
52
|
.addition { background: #eaffea; }
|
@@ -21,12 +21,7 @@ module JsonChecker
|
|
21
21
|
begin
|
22
22
|
uri = URI(url)
|
23
23
|
response = Net::HTTP.get_response(uri)
|
24
|
-
|
25
|
-
when Net::HTTPSuccess then
|
26
|
-
return JSONFetcher.json_from_content(response.body)
|
27
|
-
else
|
28
|
-
puts"[ERROR] Connection error"
|
29
|
-
end
|
24
|
+
return JSONFetcher.fetch_response(response)
|
30
25
|
rescue
|
31
26
|
end
|
32
27
|
|
@@ -45,5 +40,15 @@ module JsonChecker
|
|
45
40
|
end
|
46
41
|
return nil
|
47
42
|
end
|
43
|
+
|
44
|
+
def self.fetch_response(response)
|
45
|
+
case response
|
46
|
+
when Net::HTTPSuccess then
|
47
|
+
return JSONFetcher.json_from_content(response.body)
|
48
|
+
else
|
49
|
+
puts"[ERROR] Connection error"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
48
53
|
end
|
49
54
|
end
|
data/lib/json_checker/version.rb
CHANGED