Module: Fog::Storage::Atmos::Utils
Constant Summary collapse
- ENDPOINT_REGEX =
/(https*):\/\/([a-zA-Z0-9\.\-]+)(:[0-9]+)?(\/.*)?/
Instance Method Summary collapse
- #api_path ⇒ Object
- #host ⇒ Object
- #port ⇒ Object
- #setup_credentials(options) ⇒ Object
- #ssl? ⇒ Boolean
Instance Method Details
#api_path ⇒ Object
51 52 53 |
# File 'lib/fog/storage/atmos.rb', line 51 def api_path @endpoint.match(ENDPOINT_REGEX)[4] end |
#host ⇒ Object
47 48 49 |
# File 'lib/fog/storage/atmos.rb', line 47 def host @endpoint.match(ENDPOINT_REGEX)[2] end |
#port ⇒ Object
41 42 43 44 45 |
# File 'lib/fog/storage/atmos.rb', line 41 def port port = @endpoint.match(ENDPOINT_REGEX)[3] return ssl? ? 443 : 80 if port.nil? port.split(':')[1].to_i end |
#setup_credentials(options) ⇒ Object
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/fog/storage/atmos.rb', line 55 def setup_credentials() @storage_token = [:atmos_storage_token] @storage_secret = [:atmos_storage_secret] @storage_secret_decoded = Base64.decode64(@storage_secret) @endpoint = [:atmos_storage_endpoint] @prefix = self.ssl? ? 'https' : 'http' @storage_host = self.host @storage_port = self.port @api_path = self.api_path end |
#ssl? ⇒ Boolean
31 32 33 34 35 36 37 38 39 |
# File 'lib/fog/storage/atmos.rb', line 31 def ssl? protocol = @endpoint.match(ENDPOINT_REGEX)[1] raise ArgumentError, 'Invalid endpoint URL' if protocol.nil? return true if protocol == 'https' return false if protocol == 'http' raise ArgumentError, "Unknown protocol #{protocol}" end |