livereload 1.1 → 1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/livereload.rb +4 -1
- metadata +2 -2
data/lib/livereload.rb
CHANGED
@@ -2,6 +2,8 @@ require 'em-websocket'
|
|
2
2
|
require 'directory_watcher'
|
3
3
|
|
4
4
|
module LiveReload
|
5
|
+
VERSION = "1.2"
|
6
|
+
|
5
7
|
def self.start_watching ws
|
6
8
|
$dw.add_observer { |*args|
|
7
9
|
args.each { |event|
|
@@ -20,12 +22,13 @@ module LiveReload
|
|
20
22
|
$dw = DirectoryWatcher.new dir, :glob => "**/*.{#{exts}}", :scanner => :em
|
21
23
|
|
22
24
|
puts
|
25
|
+
puts "Version: #{VERSION}"
|
23
26
|
puts "Port: #{port}"
|
24
27
|
puts "Directory: #{dir}"
|
25
28
|
puts "Extensions: " + exts.split(",").collect {|e| ".#{e}"}.join(" ")
|
26
29
|
puts "LiveReload is waiting for browser to connect."
|
27
30
|
EventMachine::WebSocket.start(:host => host, :port => port, :debug => false) do |ws|
|
28
|
-
ws.onopen { puts "Browser connected."; start_watching ws }
|
31
|
+
ws.onopen { puts "Browser connected."; ws.send "!!ver:#{VERSION}"; start_watching ws }
|
29
32
|
ws.onmessage { |msg| puts "Browser URL: #{msg}" }
|
30
33
|
ws.onclose { puts "Browser disconnected." }
|
31
34
|
end
|