doublecheck 0.1

Sign up to get free protection for your applications and to get access to all the features.
data/MIT_LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2010 Nathan Humbert
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,14 @@
1
+ # doublecheck
2
+
3
+ doublecheck is a gem that pulls a sitemap and checks all of the URLs listed in it.
4
+
5
+ ## Install
6
+
7
+ gem install rcov
8
+
9
+
10
+ ## Usage
11
+
12
+ doublecheck http://example.com/sitemap.xml
13
+
14
+
data/bin/doublecheck ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'doublecheck'
4
+
5
+ if ARGV[0].nil?
6
+ puts "USAGE: doublecheck http://example.com/sitemap.xml"
7
+ else
8
+ sitemap = DoubleCheck::Sitemap.new(ARGV[0])
9
+ sitemap.urls.each do |url|
10
+ test_url = DoubleCheck::TestUrl.new(url)
11
+ test_url.test
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ module DoubleCheck
2
+ require 'rubygems'
3
+ require 'sitemap'
4
+ require 'test_url'
5
+ end
data/lib/sitemap.rb ADDED
@@ -0,0 +1,18 @@
1
+ class DoubleCheck::Sitemap
2
+ require 'open-uri'
3
+ require 'nokogiri'
4
+
5
+ def initialize(url)
6
+ @url = url
7
+ end
8
+
9
+ def urls
10
+ doc = Nokogiri::XML(open(@url))
11
+ urls = []
12
+ doc.css('loc').each do |url|
13
+ urls.push(url.content)
14
+ end
15
+ return urls
16
+ end
17
+
18
+ end
data/lib/test_url.rb ADDED
@@ -0,0 +1,17 @@
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
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: doublecheck
3
+ version: !ruby/object:Gem::Version
4
+ hash: 9
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ version: "0.1"
10
+ platform: ruby
11
+ authors:
12
+ - Nathan Humbert
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-03-11 00:00:00 -08:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: nokogiri
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 113
29
+ segments:
30
+ - 1
31
+ - 4
32
+ - 3
33
+ - 1
34
+ version: 1.4.3.1
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: fakeweb
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 3
46
+ segments:
47
+ - 0
48
+ version: "0"
49
+ type: :development
50
+ version_requirements: *id002
51
+ description: Check URLs in a sitemap to make sure you have not introduced any issues.
52
+ email:
53
+ - nathan.humbert@gmail.com
54
+ executables:
55
+ - doublecheck
56
+ extensions: []
57
+
58
+ extra_rdoc_files: []
59
+
60
+ files:
61
+ - README.markdown
62
+ - MIT_LICENSE
63
+ - bin/doublecheck
64
+ - lib/test_url.rb
65
+ - lib/doublecheck.rb
66
+ - lib/sitemap.rb
67
+ has_rdoc: true
68
+ homepage: https://github.com/nathanhumbert/doublecheck
69
+ licenses:
70
+ - MIT
71
+ post_install_message:
72
+ rdoc_options: []
73
+
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ hash: 3
82
+ segments:
83
+ - 0
84
+ version: "0"
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ hash: 3
91
+ segments:
92
+ - 0
93
+ version: "0"
94
+ requirements: []
95
+
96
+ rubyforge_project:
97
+ rubygems_version: 1.3.7
98
+ signing_key:
99
+ specification_version: 3
100
+ summary: Check URLs listed in a sitemap
101
+ test_files: []
102
+