Class: TrashMan::Manager

Inherits:
Object
  • Object
show all
Defined in:
lib/trashman/manager.rb

Instance Method Summary collapse

Constructor Details

#initialize(provider, options = {}) ⇒ Manager

Returns a new instance of Manager.



6
7
8
9
10
11
12
# File 'lib/trashman/manager.rb', line 6

def initialize(provider, options = {})
  @options = options

  @connection = Fog::Storage.new(
    { provider: provider }.merge(options[:credentials])
  )
end

Instance Method Details

#cleanup!(&block) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/trashman/manager.rb', line 14

def cleanup!(&block)
  queued_files.each do |file|
    yield(file) if block

    if !options[:dry_run]
      file.destroy
    end
  end

  queued_files.count
end