Class: Polipus::Plugin::Sleeper
- Inherits:
-
Object
- Object
- Polipus::Plugin::Sleeper
- Defined in:
- lib/polipus/plugins/sleeper.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Sleeper
constructor
A new instance of Sleeper.
- #on_initialize(crawler) ⇒ Object
- #on_message_processed(_crawler) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Sleeper
Returns a new instance of Sleeper.
4 5 6 |
# File 'lib/polipus/plugins/sleeper.rb', line 4 def initialize( = {}) @delay = [:delay] ||= 1 end |
Instance Method Details
#on_initialize(crawler) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/polipus/plugins/sleeper.rb', line 8 def on_initialize(crawler) crawler.logger.info { "Sleeper plugin loaded, sleep for #{@delay} after each request" } proc do # Set to 1 the number of threads @options[:workers] = 1 end end |
#on_message_processed(_crawler) ⇒ Object
16 17 18 |
# File 'lib/polipus/plugins/sleeper.rb', line 16 def (_crawler) sleep @delay end |