Sha256: 532358ab9cb6982284e4d09f0d37cc1bd777e4a0aec8172271ac4ebc78d42d07
Contents?: true
Size: 793 Bytes
Versions: 4
Compression:
Stored size: 793 Bytes
Contents
require 'cgi' require 'open-uri' module MassiveSitemap ENGINES_URLS = { :google => 'http://www.google.com/webmasters/tools/ping?sitemap=%s', :bing => 'http://www.bing.com/webmaster/ping.aspx?siteMap=%s', :ask => 'http://submissions.ask.com/ping?sitemap=%s', } def ping(url, engines = ENGINES_URLS.keys) url = verify_and_escape(url) Array(engines).each do |engine| if engine_url = ENGINES_URLS[engine] open(engine_url % url) end end end module_function :ping private def verify_and_escape(url) schema, host, path = url.scan(/^(https?:\/\/)?(.+?)(\/.+)$/).flatten raise URI::InvalidURIError, url if path.to_s.empty? CGI::escape("#{schema || 'http://'}#{host}#{path}") end module_function :verify_and_escape end
Version data entries
4 entries across 4 versions & 1 rubygems