Module: S3::CallingFormat

Defined in:
lib/s3sync/S3.rb,
lib/s3sync/S3_s3sync_mod.rb

Overview

class for storing calling format constants

Constant Summary collapse

REGULAR =
0
SUBDOMAIN =
1
VANITY =

http://<vanity_domain>/key – vanity_domain resolves to s3.amazonaws.com

2

Class Method Summary collapse

Class Method Details

.build_url_base(protocol, server, port, bucket, format) ⇒ Object

build the url based on the calling format, and bucket



477
478
479
480
481
482
483
484
485
486
487
488
489
# File 'lib/s3sync/S3.rb', line 477

def CallingFormat.build_url_base(protocol, server, port, bucket, format)
  build_url_base = "#{protocol}://"
  if bucket.empty?
    build_url_base << "#{server}:#{port}"
  elsif format == SUBDOMAIN
    build_url_base << "#{bucket}.#{server}:#{port}"
  elsif format == VANITY
    build_url_base << "#{bucket}:#{port}"
  else
    build_url_base << "#{server}:#{port}/#{bucket}"
  end
  return build_url_base
end

.string_to_format(s) ⇒ Object



129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/s3sync/S3_s3sync_mod.rb', line 129

def CallingFormat.string_to_format(s)
   case s
   when 'REGULAR'
     return CallingFormat::REGULAR
   when 'SUBDOMAIN'
     return CallingFormat::SUBDOMAIN
   when 'VANITY'
     return CallingFormat::VANITY
   else
     raise "Unsupported calling format #{s}"
   end
end