class Usmu::S3::RemoteFiles

Attributes

bucket[R]
s3[R]

Public Class Methods

new(configuration) click to toggle source

@param [Usmu::S3::Configuration] configuration

An S3 configuration to provide connection details to the remote S3 bucket.
# File lib/usmu/s3/remote_files.rb, line 11
def initialize(configuration)
  @s3 = Aws::S3::Resource.new(credentials: configuration.credentials, region: configuration.region)
  @bucket = @s3.bucket(configuration.bucket)
end

Public Instance Methods

files_list() click to toggle source

@see Usmu::Deployment::RemoteFileInterface#files_list

# File lib/usmu/s3/remote_files.rb, line 17
def files_list
  objects.map {|o| o.key }
end
stat(filename) click to toggle source

@see Usmu::Deployment::RemoteFileInterface#stat

# File lib/usmu/s3/remote_files.rb, line 22
def stat(filename)
  obj = objects.select {|o| o.key.eql? filename }.first
  return nil if obj.nil?

  etag = unless obj.etag.index('-')
           obj.etag.gsub(/^["]|["]$/, '')
         end

  {
      md5: etag,
      mtime: obj.last_modified,
  }
end

Private Instance Methods

objects() click to toggle source
# File lib/usmu/s3/remote_files.rb, line 41
def objects
  @objects ||= @bucket.objects.to_a
end