Class: Polipus::Plugin::Cleaner

Inherits:
Object
  • Object
show all
Defined in:
lib/polipus/plugins/cleaner.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Cleaner

Returns a new instance of Cleaner.



5
6
7
# File 'lib/polipus/plugins/cleaner.rb', line 5

def initialize(options = {})
  @reset = options[:reset] ||= false
end

Instance Method Details

#on_initialize(crawler) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/polipus/plugins/cleaner.rb', line 9

def on_initialize(crawler)
  crawler.logger.info { 'Cleaner plugin loaded' }
  unless @reset
    crawler.logger.info { 'Cleaner plugin is disabled, add :reset => true to the plugin if you really know what you are doing' }
    return nil
  end
  crawler.logger.info { 'Cleaning all: url_tracker, storage, queue' }
  proc do
    url_tracker.clear
    storage.clear
    queue_factory.clear
    @options[:queue_overflow_adapter].clear if @options[:queue_overflow_adapter]
  end
end