firehose 1.2.20 → 1.3.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +29 -0
  3. data/.dockerignore +2 -0
  4. data/.gitignore +3 -1
  5. data/.rubocop.yml +1156 -0
  6. data/.ruby-version +1 -0
  7. data/.travis.yml +3 -7
  8. data/CHANGELOG.md +15 -0
  9. data/Dockerfile +11 -0
  10. data/Gemfile +4 -2
  11. data/Procfile.dev +0 -1
  12. data/README.md +66 -8
  13. data/Rakefile +43 -32
  14. data/coffeelint.json +129 -0
  15. data/docker-compose.yml +17 -0
  16. data/firehose.gemspec +5 -9
  17. data/karma.config.coffee +89 -0
  18. data/lib/assets/javascripts/firehose.js.coffee +1 -2
  19. data/lib/assets/javascripts/firehose/consumer.js.coffee +18 -2
  20. data/lib/assets/javascripts/firehose/core.js.coffee +2 -1
  21. data/lib/assets/javascripts/firehose/long_poll.js.coffee +69 -8
  22. data/lib/assets/javascripts/firehose/multiplexed_consumer.js.coffee +74 -0
  23. data/lib/assets/javascripts/firehose/transport.js.coffee +4 -2
  24. data/lib/assets/javascripts/firehose/web_socket.js.coffee +51 -5
  25. data/lib/firehose/cli.rb +2 -1
  26. data/lib/firehose/client/producer.rb +10 -4
  27. data/lib/firehose/rack/consumer.rb +39 -0
  28. data/lib/firehose/rack/consumer/http_long_poll.rb +118 -45
  29. data/lib/firehose/rack/consumer/web_socket.rb +133 -28
  30. data/lib/firehose/rack/ping.rb +1 -1
  31. data/lib/firehose/rack/publisher.rb +10 -4
  32. data/lib/firehose/server.rb +9 -9
  33. data/lib/firehose/server/channel.rb +23 -31
  34. data/lib/firehose/server/message_buffer.rb +59 -0
  35. data/lib/firehose/server/publisher.rb +16 -17
  36. data/lib/firehose/server/redis.rb +32 -0
  37. data/lib/firehose/server/subscriber.rb +7 -7
  38. data/lib/firehose/version.rb +2 -2
  39. data/package.json +14 -2
  40. data/spec/integrations/shared_examples.rb +89 -7
  41. data/spec/javascripts/firehose/multiplexed_consumer_spec.coffee +72 -0
  42. data/spec/javascripts/firehose/transport_spec.coffee +0 -2
  43. data/spec/javascripts/firehose/websocket_spec.coffee +2 -0
  44. data/spec/javascripts/helpers/spec_helper.js +1 -0
  45. data/spec/javascripts/support/jquery-1.11.1.js +10308 -0
  46. data/{lib/assets/javascripts/vendor → spec/javascripts/support}/json2.js +0 -0
  47. data/spec/javascripts/support/spec_helper.coffee +3 -0
  48. data/spec/lib/assets_spec.rb +8 -8
  49. data/spec/lib/client/producer_spec.rb +14 -14
  50. data/spec/lib/firehose_spec.rb +2 -2
  51. data/spec/lib/rack/consumer/http_long_poll_spec.rb +21 -3
  52. data/spec/lib/rack/consumer_spec.rb +4 -4
  53. data/spec/lib/rack/ping_spec.rb +4 -4
  54. data/spec/lib/rack/publisher_spec.rb +5 -5
  55. data/spec/lib/server/app_spec.rb +2 -2
  56. data/spec/lib/server/channel_spec.rb +58 -44
  57. data/spec/lib/server/message_buffer_spec.rb +148 -0
  58. data/spec/lib/server/publisher_spec.rb +29 -22
  59. data/spec/lib/server/redis_spec.rb +13 -0
  60. data/spec/lib/server/subscriber_spec.rb +14 -13
  61. data/spec/spec_helper.rb +8 -1
  62. metadata +34 -95
  63. data/.rbenv-version +0 -1
  64. data/Guardfile +0 -31
  65. data/config/evergreen.rb +0 -9
@@ -0,0 +1 @@
1
+ 2.3.0
@@ -1,16 +1,12 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
- - 1.9.3
5
- - 2.0.0
6
- - 2.1.0
4
+ - 2.1.10
5
+ - 2.2.5
6
+ - 2.3.1
7
7
 
8
8
  services:
9
9
  - redis-server
10
10
 
11
- before_script:
12
- - bundle exec rake travis:prepare
13
-
14
11
  script:
15
12
  - bundle exec rake spec
16
- - xvfb-run bundle exec rake evergreen:run
@@ -0,0 +1,15 @@
1
+ ## master
2
+
3
+ - Configuration of Redis via the `Firehose::Server.redis` object.
4
+ - Less rubygem dependencies: JSON gem removed because its included in Ruby 2.x
5
+ - DEPRECATED: `firehose javascript` command will be removed. Those have been moved to https://github.com/firehoseio/js_client.
6
+
7
+ ## 1.3.6
8
+
9
+ - DEPRECATION WARNING: `firehose javascript` has been removed from this project.
10
+ - BUG: The null message bug fix in 1.3.5 introduce different behavior into the messages delivered when a client reconnects with a last_sequence. This has been corrected and 1.3.5 will be yanked.
11
+
12
+ ## 1.3.5
13
+
14
+ - Fix bug where null messages are sent over WebSockets to client. Issue https://github.com/firehoseio/firehose/issues/51.
15
+ - Drop support for Ruby 1.9.3. Documented official Ruby support policy in README.md
@@ -0,0 +1,11 @@
1
+ FROM ruby
2
+
3
+ RUN apt-get update && apt-get install -y \
4
+ qt5-default libqt5webkit5-dev gstreamer1.0-plugins-base gstreamer1.0-tools gstreamer1.0-x
5
+
6
+ WORKDIR /firehose/
7
+ COPY . /firehose/
8
+ RUN bundle
9
+
10
+ EXPOSE 7474
11
+ CMD bundle exec firehose server
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
+
3
+ gem "codeclimate-test-reporter", group: :test, require: nil
2
4
 
3
5
  # Specify your gem's dependencies in firehose.gemspec
4
- gemspec
6
+ gemspec
@@ -1,4 +1,3 @@
1
1
  firehose: ./bin/firehose server -p $PORT
2
2
  redis: redis-server
3
- evergreen: rake evergreen:serve
4
3
  # guard: guard
data/README.md CHANGED
@@ -1,13 +1,13 @@
1
- __ _ _
2
- / _(_) | |
3
- | |_ _ _ __ ___| |__ ___ ___ ___
1
+ __ _ _
2
+ / _(_) | |
3
+ | |_ _ _ __ ___| |__ ___ ___ ___
4
4
  | _| | '__/ _ \ '_ \ / _ \/ __|/ _ \
5
5
  | | | | | | __/ | | | (_) \__ \ __/
6
6
  |_| |_|_| \___|_| |_|\___/|___/\___|
7
-
7
+
8
8
  Build realtime web applications in Ruby and JS
9
9
 
10
- [![Build Status](https://travis-ci.org/polleverywhere/firehose.png)](https://travis-ci.org/polleverywhere/firehose)
10
+ [![Build Status](https://travis-ci.org/firehoseio/firehose.svg?branch=master)](https://travis-ci.org/firehoseio/firehose) [![Code Climate](https://codeclimate.com/github/firehoseio/firehose/badges/gpa.svg)](https://codeclimate.com/github/firehoseio/firehose) [![Test Coverage](https://codeclimate.com/github/firehoseio/firehose/badges/coverage.svg)](https://codeclimate.com/github/firehoseio/firehose/coverage)
11
11
 
12
12
  # What is Firehose?
13
13
 
@@ -90,6 +90,53 @@ new Firehose.Consumer({
90
90
  }).connect();
91
91
  ```
92
92
 
93
+ There's also a Consumer that uses channel multiplexing.
94
+ The multiplexed consumer is useful for scenarios where you want to subscribe
95
+ to messages from many channels at once, without having to use one connection
96
+ per channel. You can specify a list of channels to subscribe to, including a
97
+ handler function per channel that gets called with all messages coming from that
98
+ channel.
99
+
100
+ Example:
101
+
102
+ ```javascript
103
+ new Firehose.MultiplexedConsumer({
104
+ connected: function(){
105
+ console.log("Great Scotts!! We're connected!");
106
+ },
107
+ disconnected: function(){
108
+ console.log("Well shucks, we're not connected anymore");
109
+ },
110
+ error: function(){
111
+ console.log("Well then, something went horribly wrong.");
112
+ },
113
+ // Note that we don't specify a general message handler function
114
+ // but instead define one per channel below
115
+
116
+ // Note that we do NOT specify a protocol here because we don't
117
+ // know that yet. We also don't specify a specific channel name as part of
118
+ // the URI but instead pass in a list of subscriptions below
119
+ uri: '//localhost:7474/',
120
+
121
+ // List of channel subscriptions:
122
+ channels: {
123
+ "/my/channel/1": {
124
+ last_sequence: 10, // defaults to 0 and can be ommitted
125
+ message: function(msg) {
126
+ console.log("got message on channel 1:");
127
+ console.log(msg);
128
+ }
129
+ },
130
+ "/my/channel/2": {
131
+ message: function(msg) {
132
+ console.log("got message on channel 2:");
133
+ console.log(msg);
134
+ }
135
+ }
136
+ }
137
+ }).connect();
138
+ ```
139
+
93
140
  Then publish another message.
94
141
 
95
142
  ```sh
@@ -120,7 +167,7 @@ Firehose can be configured via environmental variables. Take a look at the [`.en
120
167
 
121
168
  ## Rack Configuration
122
169
 
123
- There are two rack applications that are included with Firehose: `Firehose::Rack::Producer` which a client can `PUT` HTTP request with message payloads to publish information on Firehose and the `Firehose::Rack::Consumer` application which a client connects to via HTT long polling or WebSockets to consume a message.
170
+ There are two rack applications that are included with Firehose: `Firehose::Rack::Producer` which a client can `PUT` HTTP request with message payloads to publish information on Firehose and the `Firehose::Rack::Consumer` application which a client connects to via HTTP long polling or WebSockets to consume a message.
124
171
 
125
172
  ### Consumer Configuration
126
173
 
@@ -208,7 +255,7 @@ end
208
255
 
209
256
  # Deployment
210
257
 
211
- The recommended method of deploying firehose is to deploy it separately from your main app.
258
+ The recommended method ofGdeploying firehose is to deploy it separately from your main app.
212
259
 
213
260
  1. Create a new project with a Gemfile such as
214
261
 
@@ -216,7 +263,7 @@ The recommended method of deploying firehose is to deploy it separately from you
216
263
  gem "firehose"
217
264
  gem "airbrake"
218
265
  gem "rainbows", :require => false
219
- gem "rack", "~> 1.4.0" # if you're using Rainbows. See https://github.com/polleverywhere/firehose/commit/dfe55fff
266
+ gem "rack", "~> 1.4.0" # if you're using Rainbows. See https://github.com/firehoseio/firehose/commit/dfe55fff
220
267
  gem "foreman", :require => false
221
268
  gem "capistrano", :require => false
222
269
  ```
@@ -226,3 +273,14 @@ Of course, you could use `exceptional` instead of `airbrake` and `thin` instead
226
273
  2. Set up `config/deploy.rb` to your liking. You can follow most directions for using Capistrano and Foreman to deploy Rack apps, such as https://gist.github.com/1027117
227
274
 
228
275
  3. Set up `config/rainbows.rb` (if you are using Rainbows!). The gem includes example configurations scripts to get you started. There's also an example at https://gist.github.com/bradgessler/f2416efdbb1771e983b3.
276
+
277
+ # New releases & version bump
278
+
279
+ For a new release of Firehose, bump the version number in `lib/firehose/version.rb` as well as `package.json`.
280
+ Make sure, they have the same version number.
281
+
282
+ # Support
283
+
284
+ ## Ruby version
285
+
286
+ Firehose will support the latest minor 2.x revisions of Ruby that are officially supported by the Ruby community. More details at https://www.ruby-lang.org/.
data/Rakefile CHANGED
@@ -3,51 +3,62 @@ require 'bundler/gem_tasks'
3
3
  require 'rspec/core/rake_task'
4
4
  require 'coffee-script'
5
5
 
6
+ task :default => :spec
7
+ task :debug => ["spec:debug"]
8
+ task :ci => ["spec:ci"]
6
9
 
7
- task :default => [:spec, 'evergreen:run']
10
+ task :spec => ["spec:all"]
8
11
 
12
+ namespace :js do
13
+ desc "Compile *.js.coffee.erb files"
14
+ task :compile_erb do
15
+ require 'erb'
16
+ require_relative "lib/firehose"
9
17
 
10
- desc 'run Rspec specs'
11
- task :spec do
12
- sh 'rspec spec'
13
- end
18
+ erb_files = Dir.glob("lib/assets/javascripts/**/*.erb")
14
19
 
20
+ erb_files.each do |template_file|
21
+ output_file = template_file.split(".erb")[0]
22
+ puts "ERB compile #{template_file} => #{output_file}"
15
23
 
16
- namespace :evergreen do
17
- desc 'run Evergreen specs'
18
- task :run do
19
- sh 'evergreen run'
24
+ renderer = ERB.new File.read(template_file)
25
+ File.open(output_file, "w+") do |f|
26
+ f.puts renderer.result
27
+ end
28
+ end
20
29
  end
30
+ end
31
+
32
+ namespace :spec do
33
+ desc "Run all specs"
34
+ task :all => [:ruby, "js:run"]
21
35
 
22
- desc 'start an Evergreen server'
23
- task :serve do
24
- sh 'evergreen serve'
36
+ desc 'run Rspec specs'
37
+ task :ruby do
38
+ sh 'rspec spec'
25
39
  end
26
- end
27
40
 
41
+ task :js => "js:run"
28
42
 
29
- namespace :travis do
30
- desc 'Prepares evergreen and JS files for Travis CI'
31
- task :prepare do
32
- # Prepare directories
33
- sh "mkdir -p public/javascripts/vendor"
34
- sh "mkdir -p public/javascripts/firehose"
43
+ # desc "Run specs with Karma runner"
44
+ namespace :js do
45
+ task :setup => "js:compile_erb" do
46
+ sh %[npm install]
47
+ end
35
48
 
36
- # Precompile coffeescript
37
- Dir.glob 'lib/assets/javascripts/**/*.js.coffee' do |coffee_file|
38
- dest = coffee_file.gsub( 'lib/assets/', 'public/' ).gsub '.js.coffee', '.js'
49
+ desc "CI specs run on PhantomJS"
50
+ task :ci => :setup do
51
+ sh %[./node_modules/karma/bin/karma start karma.config.coffee --browsers PhantomJS --single-run --reporters dots,junit]
52
+ end
39
53
 
40
- File.open dest, 'w' do |file|
41
- file.write ::CoffeeScript.compile File.read coffee_file
42
- end
54
+ desc "Run local specs in PhantomJS"
55
+ task :run => :setup do
56
+ sh %[./node_modules/karma/bin/karma start karma.config.coffee --browsers PhantomJS --single-run]
43
57
  end
44
58
 
45
- # Copy JS vendor files into public
46
- Dir.glob [
47
- 'spec/javascripts/support/*.js',
48
- 'lib/assets/javascripts/vendor/*.js'
49
- ] do |js_file|
50
- sh "cp #{js_file} public/javascripts/vendor"
59
+ desc "Run local specs in Chrome and leaves the window open for debugging"
60
+ task :debug => :setup do
61
+ sh %[./node_modules/karma/bin/karma start karma.config.coffee --browsers Chrome]
51
62
  end
52
63
  end
53
- end
64
+ end
@@ -0,0 +1,129 @@
1
+ {
2
+ "arrow_spacing": {
3
+ "level": "ignore"
4
+ },
5
+ "braces_spacing": {
6
+ "level": "ignore",
7
+ "spaces": 0,
8
+ "empty_object_spaces": 0
9
+ },
10
+ "camel_case_classes": {
11
+ "level": "error"
12
+ },
13
+ "coffeescript_error": {
14
+ "level": "error"
15
+ },
16
+ "colon_assignment_spacing": {
17
+ "level": "ignore",
18
+ "spacing": {
19
+ "left": 0,
20
+ "right": 0
21
+ }
22
+ },
23
+ "cyclomatic_complexity": {
24
+ "value": 10,
25
+ "level": "ignore"
26
+ },
27
+ "duplicate_key": {
28
+ "level": "error"
29
+ },
30
+ "empty_constructor_needs_parens": {
31
+ "level": "ignore"
32
+ },
33
+ "ensure_comprehensions": {
34
+ "level": "warn"
35
+ },
36
+ "eol_last": {
37
+ "level": "ignore"
38
+ },
39
+ "indentation": {
40
+ "value": 2,
41
+ "level": "error"
42
+ },
43
+ "line_endings": {
44
+ "level": "ignore",
45
+ "value": "unix"
46
+ },
47
+ "max_line_length": {
48
+ "value": 80,
49
+ "level": "error",
50
+ "limitComments": true
51
+ },
52
+ "missing_fat_arrows": {
53
+ "level": "ignore",
54
+ "is_strict": false
55
+ },
56
+ "newlines_after_classes": {
57
+ "value": 3,
58
+ "level": "ignore"
59
+ },
60
+ "no_backticks": {
61
+ "level": "error"
62
+ },
63
+ "no_debugger": {
64
+ "level": "warn",
65
+ "console": false
66
+ },
67
+ "no_empty_functions": {
68
+ "level": "ignore"
69
+ },
70
+ "no_empty_param_list": {
71
+ "level": "ignore"
72
+ },
73
+ "no_implicit_braces": {
74
+ "level": "ignore",
75
+ "strict": true
76
+ },
77
+ "no_implicit_parens": {
78
+ "strict": true,
79
+ "level": "ignore"
80
+ },
81
+ "no_interpolation_in_single_quotes": {
82
+ "level": "ignore"
83
+ },
84
+ "no_plusplus": {
85
+ "level": "ignore"
86
+ },
87
+ "no_stand_alone_at": {
88
+ "level": "ignore"
89
+ },
90
+ "no_tabs": {
91
+ "level": "error"
92
+ },
93
+ "no_this": {
94
+ "level": "ignore"
95
+ },
96
+ "no_throwing_strings": {
97
+ "level": "error"
98
+ },
99
+ "no_trailing_semicolons": {
100
+ "level": "error"
101
+ },
102
+ "no_trailing_whitespace": {
103
+ "level": "error",
104
+ "allowed_in_comments": false,
105
+ "allowed_in_empty_lines": true
106
+ },
107
+ "no_unnecessary_double_quotes": {
108
+ "level": "ignore"
109
+ },
110
+ "no_unnecessary_fat_arrows": {
111
+ "level": "warn"
112
+ },
113
+ "non_empty_constructor_needs_parens": {
114
+ "level": "ignore"
115
+ },
116
+ "prefer_english_operator": {
117
+ "level": "ignore",
118
+ "doubleNotLevel": "ignore"
119
+ },
120
+ "space_operators": {
121
+ "level": "ignore"
122
+ },
123
+ "spacing_after_comma": {
124
+ "level": "ignore"
125
+ },
126
+ "transform_messes_up_line_numbers": {
127
+ "level": "warn"
128
+ }
129
+ }
@@ -0,0 +1,17 @@
1
+ # Isolated development and test environment.
2
+ version: '2'
3
+ services:
4
+ firehose:
5
+ build: .
6
+ depends_on:
7
+ - redis
8
+ environment:
9
+ REDIS_URL: redis://redis:6379/0
10
+ ports:
11
+ - 7474
12
+ volumes:
13
+ - .:/firehose/
14
+ redis:
15
+ image: redis
16
+ expose:
17
+ - 6379
@@ -5,8 +5,8 @@ require "firehose/version"
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "firehose"
7
7
  s.version = Firehose::VERSION
8
- s.authors = ["Brad Gessler", "Steel Fu", "Paul Cortens", "Zach Zolton"]
9
- s.email = ["brad@polleverywhere.com", "steel@polleverywhere.com", "paul@polleverywhere.com", "zach@polleverywhere.com"]
8
+ s.authors = ["Brad Gessler", "Steel Fu", "Paul Cortens", "Zach Zolton", "Christopher Bertels"]
9
+ s.email = ["brad@polleverywhere.com", "steel@polleverywhere.com", "paul@polleverywhere.com", "zach@polleverywhere.com", "christopher@polleverywhere.com"]
10
10
  s.homepage = "http://firehose.io/"
11
11
  s.summary = %q{Build realtime Ruby web applications}
12
12
  s.description = %q{Firehose is a realtime web application toolkit for building realtime Ruby web applications.}
@@ -23,19 +23,16 @@ Gem::Specification.new do |s|
23
23
  s.add_runtime_dependency "eventmachine", ">= 1.0.0"
24
24
  s.add_runtime_dependency "em-hiredis", ">= 0.2.0"
25
25
  s.add_runtime_dependency "thor"
26
- s.add_runtime_dependency "faraday"
26
+ # faraday 0.9.1 causes some specs to fail
27
+ # need to investigate this further
28
+ s.add_runtime_dependency "faraday", "0.9.0"
27
29
  s.add_runtime_dependency "faye-websocket"
28
30
  s.add_runtime_dependency "em-http-request", ">= 1.0.0"
29
- s.add_runtime_dependency "json"
30
31
  s.add_runtime_dependency "rack"
31
32
 
32
33
  s.add_development_dependency "rspec", "~> 2"
33
34
  s.add_development_dependency "webmock"
34
35
  s.add_development_dependency "coffee-script"
35
- s.add_development_dependency "guard-rspec"
36
- s.add_development_dependency "guard-bundler"
37
- s.add_development_dependency "guard-coffeescript"
38
- s.add_development_dependency "guard-copy"
39
36
  s.add_development_dependency "rainbows", "~> 4.4.3"
40
37
  s.add_development_dependency "thin"
41
38
  s.add_development_dependency "rack-test"
@@ -43,7 +40,6 @@ Gem::Specification.new do |s|
43
40
  s.add_development_dependency "foreman"
44
41
  s.add_development_dependency "sprockets"
45
42
  s.add_development_dependency "rake"
46
- s.add_development_dependency "evergreen"
47
43
  s.add_development_dependency "capybara-webkit"
48
44
  s.add_development_dependency "therubyracer"
49
45
  end