Project

batchr

0.0
No commit activity in last 3 years
No release in over 3 years
Perfect for batching operations over long enumerables
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

>= 0
 Project Readme

Batchr

Build Status

Installation

With Bundler

gem 'batchr'

With Only Rubygems

$ gem install batchr

Usage

class ApiSender
  def bulk_send objects = []
    # use some API that allows sending, say, up to 10 objects at once
  end
end

Batchr.batch(ApiSender.new, :bulk_send) do |batchr|
  b.batch_size = 10 # optional; default is 400
  read_really_really_long_csv_file do |row|
    batchr << row
  end
end

Why?

I found this useful when I was parsing a large CSV file and storing the results in a DB. The DB was slow to insert the rows individually, and couldn't handle an import the size of the entire file. So, I created Batchr to batch the parsed CSV into the DB.

Contributing

Want to contribute? Great!

  1. Fork it.
  2. Create a branch (git checkout -b my_feature).
  3. Commit your changes (git commit -am "Added Awesomeness").
  4. Push to the branch (git push origin my_feature).
  5. Create a Pull Request
  6. Enjoy a refreshing beverage of your choice and wait.