seo_checker 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/seo_checker.rb +21 -3
- data/seo_checker.gemspec +2 -2
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/lib/seo_checker.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'enumerator'
|
2
2
|
require 'logger'
|
3
|
+
require 'zlib'
|
4
|
+
require 'stringio'
|
3
5
|
require 'net/http'
|
4
6
|
require 'uri'
|
5
7
|
|
@@ -36,14 +38,30 @@ class SEOChecker
|
|
36
38
|
|
37
39
|
def check_sitemap
|
38
40
|
#TODO: allow manual sitemap file
|
39
|
-
|
41
|
+
check_plain_sitemap
|
42
|
+
check_gzip_sitemap if @locations.empty?
|
43
|
+
|
44
|
+
raise SEOException, "Error: There is no sitemap.xml or sitemap.xml.gz" if @locations.empty?
|
45
|
+
end
|
46
|
+
|
47
|
+
def check_plain_sitemap
|
48
|
+
@logger.debug "checking sitemap.xml file" if @logger
|
40
49
|
uri = URI.parse(@url)
|
41
50
|
uri.path = '/sitemap.xml'
|
42
51
|
response = get_response(uri)
|
43
52
|
if response.is_a? Net::HTTPSuccess
|
44
53
|
@locations = response.body.scan(%r{<loc>(.*?)</loc>}).flatten
|
45
|
-
|
46
|
-
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def check_gzip_sitemap
|
58
|
+
@logger.debug "checking sitemap.xml.gz file" if @logger
|
59
|
+
uri = URI.parse(@url)
|
60
|
+
uri.path = '/sitemap.xml.gz'
|
61
|
+
response = get_response(uri)
|
62
|
+
if response.is_a? Net::HTTPSuccess
|
63
|
+
body_io = StringIO.new(response.body)
|
64
|
+
@locations = Zlib::GzipReader.new(body_io).read.scan(%r{<loc>(.*?)</loc>}).flatten
|
47
65
|
end
|
48
66
|
end
|
49
67
|
|
data/seo_checker.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{seo_checker}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Richard Huang"]
|
12
|
-
s.date = %q{2010-03-
|
12
|
+
s.date = %q{2010-03-05}
|
13
13
|
s.description = %q{seo_checker check your website if it is seo.}
|
14
14
|
s.email = %q{flyerhzm@gmail.com}
|
15
15
|
s.executables = ["seo_checker", "seo_checker"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seo_checker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-03-
|
12
|
+
date: 2010-03-05 00:00:00 +08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|