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
|
# File 'lib/active_reloader/server.rb', line 4
def self.start
builder = Rack::Builder.new do
map '/' do
html_response = File.read(File.expand_path("../../../app/html/iframe.html", __FILE__))
run Proc.new { [200, {"Content-Type" => "text/html"}, [html_response]] }
end
map '/check_for_changes' do
run Proc.new { |env|
req = Rack::Request.new(env)
json = ActiveReloader::FileSystem.new(req).notify
[200, {"Content-Type" => "application/json"}, json]
}
end
map '/javascripts/jquery-1.11.2.js' do
js_code = File.read(File.expand_path("../../../app/assets/javascripts/jquery-1.11.2.js", __FILE__))
run Proc.new { [200, {"Content-Type" => "text/javascript"}, [js_code]] }
end
map '/javascripts/active_reloader_main.js' do
js_code = File.read(File.expand_path("../../../app/assets/javascripts/active_reloader_main.js", __FILE__))
run Proc.new { [200, {"Content-Type" => "text/javascript"}, [js_code]] }
end
end
end
|