Module: ClusterFuck::S3Methods

Included in:
Commands::List, Reader, Writer
Defined in:
lib/cluster-fuck/s3_methods.rb

Defined Under Namespace

Classes: ConflictError, KeyDoesNotExistError

Instance Method Summary collapse

Instance Method Details

#all_filesObject



27
28
29
# File 'lib/cluster-fuck/s3_methods.rb', line 27

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

#amicus_envObject



35
36
37
# File 'lib/cluster-fuck/s3_methods.rb', line 35

def amicus_env
  @amicus_env || ClusterFuck.amicus_env
end

#bucketObject



11
12
13
# File 'lib/cluster-fuck/s3_methods.rb', line 11

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

#credentialsObject



15
16
17
# File 'lib/cluster-fuck/s3_methods.rb', line 15

def credentials
  @credentials ||= CredentialGrabber.find
end

#full_s3_path(key) ⇒ Object



31
32
33
# File 'lib/cluster-fuck/s3_methods.rb', line 31

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

#s3Object



19
20
21
22
23
24
25
# File 'lib/cluster-fuck/s3_methods.rb', line 19

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

#s3_object(object_name) ⇒ Object



7
8
9
# File 'lib/cluster-fuck/s3_methods.rb', line 7

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