Sha256: 87f12a24687deb92c2e3fc0bd4e9e9c3e66219ef84ff18c05dafc276e7416e10

Contents?: true

Size: 495 Bytes

Versions: 28

Compression:

Stored size: 495 Bytes

Contents

module SitemapGenerator
  class FileAdapter
    def write(location, raw_data)
      # Ensure that the directory exists
      dir = location.directory
      if !File.exists?(dir)
        FileUtils.mkdir_p(dir)
      elsif !File.directory?(dir)
        raise SitemapError.new("#{dir} should be a directory!")
      end

      gzip(open(location.path, 'wb'), raw_data)
    end

    def gzip(stream, data)
      gz = Zlib::GzipWriter.new(stream)
      gz.write data
      gz.close
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
sitemap_generator-2.1.5 lib/sitemap_generator/adapters/file_adapter.rb
sitemap_generator-2.1.4 lib/sitemap_generator/adapters/file_adapter.rb
sitemap_generator-2.1.3 lib/sitemap_generator/adapters/file_adapter.rb
sitemap_generator-2.1.2 lib/sitemap_generator/adapters/file_adapter.rb
sitemap_generator-2.1.1 lib/sitemap_generator/adapters/file_adapter.rb
sitemap_generator-2.1.0 lib/sitemap_generator/adapters/file_adapter.rb
sitemap_generator-2.0.1.pre2 lib/sitemap_generator/adapters/file_adapter.rb
sitemap_generator-2.0.1.pre1 lib/sitemap_generator/adapters/file_adapter.rb