Class: CarthageCache::HTTPRepository
- Inherits:
-
Object
- Object
- CarthageCache::HTTPRepository
- Defined in:
- lib/carthage_cache/repository.rb
Instance Attribute Summary collapse
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
Instance Method Summary collapse
- #archive_exist?(archive_filename) ⇒ Boolean
- #download(archive_filename, destination_path) ⇒ Object
-
#initialize(bucket_name, client_options = {}) ⇒ HTTPRepository
constructor
A new instance of HTTPRepository.
- #upload(archive_filename, archive_path) ⇒ Object
Constructor Details
#initialize(bucket_name, client_options = {}) ⇒ HTTPRepository
Returns a new instance of HTTPRepository.
38 39 40 41 42 |
# File 'lib/carthage_cache/repository.rb', line 38 def initialize(bucket_name, = {}) region = [:region] bucket_name = bucket_name @base_url = "https://s3-#{region}.amazonaws.com/#{bucket_name}" end |
Instance Attribute Details
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
36 37 38 |
# File 'lib/carthage_cache/repository.rb', line 36 def base_url @base_url end |
Instance Method Details
#archive_exist?(archive_filename) ⇒ Boolean
44 45 46 |
# File 'lib/carthage_cache/repository.rb', line 44 def archive_exist?(archive_filename) system "wget", "--method=HEAD", "#{base_url}/#{archive_filename}", "-q" end |
#download(archive_filename, destination_path) ⇒ Object
48 49 50 |
# File 'lib/carthage_cache/repository.rb', line 48 def download(archive_filename, destination_path) system "wget", "--output-document=#{destination_path}", "#{base_url}/#{archive_filename}", "-q" end |
#upload(archive_filename, archive_path) ⇒ Object
52 53 54 |
# File 'lib/carthage_cache/repository.rb', line 52 def upload(archive_filename, archive_path) raise "carthage_cache is working in read-only mode. Please configure AWS credentials first" end |