push
travis-ci
421 of 449 relevant lines covered (93.76%)
2.73 hits per line
1 |
require 'eventmachine'
|
1 only 2.2.3 ✔ |
2 |
require 'em-websocket'
|
1 only 2.2.3 ✔ |
3 |
require 'guard/livereload/websocket/dispatcher'
|
1 only 2.2.3 ✔ |
4 |
|
|
5 |
module Guard |
1 only 2.2.3 ✔ |
6 |
class LiveReload |
1 only 2.2.3 ✔ |
7 |
class WebSocket < EventMachine::WebSocket::Connection |
1 only 2.2.3 ✔ |
8 |
def initialize(options) |
1 only 2.2.3 ✔ |
9 |
@dispatcher = Dispatcher.new(options) |
11 only 2.2.3 ✔ |
10 |
super
|
11 only 2.2.3 ✔ |
11 |
end
|
|
12 |
|
|
13 |
def dispatch(data) |
1 only 2.2.3 ✔ |
14 |
responses = @dispatcher.dispatch(data)
|
10 only 2.2.3 ✔ |
15 |
|
|
16 |
responses.each do |type, payload|
|
10 only 2.2.3 ✔ |
17 |
case type
|
15 only 2.2.3 ✔ |
18 |
when :default |
|
19 |
super
|
3 only 2.2.3 ✔ |
20 |
when :data |
|
21 |
send_data(payload) |
7 only 2.2.3 ✔ |
22 |
when :close_write |
|
23 |
close_connection_after_writing |
2 only 2.2.3 ✔ |
24 |
when :file |
|
25 |
path = payload |
3 only 2.2.3 ✔ |
26 |
stream_file_data(path).callback { close_connection_after_writing } |
6 only 2.2.3 ✔ |
27 |
else
|
|
28 |
fail "Unknown response type: #{type.inspect}"
|
× |
29 |
end
|
|
30 |
end
|
|
31 |
end
|
|
32 |
end
|
|
33 |
end
|
|
34 |
end
|