HotReloader Build Status Gem Version

A dead simple ruby code hot reloader wrap around zeitwerk and listen.

See README for those gems for usage.

Getting Started

Install via Rubygems

$ gem install hot_reloader

OR ...

Add to your Gemfile

gem 'hot_reloader'

Usage

Following is a example for use hot_reloader with Roda:

# config.ru

require 'roda'
require 'hot_reloader'

if ENV['RACK_ENV'] == 'production'
  HotReloader.eager_load(__dir__, 'another/root/path')
  run App
else
  HotReloader.will_listen([__dir__, 'another/root/path'])
  run ->(env) { App.call(env) }
end
# app.rb

class App < Roda
  articles = []

  route do |r|
    r.post "articles" do
    articles << r.params["content"]
    "Count: #{articles.count}"
    end
  end
end

Directory structure is like this:

├── app.rb
├── config.ru
├── Gemfile
└── Gemfile.lock

Change code in app.rb, all constant get removed from memory, and app.rb evaluated again!

Support

  • MRI 2.4.4+
  • JRuby

Dependency

zeitwerk https://github.com/fxn/zeitwerk listen https://github.com/guard/listen

Contributing

  • Bug reports
  • Source
  • Patches:
    • Fork on Github.
    • Run gem install --dev hot_reloader or bundle install.
    • 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.
    • Send a pull request :D.

license

Released under the MIT license, See LICENSE for details.