jmettraux/rufus-scheduler — pull request #121 by joelnordell (2014-04-04 16:55:53+00:00)
Title: timelapse feature

This adds a new feature to the scheduler: `:timelapse`. When constructing the scheduler, you can give it a `:timelapse => range` option to put the scheduler into "timelapse mode." Then, use the scheduler as normal. In timelapse mode, the scheduler does nothing until `join` is called, at which point the entire given time range runs sequentially, without delay. This is useful for adding a feature to scheduled applications for running them through some range of time on demand.

Because the only difference between timelapse mode and normal mode is in the initialization options given to the scheduler, applications need very few changes to take advantage of it.

Example:

```ruby
# Create a scheduler that will timelapse from one minute ago to now.
scheduler = Rufus::Scheduler.new(:timelapse => (Time.now-60)..Time.now)

# Create jobs as usual
scheduler.every '5s' do
puts "Doing something every 5 seconds"
end

scheduler.at (Time.now-30) do
puts "This is scheduled in the past"
end

# This is when the timelapse magic happens.
scheduler.join
```

**Note:** timelapsing has been tested with basic `in`, `at`, `every`, `interval`, and `cron` jobs. For `interval` jobs, it behaves exactly like `every` jobs: they are scheduled as if each job takes no time to run. Additionally, it has _not_ been tested with more advanced job options, such as `:start_at`, `:timeout`, etc., and very likely will not work in those cases.