class Canistor::Subject
Constants
- HOST_RE
Attributes
bucket[R]
key[R]
region[R]
uri[R]
Public Class Methods
new(uri)
click to toggle source
# File lib/canistor/subject.rb, line 13 def initialize(uri) @uri = uri host_segments = HOST_RE.match(uri.host) path_segments = uri.path.split('/', 3)[1..-1] || [] @region = parse_region(host_segments) @bucket = parse_bucket(host_segments, path_segments) @key = path_segments.empty? ? nil : path_segments.join('/') end
Private Instance Methods
parse_bucket(host_segments, path_segments)
click to toggle source
# File lib/canistor/subject.rb, line 37 def parse_bucket(host_segments, path_segments) if host_segments[1] host_segments[1][0..-2] else path_segments.shift end end
parse_region(host_segments)
click to toggle source
# File lib/canistor/subject.rb, line 26 def parse_region(host_segments) case host_segments[3] when nil host_segments[4] when 'amazonaws' 'us-east-1' else host_segments[3] end end