Class: S3Cleaner::Clean
- Inherits:
-
Object
- Object
- S3Cleaner::Clean
- Defined in:
- lib/s3_cleaner/clean.rb
Instance Attribute Summary collapse
-
#aws_config ⇒ Object
readonly
Returns the value of attribute aws_config.
-
#bucket_name ⇒ Object
readonly
Returns the value of attribute bucket_name.
-
#num_releases ⇒ Object
readonly
Returns the value of attribute num_releases.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
Instance Method Summary collapse
- #delete_old_releases ⇒ Object
- #directories_to_delete ⇒ Object
-
#initialize(args) ⇒ Clean
constructor
A new instance of Clean.
Constructor Details
#initialize(args) ⇒ Clean
Returns a new instance of Clean.
5 6 7 8 9 10 |
# File 'lib/s3_cleaner/clean.rb', line 5 def initialize(args) @bucket_name = args.fetch(:bucket_name) @prefix = args.fetch(:prefix) @num_releases = args.fetch(:num_releases) @aws_config = args.fetch(:aws_config) end |
Instance Attribute Details
#aws_config ⇒ Object (readonly)
Returns the value of attribute aws_config.
3 4 5 |
# File 'lib/s3_cleaner/clean.rb', line 3 def aws_config @aws_config end |
#bucket_name ⇒ Object (readonly)
Returns the value of attribute bucket_name.
3 4 5 |
# File 'lib/s3_cleaner/clean.rb', line 3 def bucket_name @bucket_name end |
#num_releases ⇒ Object (readonly)
Returns the value of attribute num_releases.
3 4 5 |
# File 'lib/s3_cleaner/clean.rb', line 3 def num_releases @num_releases end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
3 4 5 |
# File 'lib/s3_cleaner/clean.rb', line 3 def prefix @prefix end |
Instance Method Details
#delete_old_releases ⇒ Object
12 13 14 15 16 17 |
# File 'lib/s3_cleaner/clean.rb', line 12 def delete_old_releases return if directories_to_delete.nil? || directories_to_delete.empty? directories_to_delete.each do |dir| bucket.objects.with_prefix(dir).delete_all end end |
#directories_to_delete ⇒ Object
19 20 21 |
# File 'lib/s3_cleaner/clean.rb', line 19 def directories_to_delete @directories_to_delete ||= directories[num_releases..-1] end |