Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
12 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,24 @@ | ||
module Polipus | ||
module Plugin | ||
class Cleaner | ||
|
||
def initialize(options = {}) | ||
@reset = options[:reset] ||= false | ||
end | ||
|
||
def on_initialize crawler | ||
crawler.logger.info {"Cleaner plugin loaded"} | ||
unless @reset | ||
crawler.logger.info {"Cleaner plugin is disable, 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.new { | ||
on_initialize do |plugin_instance| | ||
if plugin_instance.options[:reset] | ||
@logger.info {"Cleaning all: url_tracker, storage, queue"} | ||
url_tracker.clear | ||
storage.clear | ||
queue_factory.clear | ||
@options[:queue_overflow_adapter].clear if @options[:queue_overflow_adapter] | ||
} | ||
else | ||
@logger.info {"Cleaner plugin is disable, add :reset => true to the plugin if you really know what you are doing"} | ||
end | ||
end | ||
|
||
def plugin_registered | ||
puts "Plugin #{self.class.name} registered with options: #{plugin_options}" | ||
@options[:reset] ||= false | ||
end | ||
|
||
end | ||
end | ||
end |