clearwater-hot_loader 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/clearwater-hot_loader.gemspec +1 -1
- data/lib/clearwater/hot_loader.rb +6 -6
- data/lib/clearwater/hot_loader/configuration.rb +1 -3
- data/lib/clearwater/hot_loader/file_listener.rb +1 -1
- data/lib/clearwater/hot_loader/server.rb +4 -2
- data/lib/clearwater/hot_loader/version.rb +1 -1
- data/opal/clearwater/hot_loader.rb +57 -2
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 333c55823d1f8bf36570a9c7bc530669c4c0ebbe
|
4
|
+
data.tar.gz: 980439c4b1b380b0d3842967fed45521e4ba1d5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c16c3a63ba346cbb7c55e3680966c3d4a166c934de41a7db7635062f8a1fb2b85f83a4a796586dd07bd5651d3beb33ba7fdf0cd619c5edda12625e6ea982eca
|
7
|
+
data.tar.gz: 7472c8d1a662ced9691399abdd481a5a007a1bba8e94bfa142ed9f7107bc3b9628d4d48e457547ef9795ffd8b483013f90f5557a90b4badf7fef33fc81bd50d1
|
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
-
spec.add_runtime_dependency 'clearwater'
|
20
|
+
spec.add_runtime_dependency 'clearwater', '~> 1.0.0.rc1'
|
21
21
|
spec.add_runtime_dependency 'listen'
|
22
22
|
spec.add_runtime_dependency 'faye-websocket'
|
23
23
|
|
@@ -31,14 +31,14 @@ module Clearwater
|
|
31
31
|
begin
|
32
32
|
puts "[Clearwater::HotLoader] Compiling #{filename}..."
|
33
33
|
code = server.compile_file(filename)
|
34
|
-
|
35
|
-
|
36
|
-
sockets.each do |ws|
|
37
|
-
ws.send code
|
38
|
-
end
|
39
|
-
rescue => e
|
34
|
+
rescue SyntaxError => e
|
40
35
|
puts "ONOES! #{e.class} - #{e.message}"
|
41
36
|
end
|
37
|
+
|
38
|
+
puts "[Clearwater::HotLoader] Hot-loading #{filename}..."
|
39
|
+
sockets.each do |ws|
|
40
|
+
ws.send code
|
41
|
+
end
|
42
42
|
end
|
43
43
|
}
|
44
44
|
@listeners.each(&:start)
|
@@ -16,12 +16,14 @@ module Clearwater
|
|
16
16
|
if WebSocket.websocket? env
|
17
17
|
ws = WebSocket.new(env)
|
18
18
|
|
19
|
+
ws.on :open do
|
20
|
+
hot_loader.add_socket ws
|
21
|
+
end
|
22
|
+
|
19
23
|
ws.on :close do
|
20
24
|
hot_loader.remove_socket ws
|
21
25
|
end
|
22
26
|
|
23
|
-
hot_loader.add_socket ws
|
24
|
-
|
25
27
|
ws.rack_response
|
26
28
|
else
|
27
29
|
[200, { 'Content-Type' => 'text/plain' }, ['Websockets only, please.']]
|
@@ -13,23 +13,78 @@ module Clearwater
|
|
13
13
|
def initialize port, path='/clearwater_hot_loader'
|
14
14
|
@port = port
|
15
15
|
@path = path
|
16
|
+
Bowser.window.animation_frame do
|
17
|
+
div = Bowser.document.create_element('div')
|
18
|
+
Bowser.document.body.append div
|
19
|
+
@app = Clearwater::Application.new(
|
20
|
+
component: ConnectionIndicator.new(self),
|
21
|
+
element: div,
|
22
|
+
)
|
23
|
+
@app.call
|
24
|
+
end
|
16
25
|
end
|
17
26
|
|
18
27
|
def connect
|
19
28
|
@socket = Bowser::WebSocket.new("ws://localhost:#{port}#{path}")
|
20
29
|
|
30
|
+
@socket.on :open do
|
31
|
+
@app.render
|
32
|
+
end
|
33
|
+
|
21
34
|
@socket.on :message do |msg|
|
22
|
-
|
35
|
+
begin
|
36
|
+
%x{ eval(msg.native.data) }
|
37
|
+
rescue => e
|
38
|
+
error_message = "[Clearwater::HotLoader] Error #{e.class}: #{e.message}"
|
39
|
+
`console.error(error_message)`
|
40
|
+
end
|
23
41
|
Clearwater::Application.render
|
24
42
|
end
|
25
43
|
|
26
44
|
@socket.on :close do
|
27
|
-
|
45
|
+
@app.render
|
46
|
+
Bowser.window.delay 0.5 do
|
28
47
|
connect
|
29
48
|
end
|
30
49
|
end
|
31
50
|
|
32
51
|
self
|
33
52
|
end
|
53
|
+
|
54
|
+
def connected?
|
55
|
+
@socket.connected?
|
56
|
+
end
|
57
|
+
|
58
|
+
class ConnectionIndicator
|
59
|
+
include Clearwater::Component
|
60
|
+
|
61
|
+
def initialize loader
|
62
|
+
@loader = loader
|
63
|
+
end
|
64
|
+
|
65
|
+
def render
|
66
|
+
div({ style: style }, [
|
67
|
+
connection_status,
|
68
|
+
])
|
69
|
+
end
|
70
|
+
|
71
|
+
def connection_status
|
72
|
+
span([
|
73
|
+
"Hot Loader: ",
|
74
|
+
@loader.connected? ? 'Connected' : 'Disconnected',
|
75
|
+
])
|
76
|
+
end
|
77
|
+
|
78
|
+
def style
|
79
|
+
connected = @loader.connected?
|
80
|
+
{
|
81
|
+
position: :fixed,
|
82
|
+
bottom: 0,
|
83
|
+
right: 0,
|
84
|
+
background_color: connected ? :green : :red,
|
85
|
+
color: :white,
|
86
|
+
}
|
87
|
+
end
|
88
|
+
end
|
34
89
|
end
|
35
90
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clearwater-hot_loader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamie Gaskins
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clearwater
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.0.0.rc1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 1.0.0.rc1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: listen
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
136
|
version: '0'
|
137
137
|
requirements: []
|
138
138
|
rubyforge_project:
|
139
|
-
rubygems_version: 2.
|
139
|
+
rubygems_version: 2.6.11
|
140
140
|
signing_key:
|
141
141
|
specification_version: 4
|
142
142
|
summary: Reload your Clearwater app without refreshing the browser
|