Class: InteractiveS3::S3
- Inherits:
-
Object
- Object
- InteractiveS3::S3
- Defined in:
- lib/interactive_s3/s3.rb
Instance Attribute Summary collapse
-
#stack ⇒ Object
Returns the value of attribute stack.
Instance Method Summary collapse
- #bucket? ⇒ Boolean
- #current_path ⇒ Object
- #empty? ⇒ Boolean (also: #root?)
- #exists? ⇒ Boolean
-
#initialize ⇒ S3
constructor
A new instance of S3.
- #reset ⇒ Object
Constructor Details
#initialize ⇒ S3
Returns a new instance of S3.
7 8 9 |
# File 'lib/interactive_s3/s3.rb', line 7 def initialize @stack = [] end |
Instance Attribute Details
#stack ⇒ Object
Returns the value of attribute stack.
5 6 7 |
# File 'lib/interactive_s3/s3.rb', line 5 def stack @stack end |
Instance Method Details
#bucket? ⇒ Boolean
24 25 26 |
# File 'lib/interactive_s3/s3.rb', line 24 def bucket? stack.size == 1 end |
#current_path ⇒ Object
11 12 13 |
# File 'lib/interactive_s3/s3.rb', line 11 def current_path empty? ? '' : "s3://#{stack.join('/')}" end |
#empty? ⇒ Boolean Also known as: root?
15 16 17 |
# File 'lib/interactive_s3/s3.rb', line 15 def empty? stack.empty? end |
#exists? ⇒ Boolean
28 29 30 31 32 |
# File 'lib/interactive_s3/s3.rb', line 28 def exists? return true if root? output, error, status = Open3.capture3('aws', 's3', 'ls', current_path) status.success? && (bucket? || (output != '' && output.match(/(\S*)\/$/)[1] == stack.last)) end |
#reset ⇒ Object
20 21 22 |
# File 'lib/interactive_s3/s3.rb', line 20 def reset self.stack = [] end |