Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Down to 3 failures

  • Loading branch information...
commit 15d0a580221d59108a5b2362b5b54fba2f6e6233 1 parent 6c91cc0
Karl Varga authored
2  lib/sitemap_generator/builder/sitemap_url.rb
View
@@ -32,7 +32,7 @@ def initialize(path, options={})
SitemapGenerator::Utilities.assert_valid_keys(options, :priority, :changefreq, :lastmod, :host, :images, :video, :geo, :news, :videos)
SitemapGenerator::Utilities.reverse_merge!(options, :priority => 0.5, :changefreq => 'weekly', :lastmod => Time.now, :images => [], :news => {}, :videos => [])
- if options[:host].blank?
+ if SitemapGenerator::Utilities.blank?(options[:host])
raise "Cannot generate a url without a host"
end
if video = options.delete(:video)
6 lib/sitemap_generator/helpers/number_helper.rb
View
@@ -39,7 +39,7 @@ def initialize(number)
# number_with_delimiter(98765432.98, :delimiter => " ", :separator => ",")
# # => 98 765 432,98
def number_with_delimiter(number, options = {})
- options.symbolize_keys!
+ SitemapGenerator::Utilities.symbolize_keys!(options)
begin
Float(number)
@@ -92,7 +92,7 @@ def number_with_delimiter(number, options = {})
# number_with_precision(1111.2345, :precision => 2, :separator => ',', :delimiter => '.')
# # => 1.111,23
def number_with_precision(number, options = {})
- options.symbolize_keys!
+ SitemapGenerator::Utilities.symbolize_keys!(options)
number = begin
Float(number)
@@ -116,7 +116,7 @@ def number_with_precision(number, options = {})
}
defaults = defaults.merge(precision_defaults)
- options = options.reverse_merge(defaults) # Allow the user to unset default values: Eg.: :significant => false
+ options = SitemapGenerator::Utilities.reverse_merge(options, defaults) # Allow the user to unset default values: Eg.: :significant => false
precision = options.delete :precision
significant = options.delete :significant
strip_insignificant_zeros = options.delete :strip_insignificant_zeros
2  lib/sitemap_generator/interpreter.rb
View
@@ -21,7 +21,7 @@ class Interpreter
#
# All other options are passed to the LinkSet by setting them using accessor methods.
def initialize(opts={}, &block)
- opts.reverse_merge!(:link_set => SitemapGenerator::Sitemap)
+ SitemapGenerator::Utilities.reverse_merge!(opts, :link_set => SitemapGenerator::Sitemap)
@linkset = opts.delete :link_set
@linkset.send(:set_options, opts)
eval(&block) if block_given?
13 lib/sitemap_generator/link_set.rb
View
@@ -93,12 +93,12 @@ def add_links(&block)
# * <tt>:verbose</tt> - If +true+, output a summary line for each sitemap and sitemap
# index that is created. Default is +false+.
def initialize(options={})
- options.reverse_merge!({
+ SitemapGenerator::Utilities.reverse_merge!(options,
:include_root => true,
:include_index => true,
:filename => :sitemap,
:verbose => false
- })
+ )
options.each_pair { |k, v| instance_variable_set("@#{k}".to_sym, v) }
# If an index is passed in, protect it from modification.
@@ -116,7 +116,7 @@ def initialize(options={})
# host - host for the link, defaults to your <tt>default_host</tt>.
def add(link, options={})
add_default_links if !@added_default_links
- sitemap.add(link, options.reverse_merge!(:host => @default_host))
+ sitemap.add(link, SitemapGenerator::Utilities.reverse_merge!(options, :host => @default_host))
rescue SitemapGenerator::SitemapFullError
finalize_sitemap!
retry
@@ -186,6 +186,7 @@ def group(opts={}, &block)
#
# @see http://en.wikipedia.org/wiki/Sitemap_index
def ping_search_engines
+ require 'cgi'
require 'open-uri'
require 'timeout'
@@ -277,7 +278,7 @@ def set_options(opts={})
# change the public path.
def options_for_group(opts)
opts.delete(:public_path)
- opts.reverse_merge!(
+ SitemapGenerator::Utilities.reverse_merge!(opts,
:include_index => false,
:include_root => false,
:sitemap_index => sitemap_index
@@ -298,7 +299,7 @@ def options_for_group(opts)
end
hash
end
- opts.reverse_merge!(current_settings)
+ SitemapGenerator::Utilities.reverse_merge!(opts, current_settings)
opts
end
@@ -466,7 +467,7 @@ def sitemap_index_location
# Update the given attribute on the current sitemap index and sitemap file location objects.
# But don't create the index or sitemap files yet if they are not already created.
def update_location_info(attribute, value, opts={})
- opts.reverse_merge!(:include_index => !@protect_index)
+ SitemapGenerator::Utilities.reverse_merge!(opts, :include_index => !@protect_index)
@sitemap_index.location[attribute] = value if opts[:include_index] && @sitemap_index && !@sitemap_index.finalized?
@sitemap.location[attribute] = value if @sitemap && !@sitemap.finalized?
end
4 spec/files/sitemap.create.rb
View
@@ -1,11 +1,11 @@
SitemapGenerator::Sitemap.default_host = "http://www.example.com"
SitemapGenerator::Sitemap.create do
- add contents_path, :priority => 0.7, :changefreq => 'daily'
+ add '/contents', :priority => 0.7, :changefreq => 'daily'
# add all individual articles
Content.find(:all).each do |c|
- add content_path(c), :lastmod => c.updated_at
+ add "/content/#{c.to_param}", :lastmod => c.updated_at
end
add "/merchant_path", :host => "https://www.example.com"
4 spec/files/sitemap.deprecated.rb
View
@@ -2,11 +2,11 @@
SitemapGenerator::Sitemap.yahoo_app_id = false
SitemapGenerator::Sitemap.add_links do |sitemap|
- sitemap.add contents_path, :priority => 0.7, :changefreq => 'daily'
+ sitemap.add '/contents', :priority => 0.7, :changefreq => 'daily'
# add all individual articles
Content.find(:all).each do |c|
- sitemap.add content_path(c), :lastmod => c.updated_at
+ sitemap.add "/content/#{c.to_param}", :lastmod => c.updated_at
end
sitemap.add "/merchant_path", :host => "https://www.example.com"
8 spec/sitemap_generator/application_spec.rb
View
@@ -2,17 +2,17 @@
describe SitemapGenerator::Application do
before :all do
- with_warnings(nil) do
+ SitemapGenerator::Utilities.with_warnings(nil) do
Object.const_set(:Rails, Object.new)
end
end
-
+
after :all do
- with_warnings(nil) do
+ SitemapGenerator::Utilities.with_warnings(nil) do
Object.const_set(:Rails, nil)
end
end
-
+
before :each do
@app = SitemapGenerator::Application.new
end
4 spec/sitemap_generator/interpreter_spec.rb
View
@@ -9,8 +9,8 @@
end
it "should find the config file if Rails.root doesn't end in a slash" do
- rails_root = Rails.root.to_s.sub(/\/$/, '')
- Rails.expects(:root).returns(rails_root).at_least_once
+ Rails = stub(:root => SitemapGenerator.app.root.to_s.sub(/\/$/, ''))
+ # Rails.expects(:root).returns(rails_root).at_least_once
lambda { SitemapGenerator::Interpreter.run }.should_not raise_exception(Errno::ENOENT)
end
2  spec/sitemap_generator/link_set_spec.rb
View
@@ -453,7 +453,7 @@
it "should support both sitemaps_namer and filename options no matter the order" do
namer = SitemapGenerator::SitemapNamer.new("sitemap1_")
- options = ActiveSupport::OrderedHash.new
+ options = {} #ActiveSupport::OrderedHash.new
options[:sitemaps_namer] = namer
options[:filename] = "sitemap1"
ls = @ls.create(options)
10 spec/sitemap_generator/sitemap_groups_spec.rb
View
@@ -1,10 +1,12 @@
require "spec_helper"
def with_max_links(num)
- original = SitemapGenerator::MAX_SITEMAP_LINKS
- SitemapGenerator.const_set(:MAX_SITEMAP_LINKS, num)
- yield
- SitemapGenerator.const_set(:MAX_SITEMAP_LINKS, original)
+ SitemapGenerator::Utilities.with_warnings(nil) do
+ original = SitemapGenerator::MAX_SITEMAP_LINKS
+ SitemapGenerator.const_set(:MAX_SITEMAP_LINKS, num)
+ yield
+ SitemapGenerator.const_set(:MAX_SITEMAP_LINKS, original)
+ end
end
describe "Sitemap Groups" do
Please sign in to comment.
Something went wrong with that request. Please try again.