Hamster Powered

Not everything deserves a background task, especially when you want to quickly prototype something. Use HTTP Streaming to process those long running processes in real time instead! This approach is well suited for situations where you have a large number of atomic operations that would take > 10 seconds to complete.

Usage

Let's say you need to save a large number of newly instantiated objects to the database (after reading from a CSV file, for instance). Well, here's a simpler example:

objects_to_act_on = (1..10000).to_a
action = :to_s
redirect = root_url

render as_processing_screen(objects_to_act_on, action, redirect)

The actions will be processed in the view layer and the results streamed to the user, who sees a simple message and progress bar. Once the actions have been completed, the user will be directed to follow a link to the location you specify in the redirect argument.

Simple as pie made by hamsters.

Installation

Add this line to your application's Gemfile:

gem 'hamster_powered'

And then execute:

$ bundle

Or install it yourself as:

$ gem install hamster_powered

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request