guard-livereload 1.0.3 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,5 @@
1
1
  require 'em-websocket'
2
2
  require 'multi_json'
3
- require 'thread'
4
3
 
5
4
  module Guard
6
5
  class LiveReload
@@ -9,7 +8,6 @@ module Guard
9
8
  attr_reader :thread, :web_sockets
10
9
 
11
10
  def initialize(options)
12
- @mutex = Mutex.new
13
11
  @web_sockets = []
14
12
  @options = options
15
13
  @thread = start_threaded_reactor(options)
@@ -20,17 +18,15 @@ module Guard
20
18
  end
21
19
 
22
20
  def reload_browser(paths = [])
23
- @mutex.synchronize do
24
- UI.info "Reloading browser: #{paths.join(' ')}"
25
- paths.each do |path|
26
- data = MultiJson.encode(['refresh', {
27
- :path => "#{Dir.pwd}/#{path}",
28
- :apply_js_live => @options[:apply_js_live],
29
- :apply_css_live => @options[:apply_css_live]
30
- }])
31
- UI.debug data
32
- @web_sockets.each { |ws| ws.send(data) }
33
- end
21
+ UI.info "Reloading browser: #{paths.join(' ')}"
22
+ paths.each do |path|
23
+ data = MultiJson.encode(['refresh', {
24
+ :path => "#{Dir.pwd}/#{path}",
25
+ :apply_js_live => @options[:apply_js_live],
26
+ :apply_css_live => @options[:apply_css_live]
27
+ }])
28
+ UI.debug data
29
+ @web_sockets.each { |ws| ws.send(data) }
34
30
  end
35
31
  end
36
32
 
@@ -42,15 +38,13 @@ module Guard
42
38
  UI.info "LiveReload #{options[:api_version]} is waiting for a browser to connect."
43
39
  EventMachine.start_server(options[:host], options[:port], EventMachine::WebSocket::Connection, {}) do |ws|
44
40
  ws.onopen do
45
- @mutex.synchronize do
46
- begin
47
- UI.info "Browser connected."
48
- ws.send "!!ver:#{options[:api_version]}"
49
- @web_sockets << ws
50
- rescue
51
- UI.errror $!
52
- UI.errror $!.backtrace
53
- end
41
+ begin
42
+ UI.info "Browser connected."
43
+ ws.send "!!ver:#{options[:api_version]}"
44
+ @web_sockets << ws
45
+ rescue
46
+ UI.errror $!
47
+ UI.errror $!.backtrace
54
48
  end
55
49
  end
56
50
 
@@ -59,10 +53,8 @@ module Guard
59
53
  end
60
54
 
61
55
  ws.onclose do
62
- @mutex.synchronize do
63
- @web_sockets.delete ws
64
- UI.info "Browser disconnected."
65
- end
56
+ @web_sockets.delete ws
57
+ UI.info "Browser disconnected."
66
58
  end
67
59
  end
68
60
  end
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module LiveReloadVersion
3
- VERSION = "1.0.3"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-livereload
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-25 00:00:00.000000000 Z
12
+ date: 2012-10-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: guard
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: 1.1.0
21
+ version: 1.5.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
- version: 1.1.0
29
+ version: 1.5.0
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: em-websocket
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -66,7 +66,7 @@ dependencies:
66
66
  requirements:
67
67
  - - ~>
68
68
  - !ruby/object:Gem::Version
69
- version: '1.0'
69
+ version: '1.2'
70
70
  type: :development
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
@@ -74,7 +74,7 @@ dependencies:
74
74
  requirements:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
- version: '1.0'
77
+ version: '1.2'
78
78
  - !ruby/object:Gem::Dependency
79
79
  name: rspec
80
80
  requirement: !ruby/object:Gem::Requirement
@@ -82,7 +82,7 @@ dependencies:
82
82
  requirements:
83
83
  - - ~>
84
84
  - !ruby/object:Gem::Version
85
- version: '2.10'
85
+ version: '2.11'
86
86
  type: :development
87
87
  prerelease: false
88
88
  version_requirements: !ruby/object:Gem::Requirement
@@ -90,7 +90,7 @@ dependencies:
90
90
  requirements:
91
91
  - - ~>
92
92
  - !ruby/object:Gem::Version
93
- version: '2.10'
93
+ version: '2.11'
94
94
  - !ruby/object:Gem::Dependency
95
95
  name: guard-rspec
96
96
  requirement: !ruby/object:Gem::Requirement