def self.spam?(url)
@cache.fetch(url) do |url|
return @cache[url] = false unless address = url[REGEXPS[:address], 1]
firstchar = address[0]
secondchar = address[1]
thirdchar = address[2]
unless @options.whitelist.nil?
@whitelist[:regexps].each do |wl_regexp|
return @cache[url] = false if address =~ wl_regexp
end
if @whitelist.key?(firstchar) && @whitelist[firstchar].key?(secondchar) &&
@whitelist[firstchar][secondchar].key?(thirdchar)
@whitelist[firstchar][secondchar][thirdchar].each do |wl_url|
return @cache[url] = false if address.index(wl_url) == 0
end
end
end
@blacklist[:regexps].each do |bl_regexp|
return @cache[url] = true if address =~ bl_regexp
end
if @blacklist.key?(firstchar) && @blacklist[firstchar].key?(secondchar) &&
@blacklist[firstchar][secondchar].key?(thirdchar)
@blacklist[firstchar][secondchar][thirdchar].each do |bl_url|
return @cache[url] = true if address.index(bl_url) == 0
end
end
return @cache[url] = false
end
end