Sha256: 3038ea027472b8af4d664c79021c3ff8f70a10cb370ddc1a28230946055134e5

Contents?: true

Size: 952 Bytes

Versions: 1

Compression:

Stored size: 952 Bytes

Contents

require "massive_sitemap/builder/base"

module MassiveSitemap
  module Builder
    class Index < Base
      HEADER_NAME       = 'sitemapindex'
      HEADER_ATTRIBUTES = {
        :xmlns => 'http://www.sitemaps.org/schemas/sitemap/0.9'
      }

      def initialize(writer, options = {}, &block)
        super(writer, options) do
          writer.each do |path, last_modified|
            add path, :last_modified => last_modified
          end
        end

      end

      def self.generate(writer, options = {}, &block)
        index_url(super, writer)
      end

      def self.index_url(builder, writer)
        ::File.join(builder.send(:url), writer.options[:filename])
      end

      def add_url!(location, attrs = {})
        init!

        tag! 'sitemap' do
          tag! 'loc', location
          tag! 'lastmod', attrs[:last_modified].utc.strftime('%Y-%m-%dT%H:%M:%S+00:00') if attrs[:last_modified]
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
massive_sitemap-2.0.0.rc3 lib/massive_sitemap/builder/index.rb