ext/curb.rb in curb-0.1.2 vs ext/curb.rb in curb-0.1.4

- old
+ new

@@ -25,11 +25,11 @@ # to the file, allowing the handler to perform mutative operations where # necessary. As usual, the transfer will be aborted if the on_body handler # returns a size that differs from the data chunk size - in this case, the # offending chunk will *not* be written to the file, the file will be closed, # and a Curl::Err::AbortedByCallbackError will be raised. - def download(url, filename = url.split(/\?/).first.split(/\//).last) - curl = Curl::Easy.new(url) { |curl| yield curl if block_given? } + def download(url, filename = url.split(/\?/).first.split(/\//).last, &blk) + curl = Curl::Easy.new(url, &blk) File.open(filename, "wb") do |output| old_on_body = curl.on_body do |data| result = old_on_body ? old_on_body.call(data) : data.length output << data if result == data.length