class Fog::Storage::HuaweiCloud::Mock
Public Class Methods
data()
click to toggle source
# File lib/fog/storage/huaweicloud.rb, line 63 def self.data @data ||= Hash.new do |hash, key| hash[key] = {} end end
new(options = {})
click to toggle source
# File lib/fog/storage/huaweicloud.rb, line 73 def initialize(options = {}) require_mime_types @huaweicloud_api_key = options[:huaweicloud_api_key] @huaweicloud_username = options[:huaweicloud_username] @huaweicloud_management_url = options[:huaweicloud_management_url] || 'http://example:8774/v2/AUTH_1234' @huaweicloud_management_uri = URI.parse(@huaweicloud_management_url) @host = @huaweicloud_management_uri.host @path = @huaweicloud_management_uri.path @path.sub!(%r{/$}, '') @port = @huaweicloud_management_uri.port @scheme = @huaweicloud_management_uri.scheme end
reset()
click to toggle source
# File lib/fog/storage/huaweicloud.rb, line 69 def self.reset @data = nil end
Public Instance Methods
change_account(account)
click to toggle source
# File lib/fog/storage/huaweicloud.rb, line 96 def change_account(account) @original_path ||= @path version_string = @original_path.split('/')[1] @path = "/#{version_string}/#{account}" end
data()
click to toggle source
# File lib/fog/storage/huaweicloud.rb, line 88 def data self.class.data[@huaweicloud_username] end
put_object(container, object, data, options = {}) { || ... }
click to toggle source
# File lib/fog/storage/huaweicloud/requests/put_object.rb, line 43 def put_object(container, object, data, options = {}, &block) dgst = Digest::MD5.new if block_given? Kernel.loop do chunk = yield break if chunk.empty? dgst.update chunk end elsif data.kind_of?(String) dgst.update data else dgst.file data end response = Excon::Response.new response.status = 201 response.body = '' response.headers = {'ETag' => dgst.hexdigest} response end
reset_account_name()
click to toggle source
# File lib/fog/storage/huaweicloud.rb, line 102 def reset_account_name @path = @original_path end
reset_data()
click to toggle source
# File lib/fog/storage/huaweicloud.rb, line 92 def reset_data self.class.data.delete(@huaweicloud_username) end