lib/big_sitemap/builder.rb in big_sitemap-1.0.1 vs lib/big_sitemap/builder.rb in big_sitemap-1.0.2
- old
+ new
@@ -2,14 +2,15 @@
require 'zlib'
class BigSitemap
class Builder
MAX_URLS = 50000
+ HEADER_NAME = 'urlset'
HEADER_ATTRIBUTES = {
'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9',
'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance",
- 'xsi:schemaLocation' => "http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"
+ 'xsi:schemaLocation' => "http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"
}
def initialize(options)
@gzip = options.delete(:gzip)
@max_urls = options.delete(:max_urls) || MAX_URLS
@@ -73,15 +74,15 @@
@filepaths << filename
file = ::File.open(@tmp_filename, 'w+:ASCII-8BIT')
@gzip ? ::Zlib::GzipWriter.new(file) : file
end
- def _init_document(name='urlset', attrs=HEADER_ATTRIBUTES)
+ def _init_document
@urls = 0
target!.print '<?xml version="1.0" encoding="UTF-8"?>'
_newline
- _open_tag name, attrs
+ _open_tag self.class::HEADER_NAME, self.class::HEADER_ATTRIBUTES
end
def _rotate(part_nr=nil)
# write out the current document and start writing into a new file
close!
@@ -139,14 +140,14 @@
target!.puts ''
end
end
class IndexBuilder < Builder
- def _init_document(name = 'sitemapindex', attrs = {'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9'})
- attrs.merge('xmlns:geo' => "http://www.google.com/geo/schemas/sitemap/1.0")
- super(name, attrs)
- end
+ HEADER_NAME = 'sitemapindex'
+ HEADER_ATTRIBUTES = {
+ 'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9'
+ }
def add_url!(location, options={})
_open_tag 'sitemap'
tag! 'loc', location
@@ -154,16 +155,7 @@
_close_tag 'sitemap'
end
end
- class GeoBuilder < Builder
- #_build_geo if @geo
-
- # def _build_geo
- # geo :geo do
- # geo :format, 'kml'
- # end
- # end
- end
end