Class: Lexicon::Common::Remote::S3Client
- Inherits:
-
Object
- Object
- Lexicon::Common::Remote::S3Client
- Defined in:
- lib/lexicon/common/remote/s3_client.rb
Instance Attribute Summary collapse
- #raw ⇒ Aws::S3::Client readonly
Instance Method Summary collapse
- #bucket_exist?(name) ⇒ Boolean
- #ensure_bucket_absent(name) ⇒ Object
-
#initialize(raw:) ⇒ S3Client
constructor
A new instance of S3Client.
- #ls(bucket) ⇒ Array<Object>
Constructor Details
#initialize(raw:) ⇒ S3Client
Returns a new instance of S3Client.
11 12 13 |
# File 'lib/lexicon/common/remote/s3_client.rb', line 11 def initialize(raw:) @raw = raw end |
Instance Attribute Details
#raw ⇒ Aws::S3::Client (readonly)
8 9 10 |
# File 'lib/lexicon/common/remote/s3_client.rb', line 8 def raw @raw end |
Instance Method Details
#bucket_exist?(name) ⇒ Boolean
24 25 26 27 28 29 30 31 32 |
# File 'lib/lexicon/common/remote/s3_client.rb', line 24 def bucket_exist?(name) if raw.head_bucket(bucket: name) true else false end rescue StandardError false end |
#ensure_bucket_absent(name) ⇒ Object
35 36 37 38 39 |
# File 'lib/lexicon/common/remote/s3_client.rb', line 35 def ensure_bucket_absent(name) if bucket_exist?(name) raw.delete_bucket(bucket: name) end end |
#ls(bucket) ⇒ Array<Object>
16 17 18 19 20 |
# File 'lib/lexicon/common/remote/s3_client.rb', line 16 def ls(bucket) raw.list_objects_v2(bucket: bucket) .to_h .fetch(:contents, []) end |