livereload 1.0 → 1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/livereload.rb +13 -13
  2. metadata +2 -2
data/lib/livereload.rb CHANGED
@@ -2,23 +2,23 @@ require 'em-websocket'
2
2
  require 'directory_watcher'
3
3
 
4
4
  module LiveReload
5
+ def self.start_watching ws
6
+ $dw.add_observer { |*args|
7
+ args.each { |event|
8
+ if event[:type] == :modified
9
+ name = File.basename(event[:path])
10
+ puts "Modified: #{name}"
11
+ ws.send name
12
+ end
13
+ }
14
+ }
15
+ $dw.start
16
+ end
17
+
5
18
  def self.run(host, port, dir, exts)
6
19
  EM.kqueue = true
7
20
  $dw = DirectoryWatcher.new dir, :glob => "**/*.{#{exts}}", :scanner => :em
8
21
 
9
- def start_watching ws
10
- $dw.add_observer { |*args|
11
- args.each { |event|
12
- if event[:type] == :modified
13
- name = File.basename(event[:path])
14
- puts "Modified: #{name}"
15
- ws.send name
16
- end
17
- }
18
- }
19
- $dw.start
20
- end
21
-
22
22
  puts
23
23
  puts "Port: #{port}"
24
24
  puts "Directory: #{dir}"
metadata CHANGED
@@ -4,8 +4,8 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 1
7
- - 0
8
- version: "1.0"
7
+ - 1
8
+ version: "1.1"
9
9
  platform: ruby
10
10
  authors:
11
11
  - Andrey Tarantsov