litecable 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -1
  3. data/LICENSE.txt +1 -1
  4. data/README.md +24 -22
  5. data/lib/lite_cable.rb +22 -2
  6. data/lib/lite_cable/anycable.rb +14 -12
  7. data/lib/lite_cable/broadcast_adapters.rb +35 -0
  8. data/lib/lite_cable/broadcast_adapters/any_cable.rb +11 -0
  9. data/lib/lite_cable/broadcast_adapters/base.rb +17 -0
  10. data/lib/lite_cable/broadcast_adapters/memory.rb +11 -0
  11. data/lib/lite_cable/config.rb +5 -4
  12. data/lib/lite_cable/connection/subscriptions.rb +2 -2
  13. data/lib/lite_cable/server.rb +0 -6
  14. data/lib/lite_cable/server/client_socket/base.rb +9 -15
  15. data/lib/lite_cable/version.rb +1 -1
  16. metadata +18 -76
  17. data/.gem_release.yml +0 -3
  18. data/.gitignore +0 -40
  19. data/.rubocop.yml +0 -53
  20. data/.travis.yml +0 -16
  21. data/Gemfile +0 -4
  22. data/Rakefile +0 -10
  23. data/bin/console +0 -14
  24. data/bin/setup +0 -8
  25. data/examples/sinatra/Gemfile +0 -19
  26. data/examples/sinatra/Procfile +0 -3
  27. data/examples/sinatra/README.md +0 -35
  28. data/examples/sinatra/app.rb +0 -53
  29. data/examples/sinatra/assets/app.css +0 -169
  30. data/examples/sinatra/assets/cable.js +0 -584
  31. data/examples/sinatra/assets/reset.css +0 -223
  32. data/examples/sinatra/chat.rb +0 -40
  33. data/examples/sinatra/config.ru +0 -21
  34. data/examples/sinatra/config/environment.rb +0 -18
  35. data/examples/sinatra/views/index.slim +0 -8
  36. data/examples/sinatra/views/layout.slim +0 -15
  37. data/examples/sinatra/views/login.slim +0 -8
  38. data/examples/sinatra/views/resetcss.slim +0 -224
  39. data/examples/sinatra/views/room.slim +0 -68
  40. data/litecable.gemspec +0 -39
@@ -1,223 +0,0 @@
1
- /* Reset
2
- ----------------------------------------------------------------------------- */
3
-
4
- /* stylelint-disable */
5
-
6
- html, body,
7
- h1, h2, h3, h4, h5, h6, p, blockquote, pre,
8
- address, code, img,
9
- dl, dt, dd, ol, ul, li,
10
- fieldset, form, label,
11
- table, th, td,
12
- article, aside, nav, section, figure, figcaption, footer, header,
13
- audio, video {
14
- margin: 0;
15
- padding: 0;
16
- }
17
- blockquote, img, fieldset, form {
18
- border: 0;
19
- }
20
- a, strong, em, b, i, small, sub, sup, img, label, th, td, audio, video {
21
- vertical-align: baseline;
22
- }
23
- applet, object, iframe,
24
- abbr, acronym, big, cite,
25
- del, dfn, ins, kbd, q, s, samp,
26
- strike, tt, var, u, center, legend,
27
- caption, tbody, tfoot, thead, tr,
28
- canvas, details, embed,
29
- menu, output, ruby, summary,
30
- time, mark {
31
- margin: 0;
32
- padding: 0;
33
- border: 0;
34
- vertical-align: baseline;
35
- font: inherit;
36
- font-size: 100%;
37
- }
38
- ul, ol {
39
- list-style: none;
40
- }
41
-
42
- /* Border-box FTW
43
- https://css-tricks.com/inheriting-box-sizing-probably-slightly-better-best-practice/ */
44
- *,
45
- *:before,
46
- *:after {
47
- box-sizing: inherit;
48
- }
49
- html {
50
- overflow-y: scroll;
51
- box-sizing: border-box;
52
- text-size-adjust: 100%;
53
- }
54
- a {
55
- background-color: transparent; /* Remove the gray background color from active links in IE 10. */
56
- -webkit-text-decoration-skip: none;
57
-
58
- &:hover,
59
- &:active {
60
- outline: 0;
61
- }
62
- }
63
- img {
64
- vertical-align: middle;
65
- }
66
- strong, b {
67
- font-weight: bold;
68
- }
69
- em, i {
70
- font-style: italic;
71
- }
72
- h1, h2, h3, h4, h5, h6 {
73
- font-weight: bold;
74
- }
75
- table {
76
- border-spacing: 0;
77
- border-collapse: collapse;
78
- }
79
- th {
80
- font-weight: bold;
81
- }
82
- td {
83
- vertical-align: top;
84
- }
85
- input,
86
- select,
87
- textarea,
88
- button {
89
- margin: 0;
90
- vertical-align: middle;
91
- font-size: 100%;
92
- font-family: inherit;
93
- }
94
-
95
- /**
96
- * 1. Add the correct box sizing in IE 10-.
97
- * 2. Remove the padding in IE 10-.
98
- */
99
- [type="checkbox"],
100
- [type="radio"] {
101
- box-sizing: border-box; /* 1 */
102
- padding: 0; /* 2 */
103
- }
104
-
105
- /**
106
- * Show the overflow in IE.
107
- * 1. Show the overflow in Edge.
108
- * 2. Show the overflow in Edge, Firefox, and IE.
109
- */
110
- button,
111
- input, /* 1 */
112
- select { /* 2 */
113
- overflow: visible;
114
- }
115
-
116
- /**
117
- * Address inconsistent `text-transform` inheritance for `button` and `select`.
118
- * All other form control elements do not inherit `text-transform` values.
119
- * Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera.
120
- * Correct `select` style inheritance in Firefox.
121
- */
122
- button,
123
- select {
124
- text-transform: none;
125
- }
126
-
127
- /**
128
- * 1. Prevent a WebKit bug where (2) destroys native `audio` and `video`
129
- * controls in Android 4.
130
- * 2. Correct inability to style clickable `input` types in iOS.
131
- * 3. Improve usability and consistency of cursor style between image-type
132
- * `input` and others.
133
- */
134
- button,
135
- html [type="button"], /* 1 */
136
- [type="reset"],
137
- [type="submit"] {
138
- cursor: pointer; /* 3 */
139
- -webkit-appearance: button; /* 2 */
140
- }
141
-
142
- /**
143
- * Remove the inner border and padding in Firefox.
144
- */
145
- button::-moz-focus-inner,
146
- input::-moz-focus-inner {
147
- padding: 0;
148
- border: 0;
149
- }
150
- /**
151
- * 1. Remove the default vertical scrollbar in IE.
152
- */
153
- textarea {
154
- overflow: auto; /* 1 */
155
- resize: vertical;
156
- }
157
- svg:not(:root) {
158
- overflow: hidden; /* Correct overflow not hidden in IE. */
159
- }
160
-
161
- /**
162
- * Correct the odd appearance of search inputs in Chrome and Safari.
163
- */
164
- [type="search"] {
165
- -webkit-appearance: textfield;
166
- }
167
-
168
- /**
169
- * Remove the inner padding and cancel buttons in Chrome on OS X and
170
- * Safari on OS X.
171
- */
172
- [type="search"]::-webkit-search-cancel-button,
173
- [type="search"]::-webkit-search-decoration {
174
- -webkit-appearance: none;
175
- }
176
- /* stylelint-enable */
177
-
178
- [role="button"],
179
- input[type="submit"],
180
- input[type="reset"],
181
- input[type="button"],
182
- button {
183
- -webkit-box-sizing: content-box;
184
- -moz-box-sizing: content-box;
185
- box-sizing: content-box;
186
- }
187
-
188
- /* Reset `button` and button-style `input` default styles */
189
- input[type="submit"],
190
- input[type="reset"],
191
- input[type="button"],
192
- button {
193
- background: none;
194
- border: 0;
195
- color: inherit;
196
- /* cursor: default; */
197
- font: inherit;
198
- line-height: normal;
199
- overflow: visible;
200
- padding: 0;
201
- -webkit-appearance: button; /* for input */
202
- -webkit-user-select: none; /* for button */
203
- -moz-user-select: none;
204
- -ms-user-select: none;
205
- }
206
- input::-moz-focus-inner,
207
- button::-moz-focus-inner {
208
- border: 0;
209
- padding: 0;
210
- }
211
-
212
- /* Make `a` like a button */
213
- [role="button"] {
214
- color: inherit;
215
- cursor: default;
216
- display: inline-block;
217
- text-align: center;
218
- text-decoration: none;
219
- white-space: pre;
220
- -webkit-user-select: none;
221
- -moz-user-select: none;
222
- -ms-user-select: none;
223
- }
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "litecable"
4
-
5
- # Sample chat application
6
- module Chat
7
- class Connection < LiteCable::Connection::Base # :nodoc:
8
- identified_by :user, :sid
9
-
10
- def connect
11
- @user = cookies["user"]
12
- @sid = request.params["sid"]
13
- # reject_unauthorized_connection unless @user
14
- $stdout.puts "#{@user} connected"
15
- end
16
-
17
- def disconnect
18
- $stdout.puts "#{@user} disconnected"
19
- end
20
- end
21
-
22
- class Channel < LiteCable::Channel::Base # :nodoc:
23
- identifier :chat
24
-
25
- def subscribed
26
- reject unless chat_id
27
- stream_from "chat_#{chat_id}"
28
- end
29
-
30
- def speak(data)
31
- LiteCable.broadcast "chat_#{chat_id}", user: user, message: data["message"], sid: sid
32
- end
33
-
34
- private
35
-
36
- def chat_id
37
- params.fetch("id")
38
- end
39
- end
40
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "config/environment.rb"
4
-
5
- app = Rack::Builder.new do
6
- map "/" do
7
- run App
8
- end
9
- end
10
-
11
- unless ENV["ANYCABLE"]
12
- # Start built-in rack hijack middleware to serve websockets
13
- require "lite_cable/server"
14
-
15
- app.map "/cable" do
16
- use LiteCable::Server::Middleware, connection_class: Chat::Connection
17
- run(proc { |_| [200, {"Content-Type" => "text/plain"}, ["OK"]] })
18
- end
19
- end
20
-
21
- run app
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- lib = File.expand_path("../../../lib", __dir__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
-
6
- require_relative "../app"
7
- require_relative "../chat"
8
-
9
- LiteCable.config.log_level = Logger::DEBUG
10
-
11
- if ENV["ANYCABLE"]
12
- require "anycable"
13
-
14
- # Turn AnyCable compatibility mode
15
- LiteCable.anycable!
16
-
17
- AnyCable.connection_factory = Chat::Connection
18
- end
@@ -1,8 +0,0 @@
1
- h2 Room Id
2
-
3
- form action="/rooms" method="POST"
4
- .row
5
- input type="text" required="required" name="id"
6
- .row
7
- button.btn type="submit"
8
- span Go!
@@ -1,15 +0,0 @@
1
- doctype html
2
- html
3
- head
4
- title LiteCable Sinatra Demo
5
- meta name="viewport" content="width=device-width"
6
- meta charset="UTF-8"
7
- link rel="stylesheet" href="/reset.css"
8
- link rel="stylesheet" href="/app.css"
9
- script type="text/javascript" src="/cable.js"
10
- body
11
- .header
12
- h1.title
13
- a href='/' LiteCable
14
- .container.main
15
- == yield
@@ -1,8 +0,0 @@
1
- h2 Your Name
2
-
3
- form action="/sign_in" method="POST"
4
- .row
5
- input type="text" required="required" name="user"
6
- .row
7
- button.btn type="submit"
8
- span Go!
@@ -1,224 +0,0 @@
1
- css:
2
- /* Reset
3
- ----------------------------------------------------------------------------- */
4
-
5
- /* stylelint-disable */
6
-
7
- html, body,
8
- h1, h2, h3, h4, h5, h6, p, blockquote, pre,
9
- address, code, img,
10
- dl, dt, dd, ol, ul, li,
11
- fieldset, form, label,
12
- table, th, td,
13
- article, aside, nav, section, figure, figcaption, footer, header,
14
- audio, video {
15
- margin: 0;
16
- padding: 0;
17
- }
18
- blockquote, img, fieldset, form {
19
- border: 0;
20
- }
21
- a, strong, em, b, i, small, sub, sup, img, label, th, td, audio, video {
22
- vertical-align: baseline;
23
- }
24
- applet, object, iframe,
25
- abbr, acronym, big, cite,
26
- del, dfn, ins, kbd, q, s, samp,
27
- strike, tt, var, u, center, legend,
28
- caption, tbody, tfoot, thead, tr,
29
- canvas, details, embed,
30
- menu, output, ruby, summary,
31
- time, mark {
32
- margin: 0;
33
- padding: 0;
34
- border: 0;
35
- vertical-align: baseline;
36
- font: inherit;
37
- font-size: 100%;
38
- }
39
- ul, ol {
40
- list-style: none;
41
- }
42
-
43
- /* Border-box FTW
44
- https://css-tricks.com/inheriting-box-sizing-probably-slightly-better-best-practice/ */
45
- *,
46
- *:before,
47
- *:after {
48
- box-sizing: inherit;
49
- }
50
- html {
51
- overflow-y: scroll;
52
- box-sizing: border-box;
53
- text-size-adjust: 100%;
54
- }
55
- a {
56
- background-color: transparent; /* Remove the gray background color from active links in IE 10. */
57
- -webkit-text-decoration-skip: none;
58
-
59
- &:hover,
60
- &:active {
61
- outline: 0;
62
- }
63
- }
64
- img {
65
- vertical-align: middle;
66
- }
67
- strong, b {
68
- font-weight: bold;
69
- }
70
- em, i {
71
- font-style: italic;
72
- }
73
- h1, h2, h3, h4, h5, h6 {
74
- font-weight: bold;
75
- }
76
- table {
77
- border-spacing: 0;
78
- border-collapse: collapse;
79
- }
80
- th {
81
- font-weight: bold;
82
- }
83
- td {
84
- vertical-align: top;
85
- }
86
- input,
87
- select,
88
- textarea,
89
- button {
90
- margin: 0;
91
- vertical-align: middle;
92
- font-size: 100%;
93
- font-family: inherit;
94
- }
95
-
96
- /**
97
- * 1. Add the correct box sizing in IE 10-.
98
- * 2. Remove the padding in IE 10-.
99
- */
100
- [type="checkbox"],
101
- [type="radio"] {
102
- box-sizing: border-box; /* 1 */
103
- padding: 0; /* 2 */
104
- }
105
-
106
- /**
107
- * Show the overflow in IE.
108
- * 1. Show the overflow in Edge.
109
- * 2. Show the overflow in Edge, Firefox, and IE.
110
- */
111
- button,
112
- input, /* 1 */
113
- select { /* 2 */
114
- overflow: visible;
115
- }
116
-
117
- /**
118
- * Address inconsistent `text-transform` inheritance for `button` and `select`.
119
- * All other form control elements do not inherit `text-transform` values.
120
- * Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera.
121
- * Correct `select` style inheritance in Firefox.
122
- */
123
- button,
124
- select {
125
- text-transform: none;
126
- }
127
-
128
- /**
129
- * 1. Prevent a WebKit bug where (2) destroys native `audio` and `video`
130
- * controls in Android 4.
131
- * 2. Correct inability to style clickable `input` types in iOS.
132
- * 3. Improve usability and consistency of cursor style between image-type
133
- * `input` and others.
134
- */
135
- button,
136
- html [type="button"], /* 1 */
137
- [type="reset"],
138
- [type="submit"] {
139
- cursor: pointer; /* 3 */
140
- -webkit-appearance: button; /* 2 */
141
- }
142
-
143
- /**
144
- * Remove the inner border and padding in Firefox.
145
- */
146
- button::-moz-focus-inner,
147
- input::-moz-focus-inner {
148
- padding: 0;
149
- border: 0;
150
- }
151
- /**
152
- * 1. Remove the default vertical scrollbar in IE.
153
- */
154
- textarea {
155
- overflow: auto; /* 1 */
156
- resize: vertical;
157
- }
158
- svg:not(:root) {
159
- overflow: hidden; /* Correct overflow not hidden in IE. */
160
- }
161
-
162
- /**
163
- * Correct the odd appearance of search inputs in Chrome and Safari.
164
- */
165
- [type="search"] {
166
- -webkit-appearance: textfield;
167
- }
168
-
169
- /**
170
- * Remove the inner padding and cancel buttons in Chrome on OS X and
171
- * Safari on OS X.
172
- */
173
- [type="search"]::-webkit-search-cancel-button,
174
- [type="search"]::-webkit-search-decoration {
175
- -webkit-appearance: none;
176
- }
177
- /* stylelint-enable */
178
-
179
- [role="button"],
180
- input[type="submit"],
181
- input[type="reset"],
182
- input[type="button"],
183
- button {
184
- -webkit-box-sizing: content-box;
185
- -moz-box-sizing: content-box;
186
- box-sizing: content-box;
187
- }
188
-
189
- /* Reset `button` and button-style `input` default styles */
190
- input[type="submit"],
191
- input[type="reset"],
192
- input[type="button"],
193
- button {
194
- background: none;
195
- border: 0;
196
- color: inherit;
197
- /* cursor: default; */
198
- font: inherit;
199
- line-height: normal;
200
- overflow: visible;
201
- padding: 0;
202
- -webkit-appearance: button; /* for input */
203
- -webkit-user-select: none; /* for button */
204
- -moz-user-select: none;
205
- -ms-user-select: none;
206
- }
207
- input::-moz-focus-inner,
208
- button::-moz-focus-inner {
209
- border: 0;
210
- padding: 0;
211
- }
212
-
213
- /* Make `a` like a button */
214
- [role="button"] {
215
- color: inherit;
216
- cursor: default;
217
- display: inline-block;
218
- text-align: center;
219
- text-decoration: none;
220
- white-space: pre;
221
- -webkit-user-select: none;
222
- -moz-user-select: none;
223
- -ms-user-select: none;
224
- }