Sha256: 874e73c50b7a3b1661f5107660fbe47504f06e9c18e7c41258841475b7cc133e
Contents?: true
Size: 1.42 KB
Versions: 3
Compression:
Stored size: 1.42 KB
Contents
require 'attached/storage/base' require 'fog' module Attached module Storage class Rackspace < Fog attr_reader :container attr_reader :username attr_reader :api_key # Create a new interface supporting save and destroy operations. # # Usage: # # Attached::Storage::Rackspace.new() # Attached::Storage::Rackspace.new("rackspace.yml") def initialize(credentials) super credentials = parse(credentials) @container = credentials[:container] || credentials['container'] @username = credentials[:username] || credentials['username'] @api_key = credentials[:api_key] || credentials['api_key'] raise "'container' must be specified if using 'rackspace' for storage" unless @container end # Access the host (e.g. https://storage.clouddrive.com/container) for a storage service. # # Usage: # # storage.host def host() "https://storage.clouddrive.com/#{self.container}/" end private def directory() connection.directories.get(self.container) || connection.directories.create(self.defaults.merge(key: self.container)) end def connection @connection ||= ::Fog::Storage.new( rackspace_username: self.username, rackspace_api_key: self.api_key, provider: 'Rackspace' ) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
attached-1.0.7 | lib/attached/storage/rackspace.rb |
attached-1.0.6 | lib/attached/storage/rackspace.rb |
attached-1.0.5 | lib/attached/storage/rackspace.rb |