jugglite 0.5.0 → 0.6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1b81b7cc5bc16c5f0fe6377c9f26217631a8bf0a
4
- data.tar.gz: 38d82a7c27038f3f9fa2dbac6fa424ae594989fe
3
+ metadata.gz: 3b51ae9f570f0b97660639998883771ec4d6595a
4
+ data.tar.gz: 5c4908a07f85a24caa317db97df70f37273edd0e
5
5
  SHA512:
6
- metadata.gz: 50dbbe1c5535754c7887ec7fbfb2cd7ed63099c9875b46f03b303ea24c82fd008a760b0bc1c2f63e6c1428b1acacf816463af8ad2f2c5228fd67918bf55df88f
7
- data.tar.gz: 0b8c90aac69b801d2cfc3eef9d6fde260bf73c6db28c75fb36efeb984dce54c8c85820859b3e919c3cc5e57c65ebae25f0a2b84ee84d3817dfd0da1253cd7bd8
6
+ metadata.gz: fb7095e9e0efc013925a87827d6df16eaff2bc1e05875900d5197c90fcdcf363bca5cce164ce60b110182adfc53ede9f180c1db817fc4aede2b40b44df63da93
7
+ data.tar.gz: c6c9942ae51bf578bdadff91b2690b84c42bae8bd1780fbc4daef488e86e5b47cd712ad3f3b43cb46241c09cf7fd0311632997deb9f5c9faa11f4840f342e1b7
@@ -0,0 +1,39 @@
1
+ ## 0.6.0 / 2015-02-23
2
+
3
+ * Don't break when channel parameter is blank
4
+
5
+ ## 0.5.0 / 2014-05-03
6
+
7
+ * New option: +allowed_channels+ to limit/authorize which channels a request can listen to
8
+
9
+ ## 0.4.0 / 2014-03-12
10
+
11
+ * Support for listening to multiple channels
12
+
13
+ ## 0.3.0 / 2014-03-06
14
+
15
+ * Support redis namespace option
16
+
17
+ ## 0.2.0 / 2014-02-25
18
+
19
+ * If message is JSON, extract 'event' and 'id' from the message
20
+
21
+ ## 0.1.0 / 2014-02-21
22
+
23
+ * Compatible with newer em-hiredis
24
+
25
+ ## 0.0.4 / 2012-12-13
26
+
27
+ * support for listening to a unix socket using the --socket commandline option
28
+
29
+ ## 0.0.3 / 2012-11-04
30
+
31
+ * support IE7+ through [Remy's Polyfill](https://github.com/remy/polyfills/blob/master/EventSource.js), [read more](http://html5doctor.com/server-sent-events/)
32
+
33
+ ## 0.0.2.alpha / 2012-11-04
34
+
35
+ * standalone binary supports some thin commandline options
36
+
37
+ ## 0.0.1.alpha / 2012-11-15
38
+
39
+ * Initial gem release
data/README.md CHANGED
@@ -20,7 +20,26 @@ Or install it yourself as:
20
20
 
21
21
  ## Server Usage
22
22
 
23
- I use jugglite as rack middleware in development and as a standalone binary behind nginx in production.
23
+ I used to use Jugglite as rack middleware in development and as a standalone binary behind nginx in production. Nowadays I run my rails application using thin in production so I can mount Jugglite in the routes.rb file.
24
+
25
+ ### Inside Rails's routes.rb
26
+
27
+ This only works with an EventMachine based webserver that supports rack's async.callback. I have only tested this in production with Thin, but it might work with Rainbows or Puma.
28
+
29
+ This setup is great because it allows you to do channel authorization on a per request basis.
30
+
31
+ ```ruby
32
+ # config/routes.rb
33
+ # ...
34
+
35
+ @allowed_channels = ->(request) {
36
+ user_id = request.session['user_id']
37
+ user_id ? ['broadcast', "player_#{user_id}"] : []
38
+ }
39
+ get 'stream', to: Jugglite::App.new(nil, namespace: "app:#{Rails.env}:", allowed_channels: @allowed_channels)
40
+
41
+ # ...
42
+ ```
24
43
 
25
44
  ### Stand-alone binary
26
45
 
@@ -30,7 +49,7 @@ You can run the binary from any terminal like this (these options are the defaul
30
49
 
31
50
  `jugglite --address 0.0.0.0 --port 3000 --max-conns 1024`
32
51
 
33
- ### As Rack middleware (development)
52
+ ### As Rack middleware
34
53
 
35
54
  Add it to your `config.ru` file and make sure your application runs using Thin:
36
55
 
@@ -41,7 +60,7 @@ use Jugglite::App, path: '/stream', namespace: 'myapp:' if ENV['RACK_ENV'] == 'd
41
60
  run MyRails::Application
42
61
  ```
43
62
 
44
- ### Behind Nginx (production)
63
+ ### Behind Nginx
45
64
 
46
65
  NOTE: because the html5 SSE implementation requires the connection to have the same hostname and port, you'll need to add a reverse proxy in front of your app and jugglite.
47
66
 
@@ -90,7 +109,6 @@ server {
90
109
  }
91
110
  ```
92
111
 
93
-
94
112
  ## Client Usage
95
113
 
96
114
  Use the browser's native [Server-Sent Events](http://www.html5rocks.com/en/tutorials/eventsource/basics/) implementation:
@@ -81,7 +81,8 @@ module Jugglite
81
81
  end
82
82
 
83
83
  def channels_for_request(request)
84
- channels = Array(request.params["channel"].split(","))
84
+ channel_string = request.params["channel"] || ""
85
+ channels = Array(channel_string.split(","))
85
86
  # Sanitize channels
86
87
  channels = channels & allowed_channels(request) if @options[:allowed_channels]
87
88
  channels.map! { |channel| @options[:namespace] + channel }
@@ -1,3 +1,3 @@
1
1
  module Jugglite
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -52,6 +52,31 @@ describe "allowed_channels" do
52
52
  end
53
53
  end
54
54
 
55
+ describe "no channel" do
56
+ before(:each) do
57
+ @jugglite = Jugglite::App.new(nil, allowed_channels: ->(request) { [@channel2] })
58
+ start_server(@jugglite)
59
+ end
60
+
61
+ it "allows blank channel" do
62
+ Net::HTTP.start(@host, @port) do |http|
63
+ request = Net::HTTP::Get.new("/")
64
+
65
+ body = ""
66
+ http.request(request) do |response|
67
+ response.read_body do |chunk|
68
+ body << chunk
69
+ body.should include(": registered to channels: ")
70
+ body.should_not include(@channel1)
71
+ http.finish
72
+ break
73
+ end
74
+ break
75
+ end
76
+ end
77
+ end
78
+ end
79
+
55
80
  describe "as a Proc" do
56
81
  before(:each) do
57
82
  @jugglite = Jugglite::App.new(nil, allowed_channels: ->(request) { [@channel2] })
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jugglite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - andruby
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-03 00:00:00.000000000 Z
11
+ date: 2015-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thin
@@ -77,7 +77,7 @@ files:
77
77
  - ".gitignore"
78
78
  - ".rspec"
79
79
  - ".travis.yml"
80
- - CHANGELOG
80
+ - CHANGELOG.md
81
81
  - Gemfile
82
82
  - LICENSE.txt
83
83
  - README.md
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  version: '0'
113
113
  requirements: []
114
114
  rubyforge_project:
115
- rubygems_version: 2.2.2
115
+ rubygems_version: 2.4.5
116
116
  signing_key:
117
117
  specification_version: 4
118
118
  summary: Server Sent Events server written in rack on top of thin inspired by Juggernaut
data/CHANGELOG DELETED
@@ -1,37 +0,0 @@
1
- = 0.5.0 / 2014-05-03
2
-
3
- * New option: +allowed_channels+ to limit/authorize which channels a request can listen to
4
-
5
- = 0.4.0 / 2014-03-12
6
-
7
- * Support for listening to multiple channels
8
-
9
- = 0.3.0 / 2014-03-06
10
-
11
- * Support redis namespace option
12
-
13
- = 0.2.0 / 2014-02-25
14
-
15
- * If message is JSON, extract 'event' and 'id' from the message
16
-
17
- = 0.1.0 / 2014-02-21
18
-
19
- * Compatible with newer em-hiredis
20
-
21
- = 0.0.4 / 2012-12-13
22
-
23
- * support for listening to a unix socket using the --socket commandline option
24
-
25
- = 0.0.3 / 2012-11-04
26
-
27
- * support for Remy's Polyfill (which adds support for IE7+)
28
- see https://github.com/remy/polyfills/blob/master/EventSource.js
29
- and http://html5doctor.com/server-sent-events/
30
-
31
- = 0.0.2.alpha / 2012-11-04
32
-
33
- * standalone binary supports some thin commandline options
34
-
35
- = 0.0.1.alpha / 2012-11-15
36
-
37
- * Initial gem release