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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 453a0af138fcc205c6093736aa5e9fe5e935db57
4
- data.tar.gz: acc5eec88f2848a4ed38ea1e544aa9df1b068d92
3
+ metadata.gz: 1e1d2815739a1f3bbcd31bcaa273893e6c32c9ba
4
+ data.tar.gz: b64014a6028313c3850228fa8cef84181828f760
5
5
  SHA512:
6
- metadata.gz: cd19896a140cce30488ad9a271b800bd0c6145b5d3580ab6d9c3871a66809d3bab61b5d003c2d68b7f4f3bfaa658a04f253da5e5804bf1042d0eff05f914af2b
7
- data.tar.gz: 6301dd7c6b80ff9cbef490a4fd5400408fbaf065c1424a9b7d88af1591316a5a30b6f8150589f0234111570086faa2fdaaf3bb7bf6264aa6e2c75369b794d748
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 = options
11
- @thread = Thread.new { _start_reactor }
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
- UI.info "Browser connected."
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
 
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module LiveReloadVersion
3
- VERSION = "2.1.1"
3
+ VERSION = "2.1.2"
4
4
  end
5
5
  end
@@ -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.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-01-16 00:00:00.000000000 Z
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.0
141
+ rubygems_version: 2.2.2
142
142
  signing_key:
143
143
  specification_version: 4
144
144
  summary: Guard plugin for livereload