json_checker 0.1.1 → 0.1.2

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NmU2YjE3NTcxMTE3Y2U1Y2ViYWE1MGM0ZmZhMGE0MTZjZGRlYWI3Nw==
4
+ OTRkN2Y3Y2ZhNTgwM2IxOTM3N2ZiMjMyMWRhZDJkNmRlY2FlYjJiZQ==
5
5
  data.tar.gz: !binary |-
6
- NTA0ZTdmY2JkODI0OWRkYzkwYzc2NDU4NjMxOGZlNDZiMWZhMmEwMg==
6
+ ZjUwZmYxYzQyMjIzZDk2ZjhmYmZhMzcwNGJhMDk5MGYyZjNlYTQ4Mg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZGVlZWQwOTAxMzg4ZTY3ZmEzNjk1NDM2NDdmOTcwMjhhODgwMmYwMjBlZGI5
10
- NTA3ZjdkNTc5Y2FjYjViZjEzNDYzMGI2YzQ4YmU0MmVhNjRiMWQ0MmZiZjBi
11
- ZjJlNWVmZjI4ODJlMTdmYjUxZTAyMmIzMjA2ZTYwN2JjZjRlMWI=
9
+ NjI2MGM2ZTVjYjhhYmFiZWZiNjA2NzVlNTk1ODQ4YWQ4YTkxN2RiOWRiZmRj
10
+ MDBjMjcwNTY0MDg1ZmM0NDM2ZTg2YWI3MjJmNjgzNzIzYzZmNTIyYjM5NDY2
11
+ ZjM2MmEyZDIwYjcwNDlkYjIyNGEyYTk4NzkyNWNhNWMxZDU3ODY=
12
12
  data.tar.gz: !binary |-
13
- MGFlOWQwNmYwNGExOGEzMzE0NWUwMWNlOGQ3YjY4MjQ0MWQ0OWIzMmVlMjg5
14
- MzI1Y2IxNDk1ZjVjZWJlMzlmNTZjMDMwOGNjOTJkMGYwMWQwMGQ2MzRjN2Y0
15
- NDYxNzVlOTkwOWZkNGNjNTNjMzAwYTU5MjU5YzVlMzhmNGRjMzY=
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 = item + value
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
- if @reportItems.nil?
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
- case response
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
@@ -1,3 +1,3 @@
1
1
  module JsonChecker
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_checker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cícero Duarte