search_engine_submitter 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ bundler_stubs/
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.8.7"
4
+ - "1.9.2"
5
+ - "1.9.3"
6
+ - jruby-18mode # JRuby in 1.8 mode
7
+ - jruby-19mode # JRuby in 1.9 mode
8
+ - rbx-18mode
9
+ - rbx-19mode
10
+ - ree
11
+ # uncomment this line if your project needs to run something other than `rake`:
12
+ # script: bundle exec rspec spec
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in search_engine_submitter.gemspec
4
+ gemspec
5
+
6
+ group :test do
7
+ gem 'rake'
8
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Scott McCormack
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # SearchEngineSubmitter [![Build Status](https://secure.travis-ci.org/flintinatux/search_engine_submitter.png)](http://travis-ci.org/flintinatux/search_engine_submitter) [![Dependency Status](https://gemnasium.com/flintinatux/search_engine_submitter.png)](https://gemnasium.com/flintinatux/search_engine_submitter) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/flintinatux/search_engine_submitter)
2
+
3
+ A tool to make the submission of sitemaps and RSS/Atom feeds to search engines as painless as possible. Use it to notify Big-G and friends of updates to your blog, or to ping newly created backlinks for your latest SEO campaign.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'search_engine_submitter'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install search_engine_submitter
18
+
19
+ ## Usage
20
+
21
+ To submit a sitemap or RSS feed url to all three major search engines:
22
+
23
+ ```ruby
24
+ require 'search_engine_submitter'
25
+ my_sitemap = 'http://testdomain.com/sitemap.xml'
26
+ SearchEngineSubmitter.submit_sitemap_url my_sitemap
27
+ ```
28
+
29
+ Use the `:to` option to specify which search engines you want for submittal. You can choose from `:google`, `:yahoo`, or `:bing`.
30
+
31
+ ```ruby
32
+ SearchEngineSubmitter.submit_sitemap_url my_sitemap, :to => [:google, :yahoo]
33
+ ```
34
+
35
+ You can also submit a URI:
36
+
37
+ ```ruby
38
+ my_sitemap_uri = URI(my_sitemap)
39
+ SearchEngineSubmitter.submit_sitemap_url my_sitemap_uri
40
+ ```
41
+
42
+ Or even submit a URI directly:
43
+
44
+ ```ruby
45
+ my_sitemap_uri.submit_sitemap :to => :google
46
+ ```
47
+
48
+ All search engines consider RSS or Atom feeds to be acceptable formats for sitemaps, so if it makes your code more syntactically aesthetic, then you can use the RSS alias methods instead:
49
+
50
+ ```ruby
51
+ my_rss_feed = 'http://testdomain.com/rss'
52
+ SearchEngineSubmitter.submit_rss_url my_rss_feed, :to => :yahoo
53
+ URI(my_rss_feed).submit_rss :to => [:google, :bing]
54
+ ```
55
+
56
+ The return value of all of these methods is an array of [OpenURI::Meta](http://www.ruby-doc.org/stdlib-1.9.3/libdoc/open-uri/rdoc/OpenURI/Meta.html) objects containing the response of each search engine submittal.
57
+
58
+ ## Contributing
59
+
60
+ 1. Fork it
61
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
62
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
63
+ 4. Push to the branch (`git push origin my-new-feature`)
64
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env rake
2
+
3
+ require 'rspec/core/rake_task'
4
+ RSpec::Core::RakeTask.new(:spec) do |r|
5
+ r.rspec_opts = '--color --format documentation'
6
+ end
7
+ task :default => :spec
8
+
9
+ namespace :gem do
10
+ require "bundler/gem_tasks"
11
+ end
@@ -0,0 +1,3 @@
1
+ module SearchEngineSubmitter
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,54 @@
1
+ require 'search_engine_submitter/version'
2
+ require 'open-uri'
3
+
4
+ module SearchEngineSubmitter
5
+ SEARCH_ENGINE_URL = {
6
+ :google => 'http://www.google.com/webmasters/sitemaps/ping?sitemap=',
7
+ :bing => 'http://www.bing.com/webmaster/ping.aspx?siteMap='
8
+ # Note - :yahoo uses :bing for webmaster tools now.
9
+ }
10
+
11
+ DEFAULT_OPTIONS = { :to => [:google, :bing] }
12
+
13
+ class << self
14
+ def submit_sitemap_url(url, options = DEFAULT_OPTIONS)
15
+ engines = get_engines_from options
16
+ engines.map { |engine| submit_url_to_search_engine url, engine }
17
+ end
18
+ alias_method :submit_rss_url, :submit_sitemap_url
19
+ end
20
+
21
+ # Mixin for HTTP URIs
22
+ module SubmitURI
23
+ def submit_sitemap(options = DEFAULT_OPTIONS)
24
+ SearchEngineSubmitter.submit_sitemap_url(self, options)
25
+ end
26
+ alias_method :submit_rss, :submit_sitemap
27
+ end
28
+
29
+ class InvalidSitemapError < Exception
30
+ end
31
+
32
+ private
33
+
34
+ class << self
35
+ def get_engines_from(options)
36
+ engines = Array(options[:to]).map(&:to_sym)
37
+ engines.map{ |to| to == :yahoo ? :bing : to }.uniq
38
+ end
39
+
40
+ def submit_url_to_search_engine(url, engine)
41
+ begin
42
+ return URI(SEARCH_ENGINE_URL[engine] + url.to_s).read
43
+ rescue OpenURI::HTTPError
44
+ raise SearchEngineSubmitter::InvalidSitemapError
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ module URI
51
+ class HTTP
52
+ include SearchEngineSubmitter::SubmitURI
53
+ end
54
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/search_engine_submitter/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Scott McCormack"]
6
+ gem.email = ["mail@madhackerdesigns.com"]
7
+ gem.description = %q{A tool to make the submission of sitemaps and RSS/Atom feeds to search engines as painless as possible. Use it to notify Big-G and friends of updates to your blog, or to ping newly created backlinks for your latest SEO campaign.}
8
+ gem.summary = gem.description
9
+ gem.homepage = "https://github.com/flintinatux/search_engine_submitter"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "search_engine_submitter"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = SearchEngineSubmitter::VERSION
17
+
18
+ gem.add_development_dependency 'rspec', '~> 2.12.0'
19
+ end
@@ -0,0 +1,64 @@
1
+ require 'search_engine_submitter'
2
+
3
+ describe SearchEngineSubmitter do
4
+
5
+ let(:sitemap_url) { 'http://testdomain.com/sitemap.xml' }
6
+ let(:bad_url) { 'htt://somedomain.a' }
7
+
8
+ shared_examples "a submitter" do
9
+ it "should submit a good url" do
10
+ responses = subject.submit_sitemap_url sitemap_url, :to => search_engine
11
+ responses.each { |r| r.status.should eq ["200", "OK"] }
12
+ end
13
+
14
+ it "should submit a good URI" do
15
+ responses = URI(sitemap_url).submit_sitemap :to => search_engine
16
+ responses.each { |r| r.status.should eq ["200", "OK"] }
17
+ end
18
+ end
19
+
20
+ describe "submit sitemap url" do
21
+ engines = [:google, :yahoo, :bing]
22
+ engines.each do |engine|
23
+ describe "to only #{engine.to_s}" do
24
+ let(:search_engine) { engine }
25
+ it_should_behave_like 'a submitter'
26
+
27
+ if engine == :google
28
+ it "should raise error for bad url" do
29
+ expect { subject.submit_sitemap_url bad_url, :to => search_engine }.to raise_error(SearchEngineSubmitter::InvalidSitemapError)
30
+ end
31
+ end
32
+ end
33
+ end
34
+
35
+ describe "to all three search engines" do
36
+ let(:search_engine) { engines }
37
+ it_should_behave_like 'a submitter'
38
+ end
39
+
40
+ describe "with no :to option" do
41
+ it "should submit a good url" do
42
+ responses = subject.submit_sitemap_url sitemap_url
43
+ responses.each { |r| r.status.should eq ["200", "OK"] }
44
+ end
45
+
46
+ it "should submit a good URI" do
47
+ responses = URI(sitemap_url).submit_sitemap
48
+ responses.each { |r| r.status.should eq ["200", "OK"] }
49
+ end
50
+ end
51
+
52
+ describe "with RSS alias methods" do
53
+ it "should submit a good url" do
54
+ responses = subject.submit_rss_url sitemap_url
55
+ responses.each { |r| r.status.should eq ["200", "OK"] }
56
+ end
57
+
58
+ it "should submit a good URI" do
59
+ responses = URI(sitemap_url).submit_rss
60
+ responses.each { |r| r.status.should eq ["200", "OK"] }
61
+ end
62
+ end
63
+ end
64
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: search_engine_submitter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Scott McCormack
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 2.12.0
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 2.12.0
30
+ description: A tool to make the submission of sitemaps and RSS/Atom feeds to search
31
+ engines as painless as possible. Use it to notify Big-G and friends of updates to
32
+ your blog, or to ping newly created backlinks for your latest SEO campaign.
33
+ email:
34
+ - mail@madhackerdesigns.com
35
+ executables: []
36
+ extensions: []
37
+ extra_rdoc_files: []
38
+ files:
39
+ - .gitignore
40
+ - .travis.yml
41
+ - Gemfile
42
+ - LICENSE
43
+ - README.md
44
+ - Rakefile
45
+ - lib/search_engine_submitter.rb
46
+ - lib/search_engine_submitter/version.rb
47
+ - search_engine_submitter.gemspec
48
+ - spec/lib/search_engine_submitter_spec.rb
49
+ homepage: https://github.com/flintinatux/search_engine_submitter
50
+ licenses: []
51
+ post_install_message:
52
+ rdoc_options: []
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ! '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ segments:
62
+ - 0
63
+ hash: -1444840707988511149
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ segments:
71
+ - 0
72
+ hash: -1444840707988511149
73
+ requirements: []
74
+ rubyforge_project:
75
+ rubygems_version: 1.8.24
76
+ signing_key:
77
+ specification_version: 3
78
+ summary: A tool to make the submission of sitemaps and RSS/Atom feeds to search engines
79
+ as painless as possible. Use it to notify Big-G and friends of updates to your blog,
80
+ or to ping newly created backlinks for your latest SEO campaign.
81
+ test_files:
82
+ - spec/lib/search_engine_submitter_spec.rb