Class: Egads::S3Tarball
- Inherits:
-
Object
- Object
- Egads::S3Tarball
- Defined in:
- lib/egads/s3_tarball.rb
Instance Attribute Summary collapse
-
#remote ⇒ Object
readonly
Returns the value of attribute remote.
-
#seed ⇒ Object
readonly
Returns the value of attribute seed.
-
#sha ⇒ Object
readonly
Returns the value of attribute sha.
Instance Method Summary collapse
- #bucket ⇒ Object
- #config ⇒ Object
-
#download(file) ⇒ Object
Write the S3 object’s contents to a local file.
- #exists? ⇒ Boolean
-
#initialize(sha, options = {}) ⇒ S3Tarball
constructor
A new instance of S3Tarball.
- #key ⇒ Object
- #local_tar_path ⇒ Object
- #upload(path = local_tar_path) ⇒ Object
Constructor Details
#initialize(sha, options = {}) ⇒ S3Tarball
Returns a new instance of S3Tarball.
4 5 6 7 8 |
# File 'lib/egads/s3_tarball.rb', line 4 def initialize(sha, = {}) @sha = sha @remote = [:remote] @seed = [:seed] end |
Instance Attribute Details
#remote ⇒ Object (readonly)
Returns the value of attribute remote.
3 4 5 |
# File 'lib/egads/s3_tarball.rb', line 3 def remote @remote end |
#seed ⇒ Object (readonly)
Returns the value of attribute seed.
3 4 5 |
# File 'lib/egads/s3_tarball.rb', line 3 def seed @seed end |
#sha ⇒ Object (readonly)
Returns the value of attribute sha.
3 4 5 |
# File 'lib/egads/s3_tarball.rb', line 3 def sha @sha end |
Instance Method Details
#bucket ⇒ Object
41 42 43 |
# File 'lib/egads/s3_tarball.rb', line 41 def bucket config.s3_bucket end |
#config ⇒ Object
10 11 12 |
# File 'lib/egads/s3_tarball.rb', line 10 def config remote ? RemoteConfig : Config end |
#download(file) ⇒ Object
Write the S3 object’s contents to a local file
37 38 39 |
# File 'lib/egads/s3_tarball.rb', line 37 def download(file) bucket.object(key).get(response_target: file) end |
#exists? ⇒ Boolean
22 23 24 |
# File 'lib/egads/s3_tarball.rb', line 22 def exists? bucket.object(key).exists? end |
#key ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/egads/s3_tarball.rb', line 14 def key [ config.s3_prefix, seed ? 'seeds' : nil, "#{sha}.tar.gz" ].compact * '/' end |
#local_tar_path ⇒ Object
26 27 28 |
# File 'lib/egads/s3_tarball.rb', line 26 def local_tar_path "tmp/#{sha}.tar.gz" end |
#upload(path = local_tar_path) ⇒ Object
30 31 32 33 34 |
# File 'lib/egads/s3_tarball.rb', line 30 def upload(path=local_tar_path) File.open(path) {|f| bucket.put_object(key: key, body: f) } end |