Skip to content

Commit

Permalink
fixing for 1.8.7
Browse files Browse the repository at this point in the history
  • Loading branch information
stewartmckee committed May 6, 2012
1 parent 376e136 commit 87c4b0c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
1 change: 1 addition & 0 deletions Rakefile
Expand Up @@ -6,6 +6,7 @@ require [File.dirname(__FILE__), "lib", "cobweb"].join("/")
task :default => :spec

RSpec::Core::RakeTask.new do |t|
ENV['RUBY_ENVIRONMENT'] = "test"
t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
# Put spec opts in a file named .rspec in root
end
7 changes: 3 additions & 4 deletions lib/cobweb_crawler.rb
Expand Up @@ -68,11 +68,10 @@ def crawl(base_url, crawl_options = {}, &block)
# reject the link if we've crawled it or queued it
internal_links.reject!{|link| @redis.sismember("crawled", link)}
internal_links.reject!{|link| @redis.sismember("queued", link)}



# select the link if its internal
internal_links = internal_links.select{|link| internal_link?(link)}

internal_links.each do |link|
puts "Added #{link.to_s} to queue" if @debug
@redis.sadd "queued", link
Expand All @@ -85,7 +84,7 @@ def crawl(base_url, crawl_options = {}, &block)
@stats.update_statistics(content, crawl_counter, queue_counter)
@stats.update_status("Completed #{url}.")
puts "Crawled: #{crawl_counter.to_i} Limit: #{@options[:crawl_limit].to_i} Queued: #{queue_counter.to_i}" if @debug

yield content, @stats.get_statistics if block_given?

rescue => e
Expand Down
7 changes: 3 additions & 4 deletions spec/spec_helper.rb
@@ -1,17 +1,16 @@
require File.expand_path(File.dirname(__FILE__) + '/../lib/cobweb')
require 'mock_redis'

ENVIRONMENT = "test"

RSpec.configure do |config|
config.before(:each) {

ENVIRONMENT ||= "test"


redis_mock = double("redis")
redis_mock.stub(:new).and_return(@redis_mock_object)

#redis_mock.flushdb


@default_headers = {"Cache-Control" => "private, max-age=0",
"Date" => "Wed, 10 Nov 2010 09:06:17 GMT",
"Expires" => "-1",
Expand Down

0 comments on commit 87c4b0c

Please sign in to comment.