Sha256: f793757ff89fa59220d078ddc21079d40d046bc5e8ecc89018e29a6621bca2b9

Contents?: true

Size: 1.4 KB

Versions: 1

Compression:

Stored size: 1.4 KB

Contents

# DDBuffer

Provides a way to buffer Ruby enumerables/enumerators.

This is particularly useful when reading from a slow source and reading to a slow sink, because the two will be able to work concurrently. For example:

```ruby
# Read articles (an Enumerator)
articles = my_web_service.each_article

# Buffer 100 articles at a time
articles = DDBuffer.new(100).call(articles)

# Write buffered articles
articles.each_slice(50) do |slice|
  my_slow_db.insert_articles(slice)
end
```

## Usage

To install, add the `ddbuffer` gem to your Gemfile, and run `bundle`.

To buffer an enumerable `enum` with a buffer size of `size`:

```ruby
buffered_enum = DDBuffer.new(size).call(enum)
```

## Development

To run the tests:

```
bundle install
bundle exec rake
```

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/ddfreyne/ddbuffer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.

## License

The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).

## Code of Conduct

Everyone interacting in the DDBuffer project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ddfreyne/ddbuffer/blob/master/CODE_OF_CONDUCT.md).

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ddbuffer-0.1.0 README.md