Sha256: 4e7c801bf7a42b4cb6e5f78a3edcda5145cb8a14f1e72b725b616d25573740f5

Contents?: true

Size: 1008 Bytes

Versions: 1

Compression:

Stored size: 1008 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|
            next if writer.current && path.include?(writer.current)
            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.current)
      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.rc4 lib/massive_sitemap/builder/index.rb