Skip to content

Commit

Permalink
Cosmetic refatoring
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrabarts committed Mar 10, 2009
1 parent b01d800 commit 6dff0de
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lib/big_sitemap.rb
Expand Up @@ -6,7 +6,7 @@


class BigSitemap class BigSitemap
def initialize(options) def initialize(options)
document_root = options.delete(:document_root) document_root = options.delete(:document_root)


if document_root.nil? if document_root.nil?
if defined? RAILS_ROOT if defined? RAILS_ROOT
Expand Down Expand Up @@ -37,9 +37,7 @@ def initialize(options)
'Batch size (:batch_size) must be less than or equal to maximum URLs per sitemap (:max_per_sitemap)' 'Batch size (:batch_size) must be less than or equal to maximum URLs per sitemap (:max_per_sitemap)'
) if @batch_size > @max_per_sitemap ) if @batch_size > @max_per_sitemap


unless File.exists? @file_path Dir.mkdir(@file_path) unless File.exists? @file_path
Dir.mkdir(@file_path)
end
end end


def add(options) def add(options)
Expand Down Expand Up @@ -101,11 +99,9 @@ def generate
param_method = pick_method(r, [:to_param, :id]) param_method = pick_method(r, [:to_param, :id])
raise ArgumentError, "#{klass} must provide a to_param instance method" if param_method.nil? raise ArgumentError, "#{klass} must provide a to_param instance method" if param_method.nil?


path = {:url => "#{source[:path]}/#{r.send(param_method)}", :last_mod => last_mod}

xml.url do xml.url do
xml.loc("#{@base_url}/#{path[:url]}") xml.loc("#{@base_url}/#{source[:path]}/#{r.send(param_method)}")
xml.lastmod(path[:last_mod].strftime('%Y-%m-%d')) unless path[:last_mod].nil? xml.lastmod(last_mod.strftime('%Y-%m-%d')) unless last_mod.nil?
xml.changefreq('weekly') xml.changefreq('weekly')
end end
end end
Expand Down

0 comments on commit 6dff0de

Please sign in to comment.