lib/fog/brightbox/storage.rb in fog-brightbox-0.6.1 vs lib/fog/brightbox/storage.rb in fog-brightbox-0.7.0

- old
+ new

@@ -5,23 +5,22 @@ require "fog/brightbox/storage/connection" module Fog module Storage class Brightbox < Fog::Service - - requires :brightbox_client_id, - :brightbox_secret + requires :brightbox_client_id, + :brightbox_secret recognizes :persistent, :brightbox_service_name, :brightbox_storage_url, :brightbox_service_type, :brightbox_tenant, :brightbox_region, :brightbox_temp_url_key model_path "fog/brightbox/models/storage" - model :directory - collection :directories - model :file - collection :files + model :directory + collection :directories + model :file + collection :files request_path "fog/brightbox/requests/storage" request :copy_object request :delete_container request :delete_object @@ -41,11 +40,11 @@ request :put_object request :put_object_manifest request :put_static_obj_manifest class Mock - def initialize(options={}) + def initialize(_options = {}) end end class Real def initialize(config) @@ -90,29 +89,27 @@ def connection @connection ||= Fog::Brightbox::Storage::Connection.new(@config) end def request(params, parse_json = true) - begin - authenticate if @config.must_authenticate? - connection.request(params, parse_json) - rescue Fog::Brightbox::Storage::AuthenticationRequired => error - if @config.managed_tokens? - @config.expire_tokens! - authenticate - retry - else # bad credentials - raise error - end - rescue Excon::Errors::HTTPStatusError => error - raise case error - when Excon::Errors::NotFound - Fog::Storage::Brightbox::NotFound.slurp(error) - else - error - end + authenticate if @config.must_authenticate? + connection.request(params, parse_json) + rescue Fog::Brightbox::Storage::AuthenticationRequired => error + if @config.managed_tokens? + @config.expire_tokens! + authenticate + retry + else # bad credentials + raise error end + rescue Excon::Errors::HTTPStatusError => error + raise case error + when Excon::Errors::NotFound + Fog::Storage::Brightbox::NotFound.slurp(error) + else + error + end end def authenticate if !management_url || needs_to_authenticate? response = Fog::Brightbox::Storage::AuthenticationRequest.new(@config).authenticate @@ -124,11 +121,11 @@ else false end end - # @param [URI] uri A URI object to extract the account from + # @param [URI] url A URI object to extract the account from # @return [String] The account def extract_account_from_url(url) url.path.split("/")[2] end @@ -154,12 +151,12 @@ true end end # CGI.escape, but without special treatment on spaces - def self.escape(str,extra_exclude_chars = "") + def self.escape(str, extra_exclude_chars = "") str.gsub(/([^a-zA-Z0-9_.-#{extra_exclude_chars}]+)/) do - "%" + $1.unpack("H2" * $1.bytesize).join("%").upcase + "%" + Regexp.last_match[1].unpack("H2" * Regexp.last_match[1].bytesize).join("%").upcase end end end end end