seo_checker 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -29,6 +29,7 @@ It is strongly recommand to check seo in development environment. If you want to
29
29
  Usage: seo_checker [OPTIONS] website_url
30
30
  -b, --batch BATCH_SIZE get a batch size of pages
31
31
  -i, --interval INTERVAL_TIME interval time between two batches
32
+ --debug
32
33
  -h, --help Show this message
33
34
  </code></pre>
34
35
 
@@ -36,4 +37,4 @@ For example:
36
37
 
37
38
  <pre><code>seo_checker http://localhost:3000</code></pre>
38
39
 
39
- <pre><code>seo_checker http://yoursite.com -b 10 -i 1</code></pre>
40
+ <pre><code>seo_checker http://yoursite.com --debug -b 10 -i 1</code></pre>
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
data/bin/seo_checker CHANGED
@@ -15,6 +15,10 @@ OptionParser.new do |opts|
15
15
  options[:interval_time] = interval
16
16
  end
17
17
 
18
+ opts.on('--debug') do
19
+ options[:logger] = true
20
+ end
21
+
18
22
  opts.on_tail('-h', '--help', 'Show this message') do
19
23
  puts opts
20
24
  exit
data/lib/seo_checker.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'enumerator'
2
+ require 'logger'
2
3
  require 'net/http'
3
4
  require 'uri'
4
5
 
@@ -19,6 +20,7 @@ class SEOChecker
19
20
  @unreachables = []
20
21
  @batch_size = options[:batch_size] ? options[:batch_size].to_i : nil
21
22
  @interval_time = options[:interval_time].to_i
23
+ @logger = options[:logger] == true ? Logger.new(STDOUT) : options[:logger]
22
24
  end
23
25
 
24
26
  def check
@@ -34,6 +36,7 @@ class SEOChecker
34
36
 
35
37
  def check_sitemap
36
38
  #TODO: allow manual sitemap file
39
+ @logger.debug "checking sitemap file" if @logger
37
40
  uri = URI.parse(@url)
38
41
  uri.path = '/sitemap.xml'
39
42
  response = get_response(uri)
@@ -48,6 +51,7 @@ class SEOChecker
48
51
  @batch_size ||= @locations.size
49
52
  @locations.each_slice(@batch_size) do |batch_locations|
50
53
  batch_locations.each do |location|
54
+ @logger.debug "checking #{location}" if @logger
51
55
  response = get_response(URI.parse(location))
52
56
  if response.is_a? Net::HTTPSuccess
53
57
  if response.body =~ %r{<head>(.*?)</head>}m
@@ -75,7 +79,7 @@ class SEOChecker
75
79
  end
76
80
 
77
81
  def check_title(header_string, location)
78
- if header_string =~ %r{<title>(.*?)</title>}
82
+ if header_string =~ %r{<title>(.*?)</title>} && $1 != ''
79
83
  title = $1
80
84
  (@titles[title] ||= []) << location
81
85
  else
@@ -106,33 +110,27 @@ class SEOChecker
106
110
  end
107
111
 
108
112
  def report
109
- unless @unreachables.empty?
110
- print "#{@unreachables.slice(0, 5).join(",\n")} #{'and ...' if @unreachables.size > 5} are unreachable.\n\n"
111
- end
112
- unless @no_titles.empty?
113
- print "#{@no_titles.slice(0, 5).join(",\n")} #{'and ...' if @no_titles.size > 5} have no title.\n\n"
114
- end
115
- unless @no_descriptions.empty?
116
- print "#{@no_descriptions.slice(0, 5).join(",\n")} #{'and ...' if @no_descriptions.size > 5} have no description.\n\n"
117
- end
118
- @titles.each do |title, locations|
119
- if locations.size > 1
120
- print "#{locations.slice(0, 5).join(",\n")} #{'and ...' if locations.size > 5} have the same title '#{title}'.\n\n"
121
- end
122
- end
123
- @descriptions.each do |description, locations|
113
+ report_non_empty(@unreachables, "are unreachable.")
114
+ report_non_empty(@no_titles, "have no title.")
115
+ report_non_empty(@no_descriptions, "have no description.")
116
+ report_same(@titles, 'title')
117
+ report_same(@descriptions, 'description')
118
+ report_non_empty(@id_urls.values, "use ID number in URL.")
119
+ report_non_empty(@excessive_keywords, "use excessive keywords in URL.")
120
+ report_non_empty(@nesting_subdirectories, "have deep nesting of subdirectories in URL.")
121
+ end
122
+
123
+ def report_same(variables, name)
124
+ variables.each do |variable, locations|
124
125
  if locations.size > 1
125
- print "#{locations.slice(0, 5).join(",\n")} #{'and ...' if locations.size > 5} have the same description '#{description}'.\n\n"
126
+ print "#{locations.slice(0, 5).join(",\n")} #{'and ...' if locations.size > 5} have the same #{name} '#{variable}'.\n\n"
126
127
  end
127
128
  end
128
- unless @id_urls.empty?
129
- print "#{@id_urls.values.slice(0, 5).join(",\n")} #{'and ...' if @id_urls.values.size > 5} use ID number in URL.\n\n"
130
- end
131
- unless @excessive_keywords.empty?
132
- print "#{@excessive_keywords.slice(0, 5).join(",\n")} #{'and ...' if @excessive_keywords.size > 5} use excessive keywords in URL.\n\n"
133
- end
134
- unless @nesting_subdirectories.empty?
135
- print "#{@nesting_subdirectories.slice(0, 5).join(",\n")} #{'and ...' if @nesting_subdirectories.size > 5} have deep nesting of subdirectories in URL.\n\n"
129
+ end
130
+
131
+ def report_non_empty(variables, suffix)
132
+ unless variables.empty?
133
+ print "#{variables.slice(0, 5).join(",\n")} #{'and ...' if variables.size > 5} #{suffix}\n\n"
136
134
  end
137
135
  end
138
136
  end
data/seo_checker.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{seo_checker}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
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"]
@@ -27,32 +27,32 @@ Gem::Specification.new do |s|
27
27
  s.homepage = %q{http://github.com/flyerhzm/seo_checker}
28
28
  s.rdoc_options = ["--charset=UTF-8"]
29
29
  s.require_paths = ["lib"]
30
- s.rubygems_version = %q{1.3.6}
30
+ s.rubygems_version = %q{1.3.5}
31
31
  s.summary = %q{seo_checker check your website if it is seo.}
32
32
  s.test_files = [
33
- "examples/bad_seo/app/controllers/application_controller.rb",
34
- "examples/bad_seo/app/controllers/posts_controller.rb",
35
- "examples/bad_seo/app/helpers/application_helper.rb",
36
- "examples/bad_seo/app/helpers/posts_helper.rb",
37
- "examples/bad_seo/app/models/post.rb",
38
- "examples/bad_seo/config/boot.rb",
39
- "examples/bad_seo/config/environment.rb",
40
- "examples/bad_seo/config/environments/development.rb",
41
- "examples/bad_seo/config/environments/production.rb",
33
+ "examples/bad_seo/config/routes.rb",
42
34
  "examples/bad_seo/config/initializers/backtrace_silencers.rb",
43
- "examples/bad_seo/config/initializers/inflections.rb",
44
- "examples/bad_seo/config/initializers/mime_types.rb",
45
35
  "examples/bad_seo/config/initializers/new_rails_defaults.rb",
46
36
  "examples/bad_seo/config/initializers/session_store.rb",
47
- "examples/bad_seo/config/routes.rb",
48
- "examples/bad_seo/db/migrate/20100228140057_create_posts.rb",
49
- "examples/bad_seo/db/schema.rb",
50
- "examples/bad_seo/db/seeds.rb",
51
- "examples/bad_seo/test/functional/posts_controller_test.rb",
52
- "examples/bad_seo/test/performance/browsing_test.rb",
37
+ "examples/bad_seo/config/initializers/inflections.rb",
38
+ "examples/bad_seo/config/initializers/mime_types.rb",
39
+ "examples/bad_seo/config/environment.rb",
40
+ "examples/bad_seo/config/boot.rb",
41
+ "examples/bad_seo/config/environments/production.rb",
42
+ "examples/bad_seo/config/environments/development.rb",
53
43
  "examples/bad_seo/test/test_helper.rb",
44
+ "examples/bad_seo/test/performance/browsing_test.rb",
45
+ "examples/bad_seo/test/functional/posts_controller_test.rb",
54
46
  "examples/bad_seo/test/unit/helpers/posts_helper_test.rb",
55
- "examples/bad_seo/test/unit/post_test.rb"
47
+ "examples/bad_seo/test/unit/post_test.rb",
48
+ "examples/bad_seo/db/migrate/20100228140057_create_posts.rb",
49
+ "examples/bad_seo/db/seeds.rb",
50
+ "examples/bad_seo/db/schema.rb",
51
+ "examples/bad_seo/app/helpers/application_helper.rb",
52
+ "examples/bad_seo/app/helpers/posts_helper.rb",
53
+ "examples/bad_seo/app/models/post.rb",
54
+ "examples/bad_seo/app/controllers/application_controller.rb",
55
+ "examples/bad_seo/app/controllers/posts_controller.rb"
56
56
  ]
57
57
 
58
58
  if s.respond_to? :specification_version then
metadata CHANGED
@@ -1,12 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seo_checker
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 2
8
- - 0
9
- version: 0.2.0
4
+ version: 0.2.1
10
5
  platform: ruby
11
6
  authors:
12
7
  - Richard Huang
@@ -47,44 +42,42 @@ required_ruby_version: !ruby/object:Gem::Requirement
47
42
  requirements:
48
43
  - - ">="
49
44
  - !ruby/object:Gem::Version
50
- segments:
51
- - 0
52
45
  version: "0"
46
+ version:
53
47
  required_rubygems_version: !ruby/object:Gem::Requirement
54
48
  requirements:
55
49
  - - ">="
56
50
  - !ruby/object:Gem::Version
57
- segments:
58
- - 0
59
51
  version: "0"
52
+ version:
60
53
  requirements: []
61
54
 
62
55
  rubyforge_project:
63
- rubygems_version: 1.3.6
56
+ rubygems_version: 1.3.5
64
57
  signing_key:
65
58
  specification_version: 3
66
59
  summary: seo_checker check your website if it is seo.
67
60
  test_files:
68
- - examples/bad_seo/app/controllers/application_controller.rb
69
- - examples/bad_seo/app/controllers/posts_controller.rb
70
- - examples/bad_seo/app/helpers/application_helper.rb
71
- - examples/bad_seo/app/helpers/posts_helper.rb
72
- - examples/bad_seo/app/models/post.rb
73
- - examples/bad_seo/config/boot.rb
74
- - examples/bad_seo/config/environment.rb
75
- - examples/bad_seo/config/environments/development.rb
76
- - examples/bad_seo/config/environments/production.rb
61
+ - examples/bad_seo/config/routes.rb
77
62
  - examples/bad_seo/config/initializers/backtrace_silencers.rb
78
- - examples/bad_seo/config/initializers/inflections.rb
79
- - examples/bad_seo/config/initializers/mime_types.rb
80
63
  - examples/bad_seo/config/initializers/new_rails_defaults.rb
81
64
  - examples/bad_seo/config/initializers/session_store.rb
82
- - examples/bad_seo/config/routes.rb
83
- - examples/bad_seo/db/migrate/20100228140057_create_posts.rb
84
- - examples/bad_seo/db/schema.rb
85
- - examples/bad_seo/db/seeds.rb
86
- - examples/bad_seo/test/functional/posts_controller_test.rb
87
- - examples/bad_seo/test/performance/browsing_test.rb
65
+ - examples/bad_seo/config/initializers/inflections.rb
66
+ - examples/bad_seo/config/initializers/mime_types.rb
67
+ - examples/bad_seo/config/environment.rb
68
+ - examples/bad_seo/config/boot.rb
69
+ - examples/bad_seo/config/environments/production.rb
70
+ - examples/bad_seo/config/environments/development.rb
88
71
  - examples/bad_seo/test/test_helper.rb
72
+ - examples/bad_seo/test/performance/browsing_test.rb
73
+ - examples/bad_seo/test/functional/posts_controller_test.rb
89
74
  - examples/bad_seo/test/unit/helpers/posts_helper_test.rb
90
75
  - examples/bad_seo/test/unit/post_test.rb
76
+ - examples/bad_seo/db/migrate/20100228140057_create_posts.rb
77
+ - examples/bad_seo/db/seeds.rb
78
+ - examples/bad_seo/db/schema.rb
79
+ - examples/bad_seo/app/helpers/application_helper.rb
80
+ - examples/bad_seo/app/helpers/posts_helper.rb
81
+ - examples/bad_seo/app/models/post.rb
82
+ - examples/bad_seo/app/controllers/application_controller.rb
83
+ - examples/bad_seo/app/controllers/posts_controller.rb