Rack::TimeTraveler
Rack::TimeTraveler is a Rack::Middleware, and provides "time travel" capabilities.
Installation
Add this line to your application's Gemfile:
gem 'rack-timetraveler'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rack-timetraveler
Usage
Simple usage
use Rack::TimeTraveler
If you needs customized usage
@fetcher = lambda do |env|
# You can fetch customized timestamp.
# Default is fetch from ENV['RACK_TIME_TRAVELER_TIMESTAMP']
0
end
use Rack::TimeTraveler,
timestamp_fetcher: @fetcher, # You can also fetch from cache/DB
enabled_environments: [:development] # enabled only development
Examples
$ bundle exec rackup examples/app_1.ru
$ curl localhost:9292
$ curl localhost:9292 -H 'RACK_TIME_TRAVELER_TIMESTAMP:0'
Time is 1970-01-01 09:00:00 +0900
Contributing
- Fork it ( https://github.com/luckypool/rack-timetraveler/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request