Sha256: 15aafaa1f308916241a5e74b50a2a0ee1bc6576480eb10fd2dfd825031296f2c
Contents?: true
Size: 1.06 KB
Versions: 2
Compression:
Stored size: 1.06 KB
Contents
module DynamicSitemaps class Pinger class << self def ping_search_engines_with(sitemap_urls) sitemap_urls = [sitemap_urls] unless sitemap_urls.is_a?(Array) if sitemap_urls.any? && ping_for_environment?(Rails.env) Logger.info "Pinging search engines..." sitemap_urls.each do |url| ping_search_engines_with_sitemap_url url end Logger.info "Done pinging search engines." end end def ping_search_engines_with_sitemap_url(sitemap_url) sitemap_url = CGI::escape(sitemap_url) DynamicSitemaps.search_engine_ping_urls.each do |ping_url| url = ping_url % sitemap_url ping url end end def ping(url) Logger.info "Pinging #{url} ..." begin Net::HTTP.get(URI.parse(url)) rescue Exception => e Logger.warn "Failed to ping #{url} : #{e}" end end def ping_for_environment?(env) DynamicSitemaps.ping_environments.map(&:to_s).include?(env.to_s) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dynamic_sitemaps-2.0.0 | lib/dynamic_sitemaps/pinger.rb |
dynamic_sitemaps-2.0.0.beta2 | lib/dynamic_sitemaps/pinger.rb |