Class: S3::Service
- Inherits:
-
Object
- Object
- S3::Service
- Includes:
- Proxies, Parser
- Defined in:
- lib/s3/service.rb
Instance Attribute Summary (collapse)
-
- (Object) access_key_id
readonly
Returns the value of attribute access_key_id.
-
- (Object) proxy
readonly
Returns the value of attribute proxy.
-
- (Object) secret_access_key
readonly
Returns the value of attribute secret_access_key.
-
- (Object) use_ssl
readonly
Returns the value of attribute use_ssl.
Instance Method Summary (collapse)
-
- (Object) ==(other)
Compares service to other, by access_key_id and secret_access_key.
-
- (Object) bucket(name)
Returns the bucket with the given name.
-
- (Object) buckets
Returns all buckets in the service and caches the result (see reload).
-
- (Service) initialize(options)
constructor
Creates new service.
-
- (Object) inspect
:nodoc:.
-
- (Object) port
Returns 443 or 80, depends on :use_ssl value from initializer.
-
- (Object) protocol
Returns "http://" or "https://", depends on :use_ssl value from initializer.
Methods included from Parser
#parse_copy_object_result, #parse_error, #parse_is_truncated, #parse_list_all_my_buckets_result, #parse_list_bucket_result, #parse_location_constraint, #rexml_document
Constructor Details
- (Service) initialize(options)
Creates new service.
Options
-
:access_key_id - Access key id (REQUIRED)
-
:secret_access_key - Secret access key (REQUIRED)
-
:use_ssl - Use https or http protocol (false by default)
-
:debug - Display debug information on the STDOUT (false by default)
-
:timeout - Timeout to use by the Net::HTTP object (60 by default)
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/s3/service.rb', line 25 def initialize() @access_key_id = .fetch(:access_key_id) @secret_access_key = .fetch(:secret_access_key) @use_ssl = .fetch(:use_ssl, false) @timeout = .fetch(:timeout, 60) @debug = .fetch(:debug, false) raise ArgumentError, "Missing proxy settings. Must specify at least :host." if [:proxy] && ![:proxy][:host] @proxy = .fetch(:proxy, nil) end |
Instance Attribute Details
- (Object) access_key_id (readonly)
Returns the value of attribute access_key_id
6 7 8 |
# File 'lib/s3/service.rb', line 6 def access_key_id @access_key_id end |
- (Object) proxy (readonly)
Returns the value of attribute proxy
6 7 8 |
# File 'lib/s3/service.rb', line 6 def proxy @proxy end |
- (Object) secret_access_key (readonly)
Returns the value of attribute secret_access_key
6 7 8 |
# File 'lib/s3/service.rb', line 6 def secret_access_key @secret_access_key end |
- (Object) use_ssl (readonly)
Returns the value of attribute use_ssl
6 7 8 |
# File 'lib/s3/service.rb', line 6 def use_ssl @use_ssl end |
Instance Method Details
- (Object) ==(other)
Compares service to other, by access_key_id and secret_access_key
10 11 12 |
# File 'lib/s3/service.rb', line 10 def ==(other) self.access_key_id == other.access_key_id and self.secret_access_key == other.secret_access_key end |
- (Object) bucket(name)
Returns the bucket with the given name. Does not check whether the bucket exists. But also does not issue any HTTP requests, so it's much faster than buckets.find
45 46 47 |
# File 'lib/s3/service.rb', line 45 def bucket(name) Bucket.send(:new, self, name) end |
- (Object) buckets
Returns all buckets in the service and caches the result (see reload)
38 39 40 |
# File 'lib/s3/service.rb', line 38 def buckets Proxy.new(lambda { list_all_my_buckets }, :owner => self, :extend => BucketsExtension) end |
- (Object) inspect
:nodoc:
61 62 63 |
# File 'lib/s3/service.rb', line 61 def inspect #:nodoc: "#<#{self.class}:#@access_key_id>" end |
- (Object) port
Returns 443 or 80, depends on :use_ssl value from initializer
57 58 59 |
# File 'lib/s3/service.rb', line 57 def port use_ssl ? 443 : 80 end |
- (Object) protocol
Returns "http://" or "https://", depends on :use_ssl value from initializer
51 52 53 |
# File 'lib/s3/service.rb', line 51 def protocol use_ssl ? "https://" : "http://" end |