Skip to content

Commit

Permalink
rewrote into new format
Browse files Browse the repository at this point in the history
  • Loading branch information
taganaka committed May 29, 2014
1 parent d19f859 commit 3bea13b
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions lib/polipus/plugins/cleaner.rb
@@ -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

0 comments on commit 3bea13b

Please sign in to comment.