Sha256: 38fe949293ccc977d32523a68f6ec25333ae8b904eff20110cb260847417c798
Contents?: true
Size: 1.08 KB
Versions: 6
Compression:
Stored size: 1.08 KB
Contents
if !defined?(Fog::Storage) raise "Error: `Fog::Storage` is not defined.\n\n"\ "Please `require 'fog'` - or another library that defines this class." end module SitemapGenerator # Class for uploading sitemaps to a Fog supported endpoint. class FogAdapter # Requires Fog::Storage to be defined. # # @param [Hash] opts Fog configuration options # @option :fog_credentials [Hash] Credentials for connecting to the remote server # @option :fog_directory [String] Your AWS S3 bucket or similar directory name def initialize(opts = {}) @fog_credentials = opts[:fog_credentials] @fog_directory = opts[:fog_directory] end # Call with a SitemapLocation and string data def write(location, raw_data) SitemapGenerator::FileAdapter.new.write(location, raw_data) storage = Fog::Storage.new(@fog_credentials) directory = storage.directories.new(:key => @fog_directory) directory.files.create( :key => location.path_in_public, :body => File.open(location.path), :public => true ) end end end
Version data entries
6 entries across 6 versions & 1 rubygems