Sha256: 1244a400185583b99eec5c98fcfc8f42d772e3e5bbe608202f0ee01f92addbe1
Contents?: true
Size: 1.65 KB
Versions: 2
Compression:
Stored size: 1.65 KB
Contents
if !defined?(Google::Cloud::Storage) raise LoadError, "Error: `Google::Cloud::Storage` is not defined.\n\n"\ "Please `require 'google/cloud/storage'` - or another library that defines this class." end module SitemapGenerator # Class for uploading sitemaps to a Google Storage using `google-cloud-storage` gem. class GoogleStorageAdapter # Requires Google::Cloud::Storage to be defined. # # @param [Hash] opts Google::Cloud::Storage configuration options. # @option :bucket [String] Required. Name of Google Storage Bucket where the file is to be uploaded. # # All options other than the `:bucket` option are passed to the `Google::Cloud::Storage.new` # initializer. See https://googleapis.dev/ruby/google-cloud-storage/latest/file.AUTHENTICATION.html # for all the supported environment variables and https://github.com/googleapis/google-cloud-ruby/blob/master/google-cloud-storage/lib/google/cloud/storage.rb # for supported options. # # Suggested Options: # @option :credentials [String] Path to Google service account JSON file, or JSON contents. # @option :project_id [String] Google Accounts project id where the storage bucket resides. def initialize(opts = {}) opts = opts.clone @bucket = opts.delete(:bucket) @storage_options = opts end # Call with a SitemapLocation and string data def write(location, raw_data) SitemapGenerator::FileAdapter.new.write(location, raw_data) storage = Google::Cloud::Storage.new(**@storage_options) bucket = storage.bucket(@bucket) bucket.create_file(location.path, location.path_in_public, acl: 'public') end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sitemap_generator-6.2.1 | lib/sitemap_generator/adapters/google_storage_adapter.rb |
sitemap_generator-6.2.0 | lib/sitemap_generator/adapters/google_storage_adapter.rb |