Class: GoogleAjaxCrawler::Crawler

Inherits:
Object
  • Object
show all
Defined in:
lib/google_ajax_crawler/crawler.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app = nil, &block) ⇒ Crawler

Returns a new instance of Crawler.



16
17
18
19
# File 'lib/google_ajax_crawler/crawler.rb', line 16

def initialize(app = nil, &block)
  @app = app
  self.class.configure &block
end

Class Method Details

.configure(&block) ⇒ Object



11
12
13
# File 'lib/google_ajax_crawler/crawler.rb', line 11

def configure(&block)
  @options = Options.new(self, &block)
end

.optionsObject



6
7
8
9
# File 'lib/google_ajax_crawler/crawler.rb', line 6

def options
  configure if @options.nil?
  @options
end

Instance Method Details

#call(env) ⇒ Object



25
26
27
28
29
30
# File 'lib/google_ajax_crawler/crawler.rb', line 25

def call(env)
  request = Rack::Request.new(env)
  return serve_crawlable_content_for(request) if is_search_engine?(request)
  
  @app.call(env)
end

#optionsObject



21
22
23
# File 'lib/google_ajax_crawler/crawler.rb', line 21

def options
  self.class.options
end