sinatra_sockets 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -0
- data/lib/server_skeleton/Gemfile +4 -1
- data/lib/server_skeleton/Gemfile.lock +100 -0
- data/lib/server_skeleton/client.rb +22 -19
- data/lib/server_skeleton/deps.js +3 -0
- data/lib/server_skeleton/lib/routes/index.rb +1 -0
- data/lib/server_skeleton/package.json +17 -0
- data/lib/server_skeleton/public/bundle.js +10383 -0
- data/lib/server_skeleton/server.rb +11 -3
- data/lib/server_skeleton/views/index.slim +14 -11
- data/lib/server_skeleton/views/partials/url_input.slim +4 -0
- data/lib/server_skeleton/views/partials/videos.slim +2 -0
- data/lib/server_skeleton/views/script/add_video.slim +51 -0
- data/lib/server_skeleton/views/script/url_input.slim +11 -0
- data/lib/server_skeleton/views/script/websocket.slim +13 -0
- data/lib/server_skeleton/views/style/main.slim +15 -0
- data/lib/version.rb +1 -1
- metadata +12 -2
- data/lib/server_skeleton/public/jquery.js +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d633c91055c9c1617045a385a61c450dcd65420b
|
4
|
+
data.tar.gz: c5e8a62363370912095bfab317173cf21c76e2c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5acd05d9fb2c0371bb4d5b69e753a259e26f0d648e22c9035b9ee0ac0e9fb871d88c73929e3ab5ca37eaf17688ecdccf6bd7363f50c9b10264e39488e65db3e8
|
7
|
+
data.tar.gz: 6cc81324c4f920f39dcbd2a556eef96f271bb6806e94219132dfba849a633cd0ff7b0fc8fd1113a065545cffb8ff33c19aff15da7b341a068123fa9678e4a511
|
data/README.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
This is a gem which is available through rubygems:
|
2
|
+
|
3
|
+
> gem install sinatra_sockets
|
4
|
+
|
5
|
+
After doing this the `sinatra_sockets generate PATH` shell command can be used.
|
6
|
+
|
7
|
+
The generated directory will be called `server_skeleton`. The PATH can be set to `.` for `./server_skeleton` to be created.
|
8
|
+
|
9
|
+
The generated code is commented and should be read through and customized.
|
10
|
+
|
11
|
+
In its basic form it's a websocket server using faye-websockets and a very small sinatra front-end with Slim.
|
12
|
+
|
13
|
+
Once generated, `cd server_skeleton` and run `thin start`. Then visit `localhost:3000` and open the dev console.
|
14
|
+
|
15
|
+
The client will have pinged a message to the server, and the server responds by saying `got <message>`
|
data/lib/server_skeleton/Gemfile
CHANGED
@@ -0,0 +1,100 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (5.0.1)
|
5
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
6
|
+
i18n (~> 0.7)
|
7
|
+
minitest (~> 5.1)
|
8
|
+
tzinfo (~> 1.1)
|
9
|
+
awesome_print (1.7.0)
|
10
|
+
byebug (9.0.6)
|
11
|
+
coderay (1.1.1)
|
12
|
+
coffee-script (2.4.1)
|
13
|
+
coffee-script-source
|
14
|
+
execjs
|
15
|
+
coffee-script-source (1.12.2)
|
16
|
+
colored (1.2)
|
17
|
+
concurrent-ruby (1.0.4)
|
18
|
+
corefines (1.9.0)
|
19
|
+
daemons (1.2.4)
|
20
|
+
engtagger (0.2.1)
|
21
|
+
eventmachine (1.2.2)
|
22
|
+
execjs (2.7.0)
|
23
|
+
faye-websocket (0.10.6)
|
24
|
+
eventmachine (>= 0.12.0)
|
25
|
+
websocket-driver (>= 0.5.1)
|
26
|
+
ffi (1.9.17)
|
27
|
+
gemmyrb (0.1.6)
|
28
|
+
activesupport
|
29
|
+
awesome_print
|
30
|
+
byebug
|
31
|
+
colored
|
32
|
+
corefines
|
33
|
+
engtagger
|
34
|
+
minitest
|
35
|
+
odyssey
|
36
|
+
pry
|
37
|
+
sentence_interpreter
|
38
|
+
thor
|
39
|
+
i18n (0.8.0)
|
40
|
+
listen (3.1.5)
|
41
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
42
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
43
|
+
ruby_dep (~> 1.2)
|
44
|
+
method_source (0.8.2)
|
45
|
+
minitest (5.10.1)
|
46
|
+
odyssey (0.2.0)
|
47
|
+
require_all
|
48
|
+
pry (0.10.4)
|
49
|
+
coderay (~> 1.1.0)
|
50
|
+
method_source (~> 0.8.1)
|
51
|
+
slop (~> 3.4)
|
52
|
+
rack (1.6.5)
|
53
|
+
rack-protection (1.5.3)
|
54
|
+
rack
|
55
|
+
rb-fsevent (0.9.8)
|
56
|
+
rb-inotify (0.9.8)
|
57
|
+
ffi (>= 0.5.0)
|
58
|
+
require_all (1.4.0)
|
59
|
+
rerun (0.11.0)
|
60
|
+
listen (~> 3.0)
|
61
|
+
ruby_dep (1.5.0)
|
62
|
+
sass (3.4.23)
|
63
|
+
sentence_interpreter (0.0.7)
|
64
|
+
sinatra (1.4.8)
|
65
|
+
rack (~> 1.5)
|
66
|
+
rack-protection (~> 1.4)
|
67
|
+
tilt (>= 1.3, < 3)
|
68
|
+
slim (3.0.7)
|
69
|
+
temple (~> 0.7.6)
|
70
|
+
tilt (>= 1.3.3, < 2.1)
|
71
|
+
slop (3.6.0)
|
72
|
+
temple (0.7.7)
|
73
|
+
thin (1.7.0)
|
74
|
+
daemons (~> 1.0, >= 1.0.9)
|
75
|
+
eventmachine (~> 1.0, >= 1.0.4)
|
76
|
+
rack (>= 1, < 3)
|
77
|
+
thor (0.19.4)
|
78
|
+
thread_safe (0.3.5)
|
79
|
+
tilt (2.0.6)
|
80
|
+
tzinfo (1.2.2)
|
81
|
+
thread_safe (~> 0.1)
|
82
|
+
websocket-driver (0.6.5)
|
83
|
+
websocket-extensions (>= 0.1.0)
|
84
|
+
websocket-extensions (0.1.2)
|
85
|
+
|
86
|
+
PLATFORMS
|
87
|
+
ruby
|
88
|
+
|
89
|
+
DEPENDENCIES
|
90
|
+
coffee-script
|
91
|
+
faye-websocket
|
92
|
+
gemmyrb
|
93
|
+
rerun
|
94
|
+
sass
|
95
|
+
sinatra
|
96
|
+
slim
|
97
|
+
thin
|
98
|
+
|
99
|
+
BUNDLED WITH
|
100
|
+
1.14.3
|
@@ -3,28 +3,31 @@ require 'eventmachine'
|
|
3
3
|
require 'byebug'
|
4
4
|
require 'gemmy'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
EM.
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
6
|
+
if $start_client
|
7
|
+
|
8
|
+
Settings = {awaiting_input: false }
|
9
|
+
EM.run do
|
10
|
+
|
11
|
+
EM.tick_loop do
|
12
|
+
if !Settings[:awaiting_input]
|
13
|
+
Thread.new do
|
14
|
+
Settings[:awaiting_input] = true
|
15
|
+
inp = gets.chomp
|
16
|
+
Settings[:awaiting_input] = false
|
17
|
+
Ws.send inp
|
18
|
+
end
|
19
|
+
sleep 0.2
|
16
20
|
end
|
17
|
-
|
18
|
-
end
|
19
|
-
end.on_stop { EM.stop }
|
21
|
+
end.on_stop { EM.stop }
|
20
22
|
|
21
|
-
|
23
|
+
ServerWebsocketUrl = ENV["SERVER_WS_URL"] || 'ws://localhost:3000/'
|
22
24
|
|
23
|
-
|
25
|
+
Ws = Faye::WebSocket::Client.new ServerWebsocketUrl
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
-
|
27
|
+
Ws.on :message do |event|
|
28
|
+
puts event.data
|
29
|
+
end
|
28
30
|
|
29
|
-
end
|
31
|
+
end
|
30
32
|
|
33
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
{
|
2
|
+
"name": "mixer",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"description": "A simple sinatra websocket server with faye/eventmaching",
|
5
|
+
"main": "index.js",
|
6
|
+
"scripts": {
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
8
|
+
},
|
9
|
+
"author": "",
|
10
|
+
"license": "ISC",
|
11
|
+
"dependencies": {
|
12
|
+
"bower": "^1.8.0",
|
13
|
+
"browserify": "^14.1.0",
|
14
|
+
"jquery": "^3.1.1",
|
15
|
+
"valid-url": "^1.0.9"
|
16
|
+
}
|
17
|
+
}
|