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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 85832d4bf9cf5f368b6e6a837e75acfe647c6829
4
- data.tar.gz: 289bf9344a3e70b8fcaf585570be04df8c8235c2
3
+ metadata.gz: d633c91055c9c1617045a385a61c450dcd65420b
4
+ data.tar.gz: c5e8a62363370912095bfab317173cf21c76e2c3
5
5
  SHA512:
6
- metadata.gz: b44d3168ac29c9c4deed9f404b736abc5cadb4a5086a6eb9ff43071161276a765cef761364c954405da49584b05d62694551f2297ab168f154899868c00a76e1
7
- data.tar.gz: b35d412caf5189d3dde2afb682e8947b8ec3cca4c23510d6c3be90e7213579d5a7d689fd5cc9a6ed0006fa6854c7a076b62250107b1025e2fa69e06d7953e5f9
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>`
@@ -4,4 +4,7 @@ gem 'gemmyrb'
4
4
  gem 'sinatra'
5
5
  gem 'faye-websocket'
6
6
  gem 'slim'
7
-
7
+ gem "thin"
8
+ gem 'rerun'
9
+ gem "sass"
10
+ gem 'coffee-script'
@@ -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
- Settings = {awaiting_input: false }
7
- EM.run do
8
-
9
- EM.tick_loop do
10
- if !Settings[:awaiting_input]
11
- Thread.new do
12
- Settings[:awaiting_input] = true
13
- inp = gets.chomp
14
- Settings[:awaiting_input] = false
15
- Ws.send inp
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
- sleep 0.2
18
- end
19
- end.on_stop { EM.stop }
21
+ end.on_stop { EM.stop }
20
22
 
21
- ServerWebsocketUrl = ENV["SERVER_WS_URL"] || 'ws://localhost:3000/'
23
+ ServerWebsocketUrl = ENV["SERVER_WS_URL"] || 'ws://localhost:3000/'
22
24
 
23
- Ws = Faye::WebSocket::Client.new ServerWebsocketUrl
25
+ Ws = Faye::WebSocket::Client.new ServerWebsocketUrl
24
26
 
25
- Ws.on :message do |event|
26
- puts event.data
27
- end
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,3 @@
1
+ window.valid_url = require("valid-url");
2
+ window.jquery = require("jquery");
3
+ window.$ = jquery
@@ -1,5 +1,6 @@
1
1
  class Routes::Index
2
2
 
3
+ Gemmy.patches.each { |patch| using patch }
3
4
  # This method is called from the Sinatra route handler
4
5
  def self.run(request)
5
6
  is_websocket = websocket_request? request
@@ -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
+ }