Class: Apollo::Scheduler::BaseScheduler

Inherits:
Object
  • Object
show all
Defined in:
lib/apollo_crawler/scheduler/base_scheduler.rb

Class Method Summary collapse

Class Method Details

.schedule(url, crawler = nil, opts = {}) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/apollo_crawler/scheduler/base_scheduler.rb', line 29

def self.schedule(url, crawler=nil, opts={})
	queued_url = Apollo::Model::QueuedUrl.where(:url => url).first

	if queued_url.nil? == false
		return queued_url
	end

	uri = URI.parse(url)
	domain = Apollo::Model::Domain.where(:name => uri.hostname).first
	if(domain.nil?)
		domain = Apollo::Model::Domain.new(:name => uri.hostname)
		domain.save
	end
		
	res = Apollo::Model::QueuedUrl.new(:url => url, :state => :queued, :crawler_name => crawler.to_s)
	res.save
	return res				
end