push
travis-ci
2 of 2 new or added lines in 1 file covered. (100.0%)
354 of 414 relevant lines covered (85.51%)
2.98 hits per line
1 |
require 'thread'
|
1 only 2.2.3 ✔ |
2 |
|
|
3 |
module Guard |
1 only 2.2.3 ✔ |
4 |
class LiveReload < Plugin |
1 only 2.2.3 ✔ |
5 |
class Reactor |
1 only 2.2.3 ✔ |
6 |
class Sockets |
1 only 2.2.3 ✔ |
7 |
def initialize |
1 only 2.2.3 ✔ |
8 |
@sockets = []
|
× |
9 |
@mutex = Mutex.new |
× |
10 |
end
|
|
11 |
|
|
12 |
def internal_list |
1 only 2.2.3 ✔ |
13 |
@mutex.synchronize { @sockets } |
× |
14 |
end
|
|
15 |
|
|
16 |
def size |
1 only 2.2.3 ✔ |
17 |
@mutex.synchronize { @sockets.size } |
× |
18 |
end
|
|
19 |
|
|
20 |
def broadcast(json) |
1 only 2.2.3 ✔ |
21 |
@mutex.synchronize do |
× |
22 |
@sockets.each { |ws| ws.send(json) }
|
× |
23 |
end
|
|
24 |
end
|
|
25 |
|
|
26 |
def add(socket) |
1 only 2.2.3 ✔ |
27 |
@mutex.synchronize do |
× |
28 |
yield socket if block_given? # within mutex, so 'hello' has a chance to be sent |
× |
29 |
@sockets << socket
|
× |
30 |
end
|
|
31 |
end
|
|
32 |
|
|
33 |
def delete(socket) |
1 only 2.2.3 ✔ |
34 |
@mutex.synchronize { @sockets.delete(socket) } |
× |
35 |
end
|
|
36 |
|
|
37 |
def empty? |
1 only 2.2.3 ✔ |
38 |
@mutex.synchronize { @sockets.empty? } |
× |
39 |
end
|
|
40 |
end
|
|
41 |
end
|
|
42 |
end
|
|
43 |
end
|