Class: Usmu::S3::RemoteFiles
- Inherits:
-
Object
- Object
- Usmu::S3::RemoteFiles
- Includes:
- Deployment::RemoteFileInterface
- Defined in:
- lib/usmu/s3/remote_files.rb
Instance Attribute Summary collapse
-
#bucket ⇒ void
readonly
private
Returns the value of attribute bucket.
-
#s3 ⇒ void
readonly
private
Returns the value of attribute s3.
Instance Method Summary collapse
- #files_list ⇒ void
-
#initialize(configuration) ⇒ RemoteFiles
constructor
A new instance of RemoteFiles.
- #objects ⇒ void private
- #stat(filename) ⇒ void
Constructor Details
#initialize(configuration) ⇒ RemoteFiles
Returns a new instance of RemoteFiles.
11 12 13 14 |
# File 'lib/usmu/s3/remote_files.rb', line 11 def initialize(configuration) @s3 = Aws::S3::Resource.new(credentials: configuration.credentials, region: configuration.region) @bucket = @s3.bucket(configuration.bucket) end |
Instance Attribute Details
#bucket ⇒ void (readonly, private)
Returns the value of attribute bucket.
39 40 41 |
# File 'lib/usmu/s3/remote_files.rb', line 39 def bucket @bucket end |
#s3 ⇒ void (readonly, private)
Returns the value of attribute s3.
38 39 40 |
# File 'lib/usmu/s3/remote_files.rb', line 38 def s3 @s3 end |
Instance Method Details
#files_list ⇒ void
17 18 19 |
# File 'lib/usmu/s3/remote_files.rb', line 17 def files_list objects.map {|o| o.key } end |
#objects ⇒ void (private)
41 42 43 |
# File 'lib/usmu/s3/remote_files.rb', line 41 def objects @objects ||= @bucket.objects.to_a end |
#stat(filename) ⇒ void
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/usmu/s3/remote_files.rb', line 22 def stat(filename) obj = objects.select {|o| o.key.eql? filename }.first return nil if obj.nil? etag = unless obj.etag.index('-') obj.etag.gsub(/^["]|["]$/, '') end { md5: etag, mtime: obj.last_modified, } end |