Class: ActiveReloader::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/active_reloader/server.rb

Class Method Summary collapse

Class Method Details

.portObject



35
36
37
# File 'lib/active_reloader/server.rb', line 35

def self.port
	@@port
end

.port=(value) ⇒ Object



31
32
33
# File 'lib/active_reloader/server.rb', line 31

def self.port=(value)
	@@port = value
end

.startObject



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

.urlObject



39
40
41
# File 'lib/active_reloader/server.rb', line 39

def self.url
	"http://localhost:#{@@port}"
end