doublecheck 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/doublecheck +8 -3
- data/lib/check_url.rb +10 -0
- data/lib/doublecheck.rb +1 -1
- data/lib/sitemap.rb +18 -6
- metadata +19 -5
- data/lib/test_url.rb +0 -17
data/bin/doublecheck
CHANGED
@@ -6,8 +6,13 @@ if ARGV[0].nil?
|
|
6
6
|
puts "USAGE: doublecheck http://example.com/sitemap.xml"
|
7
7
|
else
|
8
8
|
sitemap = DoubleCheck::Sitemap.new(ARGV[0])
|
9
|
-
sitemap.
|
10
|
-
|
11
|
-
|
9
|
+
sitemap.process
|
10
|
+
data = sitemap.data
|
11
|
+
data.each do |code, urls|
|
12
|
+
puts "Status Code: #{code}"
|
13
|
+
puts "#{urls.size} urls"
|
14
|
+
urls.each do |url|
|
15
|
+
puts "\t#{url}"
|
16
|
+
end
|
12
17
|
end
|
13
18
|
end
|
data/lib/check_url.rb
ADDED
data/lib/doublecheck.rb
CHANGED
data/lib/sitemap.rb
CHANGED
@@ -3,16 +3,28 @@ class DoubleCheck::Sitemap
|
|
3
3
|
require 'nokogiri'
|
4
4
|
|
5
5
|
def initialize(url)
|
6
|
-
@
|
6
|
+
@sitemap_url = url
|
7
|
+
@data = {}
|
7
8
|
end
|
8
9
|
|
9
|
-
def
|
10
|
-
doc = Nokogiri::XML(open(@
|
11
|
-
urls = []
|
10
|
+
def process
|
11
|
+
doc = Nokogiri::XML(open(@sitemap_url))
|
12
12
|
doc.css('loc').each do |url|
|
13
|
-
|
13
|
+
response = DoubleCheck::CheckUrl.get_response(url.content)
|
14
|
+
record_result(url.content, response)
|
14
15
|
end
|
15
|
-
|
16
|
+
end
|
17
|
+
|
18
|
+
def record_result(url, response)
|
19
|
+
if @data[response.code].nil?
|
20
|
+
@data[response.code] = [url]
|
21
|
+
else
|
22
|
+
@data[response.code].push(url)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def data
|
27
|
+
return @data
|
16
28
|
end
|
17
29
|
|
18
30
|
end
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: doublecheck
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: "0.
|
8
|
+
- 2
|
9
|
+
version: "0.2"
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Nathan Humbert
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-03-
|
17
|
+
date: 2011-03-24 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -48,6 +48,20 @@ dependencies:
|
|
48
48
|
version: "0"
|
49
49
|
type: :development
|
50
50
|
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: mocha
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 3
|
60
|
+
segments:
|
61
|
+
- 0
|
62
|
+
version: "0"
|
63
|
+
type: :development
|
64
|
+
version_requirements: *id003
|
51
65
|
description: Check URLs in a sitemap to make sure you have not introduced any issues.
|
52
66
|
email:
|
53
67
|
- nathan.humbert@gmail.com
|
@@ -61,7 +75,7 @@ files:
|
|
61
75
|
- README.markdown
|
62
76
|
- MIT_LICENSE
|
63
77
|
- bin/doublecheck
|
64
|
-
- lib/
|
78
|
+
- lib/check_url.rb
|
65
79
|
- lib/doublecheck.rb
|
66
80
|
- lib/sitemap.rb
|
67
81
|
has_rdoc: true
|
data/lib/test_url.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
class DoubleCheck::TestUrl
|
2
|
-
require 'uri'
|
3
|
-
def initialize(url)
|
4
|
-
@url = URI.parse(url)
|
5
|
-
end
|
6
|
-
|
7
|
-
def test
|
8
|
-
response = make_request
|
9
|
-
puts 'HTTP code: ' + response.code + ' for ' + @url.host + @url.path
|
10
|
-
end
|
11
|
-
|
12
|
-
def make_request
|
13
|
-
response = Net::HTTP.start(@url.host, @url.port) do |http|
|
14
|
-
http.get(@url.path)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|