Class: Vos::Drivers::S3
- Inherits:
-
Object
- Object
- Vos::Drivers::S3
- Includes:
- S3VfsStorage
- Defined in:
- lib/vos/drivers/s3.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ # public: true }
Instance Attribute Summary collapse
-
#bucket ⇒ Object
readonly
Returns the value of attribute bucket.
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
- #_clear ⇒ Object
- #close ⇒ Object
-
#initialize(initialization_options, options = {}) ⇒ S3
constructor
A new instance of S3.
-
#inspect ⇒ Object
(also: #to_s)
Miscellaneous.
-
#open(&block) ⇒ Object
Establishing SSH channel.
Methods included from S3VfsStorage
#attributes, #create_dir, #delete_dir, #delete_file, #each_entry, #local?, #read_file, #set_attributes, #tmp, #write_file
Constructor Details
#initialize(initialization_options, options = {}) ⇒ S3
Returns a new instance of S3.
13 14 15 |
# File 'lib/vos/drivers/s3.rb', line 13 def initialize , = {} @initialization_options, @options = , DEFAULT_OPTIONS.merge() end |
Instance Attribute Details
#bucket ⇒ Object (readonly)
Returns the value of attribute bucket.
7 8 9 |
# File 'lib/vos/drivers/s3.rb', line 7 def bucket @bucket end |
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
7 8 9 |
# File 'lib/vos/drivers/s3.rb', line 7 def connection @connection end |
Instance Method Details
#_clear ⇒ Object
58 59 60 |
# File 'lib/vos/drivers/s3.rb', line 58 def _clear bucket.objects.each{|o| o.delete} end |
#close ⇒ Object
44 |
# File 'lib/vos/drivers/s3.rb', line 44 def close; end |
#inspect ⇒ Object Also known as: to_s
Miscellaneous
55 |
# File 'lib/vos/drivers/s3.rb', line 55 def inspect; "<#{self.class.name} #{.inspect}, #{.inspect}>" end |
#open(&block) ⇒ Object
Establishing SSH channel
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/vos/drivers/s3.rb', line 21 def open &block if block if connection block.call self else begin open block.call self ensure close end end else unless connection @connection = ::AWS::S3.new self..clone unless bucket = [:bucket] raise("S3 bucket not provided (use Vos::Drivers::S3.new({initialization options ...}, {bucket: '<bucket_name>'}))!") end @bucket = @connection.buckets[bucket] end end end |