forked from sinatra/sinatra.github.com
/
sinatra-reloader.html
70 lines (46 loc) · 1.76 KB
/
sinatra-reloader.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<h1>Sinatra::Reloader</h1>
<p>Extension to reload modified files. Useful during development, since it
will automatically require files defining routes, filters, error handlers
and inline templates, with every incoming request, but only if they have
been updated.</p>
<h2>Usage</h2>
<h3>Classic Application</h3>
<p>To enable the reloader in a classic application all you need to do is
require it:</p>
<pre>require "sinatra"
require "sinatra/reloader" if development?
# Your classic application code goes here...</pre>
<h3>Modular Application</h3>
<p>To enable the reloader in a modular application all you need to do is
require it, and then, register it:</p>
<pre>require "sinatra/base"
require "sinatra/reloader"
class MyApp < Sinatra::Base
configure :development do
register Sinatra::Reloader
end
# Your modular application code goes here...
end</pre>
<h2>Changing the Reloading Policy</h2>
<p>You can refine the reloading policy with <tt>also_reload</tt> and
<tt>dont_reload</tt>, to customize which files should, and should not, be
reloaded, respectively.</p>
<h3>Classic Application</h3>
<p>Simply call the methods:</p>
<pre>require "sinatra"
require "sinatra/reloader" if development?
also_reload '/path/to/some/file'
dont_reload '/path/to/other/file'
# Your classic application code goes here...</pre>
<h3>Modular Application</h3>
<p>Call the methods inside the <tt>configure</tt> block:</p>
<pre>require "sinatra/base"
require "sinatra/reloader"
class MyApp < Sinatra::Base
configure :development do
register Sinatra::Reloader
also_reload '/path/to/some/file'
dont_reload '/path/to/other/file'
end
# Your modular application code goes here...
end</pre>