guard-livereload 2.1.1 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/guard/livereload/reactor.rb +8 -6
- data/lib/guard/livereload/version.rb +1 -1
- data/spec/lib/guard/livereload/reactor_spec.rb +17 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e1d2815739a1f3bbcd31bcaa273893e6c32c9ba
|
4
|
+
data.tar.gz: b64014a6028313c3850228fa8cef84181828f760
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1eb3bef68fe9ba23dce70e05d8899e3a127407cd1836719f947fb257cba9bc819a7895331d926200bb1a471edce6ceb12b2268dee2e541a6ced52fbdc2b54492
|
7
|
+
data.tar.gz: 198e67d389876a59fe9c41514cdbfdfae2938c03cf760dc4739345e07016c23ef08b5d927ae8e2e84af8002492f9b0cc9f9f99ffbe03327d0e15d3fcc8ec784f
|
@@ -3,12 +3,13 @@ require 'multi_json'
|
|
3
3
|
module Guard
|
4
4
|
class LiveReload
|
5
5
|
class Reactor
|
6
|
-
attr_reader :web_sockets, :thread, :options
|
6
|
+
attr_reader :web_sockets, :thread, :options, :connections_count
|
7
7
|
|
8
8
|
def initialize(options)
|
9
|
-
@web_sockets
|
10
|
-
@options
|
11
|
-
@thread
|
9
|
+
@web_sockets = []
|
10
|
+
@options = options
|
11
|
+
@thread = Thread.new { _start_reactor }
|
12
|
+
@connections_count = 0
|
12
13
|
end
|
13
14
|
|
14
15
|
def stop
|
@@ -51,7 +52,9 @@ module Guard
|
|
51
52
|
end
|
52
53
|
|
53
54
|
def _connect(ws)
|
54
|
-
|
55
|
+
@connections_count += 1
|
56
|
+
UI.info "Browser connected." if connections_count == 1
|
57
|
+
|
55
58
|
ws.send MultiJson.encode(
|
56
59
|
command: 'hello',
|
57
60
|
protocols: ['http://livereload.com/protocols/official-7'],
|
@@ -64,7 +67,6 @@ module Guard
|
|
64
67
|
end
|
65
68
|
|
66
69
|
def _disconnect(ws)
|
67
|
-
UI.info "Browser disconnected."
|
68
70
|
@web_sockets.delete(ws)
|
69
71
|
end
|
70
72
|
|
@@ -31,6 +31,23 @@ describe Guard::LiveReload::Reactor do
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
+
describe "#_connect(ws)" do
|
35
|
+
let(:ws) { double.as_null_object }
|
36
|
+
let(:reactor) { new_live_reactor }
|
37
|
+
|
38
|
+
it "displays a message once" do
|
39
|
+
expect(Guard::UI).to receive(:info).with("Browser connected.").once
|
40
|
+
reactor.send(:_connect, ws)
|
41
|
+
reactor.send(:_connect, ws)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "increments the connection count" do
|
45
|
+
expect {
|
46
|
+
reactor.send(:_connect, ws)
|
47
|
+
}.to change { reactor.connections_count }.from(0).to 1
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
34
51
|
end
|
35
52
|
|
36
53
|
def new_live_reactor(options = {})
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-livereload
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thibaud Guillaume-Gentil
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: guard
|
@@ -138,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
138
|
version: '0'
|
139
139
|
requirements: []
|
140
140
|
rubyforge_project:
|
141
|
-
rubygems_version: 2.2.
|
141
|
+
rubygems_version: 2.2.2
|
142
142
|
signing_key:
|
143
143
|
specification_version: 4
|
144
144
|
summary: Guard plugin for livereload
|