Class: S3Rails::S3
- Inherits:
-
Object
- Object
- S3Rails::S3
- Defined in:
- lib/s3_rails/s3.rb
Instance Attribute Summary collapse
-
#access_key_id ⇒ Object
Returns the value of attribute access_key_id.
-
#bucket ⇒ Object
Returns the value of attribute bucket.
-
#bucket_name ⇒ Object
Returns the value of attribute bucket_name.
-
#last_load ⇒ Object
Returns the value of attribute last_load.
-
#objects ⇒ Object
Returns the value of attribute objects.
-
#region ⇒ Object
Returns the value of attribute region.
-
#s3 ⇒ Object
Returns the value of attribute s3.
-
#secret_access_key ⇒ Object
Returns the value of attribute secret_access_key.
Instance Method Summary collapse
- #buckets ⇒ Object
-
#initialize(config_file) ⇒ S3
constructor
A new instance of S3.
- #load_cache ⇒ Object
Constructor Details
#initialize(config_file) ⇒ S3
Returns a new instance of S3.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/s3_rails/s3.rb', line 7 def initialize(config_file) puts Dir.pwd config = YAML::load(ERB.new(IO.read(config_file)).result) @access_key_id = config['s3_rails']['access_key_id'] @secret_access_key = config['s3_rails']['secret_access_key'] @bucket_name = config['s3_rails']['bucket'] @region = config['s3_rails']['region'] @last_load = nil AWS.config(access_key_id: @access_key_id, secret_access_key: @secret_access_key, region: @region) @s3 = AWS::S3.new unless @s3.buckets[ @bucket_name ].nil? @bucket = @s3.buckets[ @bucket_name ] end load_cache end |
Instance Attribute Details
#access_key_id ⇒ Object
Returns the value of attribute access_key_id.
5 6 7 |
# File 'lib/s3_rails/s3.rb', line 5 def access_key_id @access_key_id end |
#bucket ⇒ Object
Returns the value of attribute bucket.
5 6 7 |
# File 'lib/s3_rails/s3.rb', line 5 def bucket @bucket end |
#bucket_name ⇒ Object
Returns the value of attribute bucket_name.
5 6 7 |
# File 'lib/s3_rails/s3.rb', line 5 def bucket_name @bucket_name end |
#last_load ⇒ Object
Returns the value of attribute last_load.
5 6 7 |
# File 'lib/s3_rails/s3.rb', line 5 def last_load @last_load end |
#objects ⇒ Object
Returns the value of attribute objects.
5 6 7 |
# File 'lib/s3_rails/s3.rb', line 5 def objects @objects end |
#region ⇒ Object
Returns the value of attribute region.
5 6 7 |
# File 'lib/s3_rails/s3.rb', line 5 def region @region end |
#s3 ⇒ Object
Returns the value of attribute s3.
5 6 7 |
# File 'lib/s3_rails/s3.rb', line 5 def s3 @s3 end |
#secret_access_key ⇒ Object
Returns the value of attribute secret_access_key.
5 6 7 |
# File 'lib/s3_rails/s3.rb', line 5 def secret_access_key @secret_access_key end |
Instance Method Details
#buckets ⇒ Object
26 27 28 |
# File 'lib/s3_rails/s3.rb', line 26 def buckets @s3.buckets end |
#load_cache ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/s3_rails/s3.rb', line 30 def load_cache @objects = Hash[@bucket.objects.map {|o| [ o.key, S3Template.new(o.key, o.read, o.last_modified, o) ]}] @last_load = Time.now end |