Class: BoxGrinder::S3Helper
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from AWSHelper
block_device_mappings_validator, #parse_opts, #wait_with_timeout
Constructor Details
#initialize(ec2, s3, options = {}) ⇒ S3Helper
AWS::S3 object should be instantiated already, as config can be inserted
via global AWS.config or via AWS::S3.initialize
26
27
28
29
30
31
32
|
# File 'lib/boxgrinder-build/helpers/s3-helper.rb', line 26
def initialize(ec2, s3, options={})
raise ArgumentError, "ec2 argument must not be nil" if ec2.nil?
raise ArgumentError, "s3 argument must not be nil" if s3.nil?
@ec2 = ec2
@s3 = s3
@log = options[:log] || LogHelper.new
end
|
Class Method Details
.endpoints ⇒ Object
60
61
62
|
# File 'lib/boxgrinder-build/helpers/s3-helper.rb', line 60
def self.endpoints
ENDPOINTS
end
|
Instance Method Details
#bucket(options = {}) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/boxgrinder-build/helpers/s3-helper.rb', line 34
def bucket(options={})
defaults = {:bucket => nil, :acl => :private, :location_constraint => 'us-east-1', :create_if_missing => false}
options = parse_opts(options, defaults)
s3b = @s3.buckets[options[:bucket]]
return s3b if s3b.exists?
return @s3.buckets.create(options[:bucket],
:acl => options[:acl],
:location_constraint => options[:location_constraint]) if options[:create_if_missing]
nil
end
|
#delete_folder(bucket, path) ⇒ Object
46
47
48
|
# File 'lib/boxgrinder-build/helpers/s3-helper.rb', line 46
def delete_folder(bucket, path)
bucket.objects.with_prefix(deslash(path)).map(&:delete)
end
|
#parse_path(path) ⇒ Object
54
55
56
57
58
|
# File 'lib/boxgrinder-build/helpers/s3-helper.rb', line 54
def parse_path(path)
return '' if path == '/'
deslash(path) << '/'
end
|
#stub_s3obj(bucket, path) ⇒ Object
50
51
52
|
# File 'lib/boxgrinder-build/helpers/s3-helper.rb', line 50
def stub_s3obj(bucket, path)
bucket.objects[path]
end
|