Class: CarthageCacheRes::AWSRepository
- Inherits:
-
Object
- Object
- CarthageCacheRes::AWSRepository
- Defined in:
- lib/carthage_cache_res/repository.rb
Instance Attribute Summary collapse
-
#bucket_name ⇒ Object
readonly
Returns the value of attribute bucket_name.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #archive_exist?(archive_filename) ⇒ Boolean
- #download(archive_filename, destination_path) ⇒ Object
-
#initialize(bucket_name, client_options = {}) ⇒ AWSRepository
constructor
A new instance of AWSRepository.
- #upload(archive_filename, archive_path) ⇒ Object
Constructor Details
#initialize(bucket_name, client_options = {}) ⇒ AWSRepository
Returns a new instance of AWSRepository.
10 11 12 13 |
# File 'lib/carthage_cache_res/repository.rb', line 10 def initialize(bucket_name, = {}) @client = ::Aws::S3::Client.new() @bucket_name = bucket_name end |
Instance Attribute Details
#bucket_name ⇒ Object (readonly)
Returns the value of attribute bucket_name.
8 9 10 |
# File 'lib/carthage_cache_res/repository.rb', line 8 def bucket_name @bucket_name end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
7 8 9 |
# File 'lib/carthage_cache_res/repository.rb', line 7 def client @client end |
Instance Method Details
#archive_exist?(archive_filename) ⇒ Boolean
15 16 17 |
# File 'lib/carthage_cache_res/repository.rb', line 15 def archive_exist?(archive_filename) ::Aws::S3::Object.new(bucket_name, archive_filename, client: client).exists? end |
#download(archive_filename, destination_path) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/carthage_cache_res/repository.rb', line 19 def download(archive_filename, destination_path) resp = client.get_object( response_target: destination_path, bucket: bucket_name, key: archive_filename) end |
#upload(archive_filename, archive_path) ⇒ Object
26 27 28 29 30 |
# File 'lib/carthage_cache_res/repository.rb', line 26 def upload(archive_filename, archive_path) File.open(archive_path, 'rb') do |file| client.put_object(bucket: bucket_name, key: archive_filename, body: file) end end |