lib/vos/drivers/s3.rb in vos-0.3.15 vs lib/vos/drivers/s3.rb in vos-0.4.0
- old
+ new
@@ -2,18 +2,18 @@
require 'vos/drivers/s3_vfs_storage'
module Vos
module Drivers
class S3
+ attr_accessor :box
attr_reader :connection, :bucket
- DEFAULT_OPTIONS = {
- # public: true
- }
-
- def initialize initialization_options, options = {}
- @initialization_options, @options = initialization_options, DEFAULT_OPTIONS.merge(options)
+ def initialize options = {}
+ options = options.clone
+ @bucket_name = options.delete(:bucket) || raise("S3 bucket not provided!")
+ @acl = options.delete(:acl) || :public_read
+ @options = options
end
#
# Establishing SSH channel
@@ -30,15 +30,12 @@
close
end
end
else
unless connection
- @connection = ::AWS::S3.new self.initialization_options.clone
- unless bucket = options[:bucket]
- raise("S3 bucket not provided (use Vos::Drivers::S3.new({initialization options ...}, {bucket: '<bucket_name>'}))!")
- end
- @bucket = @connection.buckets[bucket]
+ @connection = ::AWS::S3.new self.options.clone
+ @bucket = @connection.buckets[bucket_name]
end
end
end
def close; end
@@ -50,17 +47,17 @@
#
# Miscellaneous
#
- def inspect; "<#{self.class.name} #{initialization_options.inspect}, #{options.inspect}>" end
+ def inspect; "<#{self.class.name} #{options.merge(bucket: bucket_name).inspect}>" end
alias_method :to_s, :inspect
def _clear
bucket.objects.each{|o| o.delete}
end
protected
- attr_reader :initialization_options, :options
+ attr_reader :options, :bucket_name, :acl
end
end
end
\ No newline at end of file