Sha256: 0fc1c8f5e82f1c8f2ea6b3fc6e32834f87c8c0aa187068951269a5a32eaf69a1

Contents?: true

Size: 752 Bytes

Versions: 5

Compression:

Stored size: 752 Bytes

Contents

module ClusterFuck
  module S3Methods

    class ConflictError < StandardError; end
    class KeyDoesNotExistError < StandardError; end

    def s3_object(object_name)
      bucket.objects[full_s3_path(object_name)]
    end

    def bucket
      @bucket ||= s3.buckets[CONFIG_BUCKET]
    end

    def credentials
      @credentials ||= CredentialGrabber.find
    end

    def s3
      if credentials
        AWS::S3.new(credentials) #could be nil, especially if on EC2
      else
        AWS::S3.new
      end
    end

    def all_files
      bucket.objects.with_prefix(amicus_env).collect(&:key)
    end

    def full_s3_path(key)
      "#{amicus_env}/#{key}"
    end

    def amicus_env
      @amicus_env || ClusterFuck.amicus_env
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cluster-fuck-0.1.4.3 lib/cluster-fuck/s3_methods.rb
cluster-fuck-0.1.4.2 lib/cluster-fuck/s3_methods.rb
cluster-fuck-0.1.4.1 lib/cluster-fuck/s3_methods.rb
cluster-fuck-0.1.4 lib/cluster-fuck/s3_methods.rb
cluster-fuck-0.1.3 lib/cluster-fuck/s3_methods.rb