class Hasta::S3File

Hasta's interface to the File objects returned by Fog

Attributes

s3_file[R]

Public Class Methods

new(s3_file) click to toggle source
# File lib/hasta/s3_file.rb, line 26
def initialize(s3_file)
  @s3_file = s3_file
end
wrap(s3_file) click to toggle source
# File lib/hasta/s3_file.rb, line 16
def self.wrap(s3_file)
  if self === s3_file
    s3_file
  elsif s3_file.nil?
    nil
  else
    new(s3_file)
  end
end
wrap_files(s3_files) click to toggle source
# File lib/hasta/s3_file.rb, line 12
def self.wrap_files(s3_files)
  s3_files.map { |s3_file| wrap(s3_file) }
end

Public Instance Methods

each_line() { |line| ... } click to toggle source
# File lib/hasta/s3_file.rb, line 46
def each_line
  return enum_for(:each_line) unless block_given?

  StringIO.new(s3_file.body).each_line { |line| yield line }
end
fingerprint() click to toggle source
# File lib/hasta/s3_file.rb, line 34
def fingerprint
  @fingerprint ||= if s3_file.respond_to? :etag
    s3_file.etag
  else
    Digest::MD5.hexdigest(body)
  end
end
remote?() click to toggle source
# File lib/hasta/s3_file.rb, line 42
def remote?
  !(Fog::Storage::Local::File === s3_file)
end
s3_uri() click to toggle source
# File lib/hasta/s3_file.rb, line 30
def s3_uri
  @s3_uri ||= S3URI.new(s3_file.directory.key, key)
end