Skip to content

Commit

Permalink
Remove 1.9 requirement for Batch, fixes mperham#42
Browse files Browse the repository at this point in the history
  • Loading branch information
mperham committed Nov 8, 2011
1 parent 79b7cbb commit bf8208e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion examples/batch.rb
Expand Up @@ -7,11 +7,14 @@ class UrlProcessor
URLS = %w(http://www.bing.com http://www.google.com http://www.yahoo.com)

def parallel
batch = GirlFriday::Batch.new(URLS, :size => 3) do |url|
batch = GirlFriday::Batch.new(nil, :size => 3) do |url|
html = open(url)
doc = Nokogiri::HTML(html.read)
doc.css('span').count
end
URLS.each do |url|
batch << url
end
p URLS.zip(batch.results)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/girl_friday/batch.rb
Expand Up @@ -12,7 +12,7 @@ module GirlFriday
#
# TODO Errors are not handled well at all.
class Batch
def initialize(enumerable=nil, options, &block)
def initialize(enumerable=nil, options={}, &block)
@queue = GirlFriday::Queue.new(:batch, options, &block)
@complete = 0
@size = 0
Expand Down
2 changes: 1 addition & 1 deletion test/test_batch.rb
Expand Up @@ -41,7 +41,7 @@ def test_batch_timeout
end

def test_empty_batch
batch = GirlFriday::Batch.new(:size => 4) do |msg|
batch = GirlFriday::Batch.new(nil, :size => 4) do |msg|
sleep msg
'x'
end
Expand Down
2 changes: 1 addition & 1 deletion test/test_girl_friday_queue.rb
@@ -1,6 +1,6 @@
require 'helper'

class TestGirlFriday < MiniTest::Unit::TestCase
class TestGirlFridayQueue < MiniTest::Unit::TestCase

class TestErrorHandler
include MiniTest::Assertions
Expand Down

0 comments on commit bf8208e

Please sign in to comment.