Class: SimpleS3::S3
- Inherits:
-
Object
- Object
- SimpleS3::S3
- Defined in:
- lib/simple_s3.rb
Instance Attribute Summary collapse
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
-
#initialize(access_key, secret_key) ⇒ S3
constructor
A new instance of S3.
- #store(local, remote_dir, bucket, options = {}) ⇒ Object
Constructor Details
#initialize(access_key, secret_key) ⇒ S3
Returns a new instance of S3.
9 10 11 |
# File 'lib/simple_s3.rb', line 9 def initialize(access_key, secret_key) connect! access_key, secret_key end |
Instance Attribute Details
#verbose ⇒ Object
Returns the value of attribute verbose.
7 8 9 |
# File 'lib/simple_s3.rb', line 7 def verbose @verbose end |
Instance Method Details
#store(local, remote_dir, bucket, options = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/simple_s3.rb', line 13 def store(local, remote_dir, bucket, = {}) # TODO better error handling return unless File.exists?(local) paths = File.directory?(local) ? paths = paths(local) : paths = [local] paths.each do |path| destination = remote_path_for(path, remote_dir, [:baseline]) unless AWS::S3::S3Object.exists?(destination, bucket) || [:test] log "Storing #{destination}" if verbose AWS::S3::S3Object.store(destination, open(path), bucket) if [:delete_source] && AWS::S3::S3Object.exists?(destination, bucket) File.delete(path) end end end end |