Class: S3Website::Endpoint

Inherits:
Object
  • Object
show all
Defined in:
lib/s3_website/endpoint.rb

Constant Summary collapse

DEFAULT_LOCATION_CONSTRAINT =
'us-east-1'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(location_constraint = nil) ⇒ Endpoint

Returns a new instance of Endpoint.



6
7
8
9
10
11
12
13
14
# File 'lib/s3_website/endpoint.rb', line 6

def initialize(location_constraint=nil)
  location_constraint = DEFAULT_LOCATION_CONSTRAINT if location_constraint.nil?
  raise "Invalid S3 location constraint #{location_constraint}" unless
    location_constraints.has_key?location_constraint
  @region = location_constraints.fetch(location_constraint)[:region]
  @hostname = location_constraints.fetch(location_constraint)[:endpoint]
  @website_hostname = location_constraints.fetch(location_constraint)[:website_hostname]
  @location_constraint = location_constraint
end

Instance Attribute Details

#hostnameObject (readonly)

Returns the value of attribute hostname.



4
5
6
# File 'lib/s3_website/endpoint.rb', line 4

def hostname
  @hostname
end

#location_constraintObject (readonly)

Returns the value of attribute location_constraint.



4
5
6
# File 'lib/s3_website/endpoint.rb', line 4

def location_constraint
  @location_constraint
end

#regionObject (readonly)

Returns the value of attribute region.



4
5
6
# File 'lib/s3_website/endpoint.rb', line 4

def region
  @region
end

#website_hostnameObject (readonly)

Returns the value of attribute website_hostname.



4
5
6
# File 'lib/s3_website/endpoint.rb', line 4

def website_hostname
  @website_hostname
end

Instance Method Details

#location_constraintsObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/s3_website/endpoint.rb', line 17

def location_constraints
  {
    'us-east-1'      => { :region => 'US Standard',                   :website_hostname => 's3-website-us-east-1.amazonaws.com',      :endpoint => 's3.amazonaws.com' },
    'us-west-2'      => { :region => 'US West (Oregon)',              :website_hostname => 's3-website-us-west-2.amazonaws.com',      :endpoint => 's3-us-west-2.amazonaws.com' },
    'us-west-1'      => { :region => 'US West (Northern California)', :website_hostname => 's3-website-us-west-1.amazonaws.com',      :endpoint => 's3-us-west-1.amazonaws.com' },
    'EU'             => { :region => 'EU (Ireland)',                  :website_hostname => 's3-website-eu-west-1.amazonaws.com',      :endpoint => 's3-eu-west-1.amazonaws.com' },
    'ap-southeast-1' => { :region => 'Asia Pacific (Singapore)',      :website_hostname => 's3-website-ap-southeast-1.amazonaws.com', :endpoint => 's3-ap-southeast-1.amazonaws.com' },
    'ap-southeast-2' => { :region => 'Asia Pacific (Sydney)',         :website_hostname => 's3-website-ap-southeast-2.amazonaws.com', :endpoint => 's3-ap-southeast-2.amazonaws.com' },
    'ap-northeast-1' => { :region => 'Asia Pacific (Tokyo)',          :website_hostname => 's3-website-ap-northeast-1.amazonaws.com', :endpoint => 's3-ap-northeast-1.amazonaws.com' },
    'sa-east-1'      => { :region => 'South America (Sao Paulo)',     :website_hostname => 's3-website-sa-east-1.amazonaws.com',      :endpoint => 's3-sa-east-1.amazonaws.com' }
  }
end