Class: SmoothS3::Service
- Inherits:
-
Object
- Object
- SmoothS3::Service
- Defined in:
- lib/smooth_s3/service.rb
Constant Summary collapse
- @@new_buckets =
{}
Instance Attribute Summary collapse
-
#aws_key ⇒ Object
readonly
Returns the value of attribute aws_key.
-
#aws_secret ⇒ Object
readonly
Returns the value of attribute aws_secret.
-
#buckets ⇒ Object
Returns the value of attribute buckets.
-
#proxy_service ⇒ Object
readonly
Returns the value of attribute proxy_service.
-
#ssl ⇒ Object
readonly
Returns the value of attribute ssl.
Class Method Summary collapse
-
.new_buckets ⇒ Object
Make @@new_buckets accessible outside of the class.
- .new_buckets=(value) ⇒ Object
Instance Method Summary collapse
- #directory_sync(bucket, directory, options = {}) ⇒ Object (also: #sync_directory)
- #directory_sync!(bucket, directory, options = {}) ⇒ Object (also: #sync_directory!)
- #gather_buckets ⇒ Object
-
#initialize(opts = {}) ⇒ Service
constructor
A new instance of Service.
- #refresh ⇒ Object
- #timestamped_directory_sync(bucket, directory, options = {}) ⇒ Object
- #timestamped_directory_sync!(bucket, directory, options = {}) ⇒ Object
- #timestamped_upload(bucket, files, options = {}) ⇒ Object
- #timestamped_upload!(bucket, files, options = {}) ⇒ Object
- #upload(bucket, files, options = {}) ⇒ Object
- #upload!(bucket, files, options = {}) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Service
Returns a new instance of Service.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/smooth_s3/service.rb', line 8 def initialize(opts={}) @aws_key = opts.delete(:aws_key) @aws_secret = opts.delete(:aws_secret) @ssl = opts.delete(:ssl) == true ? true : false @proxy_service = S3::Service.new(:access_key_id => @aws_key, :secret_access_key => @aws_secret, :use_ssl => @ssl) test_connection @buckets = gather_buckets @@new_buckets[@aws_key] = [] end |
Instance Attribute Details
#aws_key ⇒ Object (readonly)
Returns the value of attribute aws_key.
3 4 5 |
# File 'lib/smooth_s3/service.rb', line 3 def aws_key @aws_key end |
#aws_secret ⇒ Object (readonly)
Returns the value of attribute aws_secret.
3 4 5 |
# File 'lib/smooth_s3/service.rb', line 3 def aws_secret @aws_secret end |
#buckets ⇒ Object
Returns the value of attribute buckets.
4 5 6 |
# File 'lib/smooth_s3/service.rb', line 4 def buckets @buckets end |
#proxy_service ⇒ Object (readonly)
Returns the value of attribute proxy_service.
3 4 5 |
# File 'lib/smooth_s3/service.rb', line 3 def proxy_service @proxy_service end |
#ssl ⇒ Object (readonly)
Returns the value of attribute ssl.
3 4 5 |
# File 'lib/smooth_s3/service.rb', line 3 def ssl @ssl end |
Class Method Details
.new_buckets ⇒ Object
Make @@new_buckets accessible outside of the class
75 76 77 |
# File 'lib/smooth_s3/service.rb', line 75 def self.new_buckets @@new_buckets end |
.new_buckets=(value) ⇒ Object
79 80 81 |
# File 'lib/smooth_s3/service.rb', line 79 def self.new_buckets=(value) @@new_buckets = value end |
Instance Method Details
#directory_sync(bucket, directory, options = {}) ⇒ Object Also known as: sync_directory
50 51 52 |
# File 'lib/smooth_s3/service.rb', line 50 def directory_sync(bucket, directory, ={}) Uploader.directory_sync(self, bucket, directory, ) end |
#directory_sync!(bucket, directory, options = {}) ⇒ Object Also known as: sync_directory!
54 55 56 |
# File 'lib/smooth_s3/service.rb', line 54 def directory_sync!(bucket, directory, ={}) Uploader.directory_sync!(self, bucket, directory, ) end |
#gather_buckets ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/smooth_s3/service.rb', line 21 def gather_buckets service_buckets = {} begin self.proxy_service.buckets.each { |b| service_buckets.merge!(b.name => b) } rescue puts "There was an error trying to fetch the service's buckets. Retrying..." sleep 1 self.gather_buckets end service_buckets end |
#refresh ⇒ Object
35 36 37 38 39 40 |
# File 'lib/smooth_s3/service.rb', line 35 def refresh new_buckets = @@new_buckets[self.aws_key] new_buckets.each {|nb| self.buckets[nb.name] = nb} return self end |
#timestamped_directory_sync(bucket, directory, options = {}) ⇒ Object
66 67 68 |
# File 'lib/smooth_s3/service.rb', line 66 def (bucket, directory, ={}) Uploader.(self, bucket, directory, ) end |
#timestamped_directory_sync!(bucket, directory, options = {}) ⇒ Object
70 71 72 |
# File 'lib/smooth_s3/service.rb', line 70 def (bucket, directory, ={}) Uploader.(self, bucket, directory, ) end |
#timestamped_upload(bucket, files, options = {}) ⇒ Object
58 59 60 |
# File 'lib/smooth_s3/service.rb', line 58 def (bucket, files, ={}) Uploader.(self, bucket, files, ) end |
#timestamped_upload!(bucket, files, options = {}) ⇒ Object
62 63 64 |
# File 'lib/smooth_s3/service.rb', line 62 def (bucket, files, ={}) Uploader.(self, bucket, files, ) end |