File tree 2 files changed +0
-46
lines changed
2 files changed +0
-46
lines changed Original file line number Diff line number Diff line change @@ -3,5 +3,3 @@ source "https://rubygems.org"
3
3
gem "rake"
4
4
gem "json"
5
5
gem "json-schema"
6
- gem "httparty"
7
- gem "work_queue"
Original file line number Diff line number Diff line change 1
1
require "json"
2
2
require "json-schema"
3
- require "httparty"
4
- require "work_queue"
5
3
6
4
task default : "validate:json"
7
5
@@ -10,46 +8,4 @@ namespace :validate do
10
8
task :json do
11
9
JSON ::Validator . validate! ( "schema_blogs.json" , "blogs.json" )
12
10
end
13
-
14
- desc "Ping each site and feed URLs and report any failures"
15
- task :ping do
16
- wq = WorkQueue . new 30
17
- # The top level of the JSON file contains an array of languages
18
- urls = Array . new
19
- languages = JSON . parse ( File . read ( "blogs.json" ) )
20
- languages . each do |language |
21
- # Inside each language is an array of categories
22
- language [ "categories" ] . each do |category |
23
- # Inside each category is a list of sites
24
- category [ "sites" ] . each do |site |
25
- urls . push ( URI ( site [ "site_url" ] ) )
26
- urls . push ( URI ( site [ "feed_url" ] ) )
27
- end
28
- end
29
- end
30
-
31
- urls . each do |url |
32
- wq . enqueue_b do
33
- ping_url ( url )
34
- end
35
- end
36
-
37
- wq . join
38
- end
39
- end
40
-
41
- def ping_url ( url )
42
- begin
43
- response = HTTParty . head ( url , follow_redirects : true , timeout : 10 )
44
- # Anything other than a 200 is classed as a faulure
45
- puts "#{ response . code } for #{ url } " unless response . code == 200
46
- rescue Net ::OpenTimeout
47
- puts "Timeout for #{ url } "
48
- rescue OpenSSL ::SSL ::SSLError
49
- puts "SSL Error for #{ url } "
50
- rescue SocketError
51
- puts "Socket Error for #{ url } "
52
- rescue => exception
53
- puts "#{ exception . class } #{ exception } for #{ url } "
54
- end
55
11
end
You can’t perform that action at this time.
0 commit comments