Class: Rspider::SpiderConfParser

Inherits:
ConfParser
  • Object
show all
Defined in:
lib/rspider/ConfParser.rb

Constant Summary

Constants inherited from ConfParser

ConfParser::Version

Instance Method Summary collapse

Methods inherited from ConfParser

#config_file, #config_file=, #get_value, #nil_value, #override_value, #to_s

Constructor Details

#initialize(config_file) ⇒ SpiderConfParser

Returns a new instance of SpiderConfParser.



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/rspider/ConfParser.rb', line 109

def initialize(config_file)
	super(config_file)
	begin 
		if(self["can_leave_domain"].pop.upcase=="YES")
			self["can_leave_domain"]=true
		else
			self["can_leave_domain"]=false
		end
		self["max_depth"]=self["max_depth"].pop.to_i
		self["max_redirects"]=self["max_redirects"].pop.to_i
		self["save_path"]=self["save_path"].pop
		self["source"]=self["source"].pop
		self["buckets"]=self["buckets"].pop.to_i
		self["threads"]=self["threads"].pop.to_i
		self["same_domain_regexp"]=self["same_domain_regexp"].pop
		self["agent"]=self["agent"].pop
		self["urls"]=self["urls"].pop
		self["logger"]=self["logger"].pop
		self["url_max_length"]=self["url_max_length"].pop.to_i
		self["max_document_length"]=self["max_document_length"].pop.to_i
	#Mysql settings
		self["host"]=self["host"].pop
		self["db"]=self["db"].pop
		self["user"]=self["user"].pop
		self["pass"]=self["pass"].pop
		self["timeout"]=self["timeout"].pop.to_i
	rescue NoMethodError
		raise "Some thing error while conf pop"
		exit
	end
#urls="http://www.coolcode.cn/"
#can_leave_domain= "yes"
#max_depth=4
#save_path="/tmp/coolcode/"
#buckets=128
#source="coolcode"
#threads=10
#same_domain_regexp="\.coolcode\.cn"
end