Module: RCrawler

Defined in:
lib/rcrawler.rb,
lib/rcrawler/async.rb,
lib/rcrawler/crawl.rb,
lib/rcrawler/driver.rb,
lib/rcrawler/version.rb,
lib/rcrawler/configuration.rb

Defined Under Namespace

Classes: Async, Configuration, Crawl, Driver

Constant Summary collapse

VERSION =
"0.0.2"

Class Method Summary collapse

Class Method Details

.async(&block) ⇒ Object



35
36
37
38
39
# File 'lib/rcrawler.rb', line 35

def async(&block)
  async_threads = Async.new
  async_threads.instance_eval &block
  async_threads.execute
end

.configure(&block) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/rcrawler.rb', line 27

def configure(&block)
  if block_given?
    @config.configure &block
  else
    @config
  end
end

.crawl(&block) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/rcrawler.rb', line 19

def crawl(&block)
  begin
    Timeout::timeout(@config.timeout) {Crawl.new.instance_eval &block}
  rescue Timeout::Error => e
    raise if @config.timeout_proc == :raise
  end
end