Class | Ramaze::Reloader
In: | lib/ramaze/reloader.rb lib/ramaze/reloader/watch_inotify.rb lib/ramaze/reloader/watch_stat.rb
Parent: | Object

High performant source reloader

This class acts as Rack middleware.

It does not depend on Ramaze itself, but you might have to adjust the Reloader::Hooks module or include your own module to override the hooks. You also might have to set the Log constant.

Currently, it uses RInotify if available and falls back to using File.stat.

Please note that this will not reload files in the background, it does so only when actively called In case of Ramaze it is performing a check/reload cycle at the start of every request, but also respects a cool down time, during which nothing will be done.

After every reload the OPTIONS hash will be checked for changed options and assigned to the instance, so you may change options during the lifetime of your application.

A number of hooks will be executed during the reload cycle, see Ramaze::ReloaderHooks for more information.

### Methods

call cycle figure_path new options_reload rotation safe_load

### Included Modules

Hooks

### Classes and Modules

Module Ramaze::Reloader::Hooks
Class Ramaze::Reloader::WatchInotify
Class Ramaze::Reloader::WatchStat

### Constants

OPTIONS

=

{ # At most check every n seconds # nil/false will never trigger the reload cycle # 0 will cycle on every call :cooldown => 2, # Compiled files cannot be reloaded during runtime :ignore => /\.so$/, # Run cycle in a Thread.exclusive, by default no threads are used. :thread => false, # If you assign a block here it will be instance_evaled instead of # calling cycle. This allows you to use for example EventMachine for # well performing asynchronous cycling. :control => nil, # lambda{ cycle }, }

Watcher | = | WatchInotify
Watcher | = | WatchStat

### Public Class methods

new(app)

Creates a new instance of the class and saves the application it has to watch.

@author Michael Fellinger @since 09-08-2008 @param [Ramaze::App] app The application to monitor.

### Public Instance methods

call(env)

Allows this class to be called as a Rack middleware.

@author Michael Fellinger @since 09-08-2008 @param [Hash] env A hash containing all environment details.

cycle()

Loops through all the files and reloads all changes files.

@author Michael Fellinger @since 09-08-2008

figure_path(file, paths)

Tries to find a given file in an array of file paths.

@author Michael Fellinger @since 09-08-2008 @param [String] file The name of the file to look for. @param [Array] paths An array of paths to search. @return [String]

options_reload()

Returns all the options for this class.

@author Michael Fellinger @since 09-08-2008 @return [Array]

rotation() {|path| ...}
safe_load(file)

A safe Kernel::load, issuing the hooks depending on the results

@author Michael Fellinger @since 09-08-2008 @param [String] file Path to the file to safely load.

[Validate]