Class | BoxGrinder::S3Helper |
In: |
lib/boxgrinder-build/helpers/s3-helper.rb
lib/boxgrinder-build/helpers/s3-helper.rb |
Parent: | AWSHelper |
ENDPOINTS | = | { 'eu-west-1' => { :endpoint => 's3-eu-west-1.amazonaws.com', :location => 'EU', :kernel => { :i386 => {:aki => 'aki-4deec439'}, :x86_64 => {:aki => 'aki-4feec43b'} |
ENDPOINTS | = | { 'eu-west-1' => { :endpoint => 's3-eu-west-1.amazonaws.com', :location => 'EU', :kernel => { :i386 => {:aki => 'aki-4deec439'}, :x86_64 => {:aki => 'aki-4feec43b'} |
# File lib/boxgrinder-build/helpers/s3-helper.rb, line 60 60: def self.endpoints 61: ENDPOINTS 62: end
# File lib/boxgrinder-build/helpers/s3-helper.rb, line 60 60: def self.endpoints 61: ENDPOINTS 62: end
AWS::S3 object should be instantiated already, as config can be inserted via global AWS.config or via AWS::S3.initialize
# File lib/boxgrinder-build/helpers/s3-helper.rb, line 26 26: def initialize(ec2, s3, options={}) 27: raise ArgumentError, "ec2 argument must not be nil" if ec2.nil? 28: raise ArgumentError, "s3 argument must not be nil" if s3.nil? 29: @ec2 = ec2 30: @s3 = s3 31: @log = options[:log] || LogHelper.new 32: end
AWS::S3 object should be instantiated already, as config can be inserted via global AWS.config or via AWS::S3.initialize
# File lib/boxgrinder-build/helpers/s3-helper.rb, line 26 26: def initialize(ec2, s3, options={}) 27: raise ArgumentError, "ec2 argument must not be nil" if ec2.nil? 28: raise ArgumentError, "s3 argument must not be nil" if s3.nil? 29: @ec2 = ec2 30: @s3 = s3 31: @log = options[:log] || LogHelper.new 32: end
# File lib/boxgrinder-build/helpers/s3-helper.rb, line 34 34: def bucket(options={}) 35: defaults = {:bucket => nil, :acl => :private, :location_constraint => 'us-east-1', :create_if_missing => false} 36: options = parse_opts(options, defaults) 37: 38: s3b = @s3.buckets[options[:bucket]] 39: return s3b if s3b.exists? 40: return @s3.buckets.create(options[:bucket], 41: :acl => options[:acl], 42: :location_constraint => options[:location_constraint]) if options[:create_if_missing] 43: nil 44: end
# File lib/boxgrinder-build/helpers/s3-helper.rb, line 34 34: def bucket(options={}) 35: defaults = {:bucket => nil, :acl => :private, :location_constraint => 'us-east-1', :create_if_missing => false} 36: options = parse_opts(options, defaults) 37: 38: s3b = @s3.buckets[options[:bucket]] 39: return s3b if s3b.exists? 40: return @s3.buckets.create(options[:bucket], 41: :acl => options[:acl], 42: :location_constraint => options[:location_constraint]) if options[:create_if_missing] 43: nil 44: end
# File lib/boxgrinder-build/helpers/s3-helper.rb, line 46 46: def delete_folder(bucket, path) 47: bucket.objects.with_prefix(deslash(path)).map(&:delete) 48: end
# File lib/boxgrinder-build/helpers/s3-helper.rb, line 46 46: def delete_folder(bucket, path) 47: bucket.objects.with_prefix(deslash(path)).map(&:delete) 48: end
# File lib/boxgrinder-build/helpers/s3-helper.rb, line 54 54: def parse_path(path) 55: return '' if path == '/' 56: #Remove preceding and trailing slashes 57: deslash(path) << '/' 58: end
# File lib/boxgrinder-build/helpers/s3-helper.rb, line 54 54: def parse_path(path) 55: return '' if path == '/' 56: #Remove preceding and trailing slashes 57: deslash(path) << '/' 58: end
# File lib/boxgrinder-build/helpers/s3-helper.rb, line 50 50: def stub_s3obj(bucket, path) 51: bucket.objects[path] 52: end