firehose 1.2.10 → 1.2.11

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -8,3 +8,4 @@ pkg/*
8
8
  tmp
9
9
  *.sublime-project
10
10
  *.sublime-workspace
11
+ public/javascripts
@@ -1 +1 @@
1
- 1.9.3-p392
1
+ 1.9.3-p484
@@ -1,5 +1,16 @@
1
1
  language: ruby
2
+
2
3
  rvm:
3
4
  - 1.9.3
4
- - 1.8.7
5
- - ree
5
+ - 2.0.0
6
+ - 2.1.0
7
+
8
+ services:
9
+ - redis-server
10
+
11
+ before_script:
12
+ - bundle exec rake travis:prepare
13
+
14
+ script:
15
+ - bundle exec rake spec
16
+ - xvfb-run bundle exec rake evergreen:run
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- firehose (1.2.9)
4
+ firehose (1.2.11)
5
5
  em-hiredis (>= 0.2.0)
6
6
  em-http-request (>= 1.0.0)
7
7
  eventmachine (>= 1.0.0)
@@ -16,6 +16,18 @@ GEM
16
16
  specs:
17
17
  addressable (2.3.5)
18
18
  async_rack_test (0.0.4)
19
+ capybara (1.1.4)
20
+ mime-types (>= 1.16)
21
+ nokogiri (>= 1.3.3)
22
+ rack (>= 1.0.0)
23
+ rack-test (>= 0.5.4)
24
+ selenium-webdriver (~> 2.0)
25
+ xpath (~> 0.1.4)
26
+ capybara-webkit (0.13.1)
27
+ capybara (>= 1.0.0, < 1.2)
28
+ json
29
+ childprocess (0.3.9)
30
+ ffi (~> 1.0, >= 1.0.11)
19
31
  coderay (1.0.9)
20
32
  coffee-script (2.2.0)
21
33
  coffee-script-source
@@ -29,21 +41,27 @@ GEM
29
41
  dotenv (0.9.0)
30
42
  em-hiredis (0.2.1)
31
43
  hiredis (~> 0.4.0)
32
- em-http-request (1.1.1)
44
+ em-http-request (1.1.2)
33
45
  addressable (>= 2.3.4)
34
46
  cookiejar
35
47
  em-socksify (>= 0.3)
36
48
  eventmachine (>= 1.0.3)
37
- http_parser.rb (>= 0.6.0.beta.2)
49
+ http_parser.rb (>= 0.6.0)
38
50
  em-socksify (0.3.0)
39
51
  eventmachine (>= 1.0.0.beta.4)
40
52
  eventmachine (1.0.3)
53
+ evergreen (1.0.1)
54
+ capybara (~> 1.0)
55
+ coffee-script
56
+ json_pure
57
+ launchy
58
+ sinatra (~> 1.1)
41
59
  execjs (2.0.2)
42
- faraday (0.8.8)
43
- multipart-post (~> 1.2.0)
44
- faye-websocket (0.7.0)
60
+ faraday (0.9.0)
61
+ multipart-post (>= 1.2, < 3)
62
+ faye-websocket (0.7.2)
45
63
  eventmachine (>= 0.12.0)
46
- websocket-driver (>= 0.3.0)
64
+ websocket-driver (>= 0.3.1)
47
65
  ffi (1.9.0)
48
66
  foreman (0.63.0)
49
67
  dotenv (>= 0.7)
@@ -61,27 +79,39 @@ GEM
61
79
  guard-coffeescript (1.3.4)
62
80
  coffee-script (>= 2.2.0)
63
81
  guard (>= 1.1.0)
82
+ guard-copy (0.0.8)
83
+ guard (~> 1.1)
64
84
  guard-rspec (3.1.0)
65
85
  guard (>= 1.8)
66
86
  rspec (~> 2.13)
67
87
  hike (1.2.3)
68
88
  hiredis (0.4.5)
69
- http_parser.rb (0.6.0.beta.2)
89
+ http_parser.rb (0.6.0)
70
90
  json (1.8.1)
91
+ json_pure (1.8.1)
71
92
  kgio (2.8.1)
93
+ launchy (2.4.2)
94
+ addressable (~> 2.3)
95
+ libv8 (3.16.14.3)
72
96
  listen (1.3.1)
73
97
  rb-fsevent (>= 0.9.3)
74
98
  rb-inotify (>= 0.9)
75
99
  rb-kqueue (>= 0.2)
76
100
  lumberjack (1.0.4)
77
101
  method_source (0.8.2)
102
+ mime-types (2.0)
103
+ mini_portile (0.5.2)
78
104
  multi_json (1.8.2)
79
- multipart-post (1.2.0)
105
+ multipart-post (2.0.0)
106
+ nokogiri (1.6.1)
107
+ mini_portile (~> 0.5.0)
80
108
  pry (0.9.12.2)
81
109
  coderay (~> 1.0.5)
82
110
  method_source (~> 0.8)
83
111
  slop (~> 3.4)
84
112
  rack (1.4.5)
113
+ rack-protection (1.5.1)
114
+ rack
85
115
  rack-test (0.6.2)
86
116
  rack (>= 1.0)
87
117
  rainbows (4.4.3)
@@ -95,6 +125,7 @@ GEM
95
125
  ffi (>= 0.5.0)
96
126
  rb-kqueue (0.2.0)
97
127
  ffi (>= 0.5.0)
128
+ ref (1.0.5)
98
129
  rspec (2.14.1)
99
130
  rspec-core (~> 2.14.0)
100
131
  rspec-expectations (~> 2.14.0)
@@ -103,13 +134,26 @@ GEM
103
134
  rspec-expectations (2.14.3)
104
135
  diff-lcs (>= 1.1.3, < 2.0)
105
136
  rspec-mocks (2.14.4)
137
+ rubyzip (1.1.0)
106
138
  safe_yaml (0.9.7)
139
+ selenium-webdriver (2.38.0)
140
+ childprocess (>= 0.2.5)
141
+ multi_json (~> 1.0)
142
+ rubyzip (~> 1.0)
143
+ websocket (~> 1.0.4)
144
+ sinatra (1.4.4)
145
+ rack (~> 1.4)
146
+ rack-protection (~> 1.4)
147
+ tilt (~> 1.3, >= 1.3.4)
107
148
  slop (3.4.6)
108
149
  sprockets (2.10.0)
109
150
  hike (~> 1.2)
110
151
  multi_json (~> 1.0)
111
152
  rack (~> 1.0)
112
153
  tilt (~> 1.1, != 1.3.0)
154
+ therubyracer (0.12.0)
155
+ libv8 (~> 3.16.14.0)
156
+ ref
113
157
  thin (1.6.1)
114
158
  daemons (>= 1.0.9)
115
159
  eventmachine (>= 1.0.0)
@@ -123,22 +167,30 @@ GEM
123
167
  webmock (1.15.0)
124
168
  addressable (>= 2.2.7)
125
169
  crack (>= 0.3.2)
126
- websocket-driver (0.3.0)
170
+ websocket (1.0.7)
171
+ websocket-driver (0.3.2)
172
+ xpath (0.1.4)
173
+ nokogiri (~> 1.3)
127
174
 
128
175
  PLATFORMS
129
176
  ruby
130
177
 
131
178
  DEPENDENCIES
132
179
  async_rack_test
180
+ capybara-webkit
181
+ coffee-script
182
+ evergreen
133
183
  firehose!
134
184
  foreman
135
185
  guard-bundler
136
186
  guard-coffeescript
187
+ guard-copy
137
188
  guard-rspec
138
189
  rack-test
139
190
  rainbows (~> 4.4.3)
140
191
  rake
141
192
  rspec
142
193
  sprockets
194
+ therubyracer
143
195
  thin
144
196
  webmock
data/Guardfile CHANGED
@@ -1,6 +1,31 @@
1
+ guard 'bundler' do
2
+ watch 'Gemfile'
3
+ watch /^.+\.gemspec/
4
+ end
5
+
6
+
7
+ guard 'coffeescript',
8
+ input: 'lib/assets/javascripts',
9
+ output: 'public/javascripts',
10
+ all_on_start: true
11
+
12
+
1
13
  guard 'rspec', :version => 2 do
2
14
  watch(%r{^spec/.+_spec\.rb$})
3
15
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
16
  watch('spec/spec_helper.rb') { "spec" }
5
17
  end
6
18
 
19
+
20
+ guard :copy,
21
+ from: 'lib/assets/javascripts/vendor',
22
+ to: 'public/javascripts/vendor',
23
+ mkpath: true,
24
+ run_at_start: true
25
+
26
+
27
+ guard :copy,
28
+ from: 'spec/javascripts/support',
29
+ to: 'public/javascripts/vendor',
30
+ mkpath: true,
31
+ run_at_start: true
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2011-2013 Brad Gessler
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,4 @@
1
+ firehose: ./bin/firehose server -p $PORT
2
+ redis: redis-server
3
+ evergreen: rake evergreen:serve
4
+ # guard: guard
data/README.md CHANGED
@@ -177,6 +177,16 @@ Firehose::Assets::Sprockets.configure my_sprockets_env
177
177
 
178
178
  It is important that your firehose config file comes first.
179
179
 
180
+ ### Not using sprockets?
181
+
182
+ If you don't intend to use the Firehose JavaScript client in a Ruby stack where Sprockets is available, you can grab the unminified source by running:
183
+
184
+ ```sh
185
+ $ firehose javascript > firehose.js
186
+ ```
187
+
188
+ Copy the firehose.js where needed in your project.
189
+
180
190
  # Web Server
181
191
 
182
192
  Firehose currently supports Thin and Rainbows! (which is the default). Neither is listed as a dependency in the gemspec so that you don't need to install whichever one you aren't using. You can set which server to use via the `.env` file (recommended) or with the `-s` option to `bin/firehose`.
@@ -214,4 +224,4 @@ Of course, you could use `exceptional` instead of `airbrake` and `thin` instead
214
224
 
215
225
  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
216
226
 
217
- 3. Set up `config/rainbows.rb` (if you are using Rainbows!). The gem includes an example to get you started.
227
+ 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.
data/Rakefile CHANGED
@@ -1,10 +1,53 @@
1
1
  require "rake/testtask"
2
2
  require 'bundler/gem_tasks'
3
3
  require 'rspec/core/rake_task'
4
+ require 'coffee-script'
5
+
6
+
7
+ task :default => [:spec, 'evergreen:run']
4
8
 
5
- task :default => [:spec]
6
9
 
7
10
  desc 'run Rspec specs'
8
11
  task :spec do
9
12
  sh 'rspec spec'
10
- end
13
+ end
14
+
15
+
16
+ namespace :evergreen do
17
+ desc 'run Evergreen specs'
18
+ task :run do
19
+ sh 'evergreen run'
20
+ end
21
+
22
+ desc 'start an Evergreen server'
23
+ task :serve do
24
+ sh 'evergreen serve'
25
+ end
26
+ end
27
+
28
+
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"
35
+
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'
39
+
40
+ File.open dest, 'w' do |file|
41
+ file.write ::CoffeeScript.compile File.read coffee_file
42
+ end
43
+ end
44
+
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"
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,9 @@
1
+ require 'capybara-webkit'
2
+
3
+
4
+ Evergreen.configure do |config|
5
+ config.driver = :webkit
6
+ config.public_dir = 'public'
7
+ # config.template_dir = 'spec/javascripts/templates'
8
+ config.spec_dir = 'spec/javascripts'
9
+ end
@@ -10,6 +10,7 @@ Gem::Specification.new do |s|
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.}
13
+ s.license = "MIT"
13
14
 
14
15
  s.rubyforge_project = "firehose"
15
16
 
@@ -30,9 +31,11 @@ Gem::Specification.new do |s|
30
31
 
31
32
  s.add_development_dependency "rspec"
32
33
  s.add_development_dependency "webmock"
34
+ s.add_development_dependency "coffee-script"
33
35
  s.add_development_dependency "guard-rspec"
34
36
  s.add_development_dependency "guard-bundler"
35
37
  s.add_development_dependency "guard-coffeescript"
38
+ s.add_development_dependency "guard-copy"
36
39
  s.add_development_dependency "rainbows", "~> 4.4.3"
37
40
  s.add_development_dependency "thin"
38
41
  s.add_development_dependency "rack-test"
@@ -40,4 +43,7 @@ Gem::Specification.new do |s|
40
43
  s.add_development_dependency "foreman"
41
44
  s.add_development_dependency "sprockets"
42
45
  s.add_development_dependency "rake"
46
+ s.add_development_dependency "evergreen"
47
+ s.add_development_dependency "capybara-webkit"
48
+ s.add_development_dependency "therubyracer"
43
49
  end
@@ -1,7 +1,7 @@
1
- #= require firehose/json2
2
1
  #= require firehose/base
3
2
  #= require firehose/version
4
3
  #= require firehose/transport
5
4
  #= require firehose/long_poll
6
5
  #= require firehose/web_socket
7
6
  #= require firehose/consumer
7
+ #= require vendor/json2
@@ -1 +1 @@
1
- window.Firehose = {}
1
+ window.Firehose = {}
@@ -5,8 +5,8 @@ class Firehose.LongPoll extends Firehose.Transport
5
5
  # CORS is kinda supported in IE8+ except that its implementation cannot
6
6
  # access "simple request" response headers. This means we don't yet have a
7
7
  # plan to support IE<10 (when it gets a real XHR2 implementation). Sucks...
8
- @ieSupported: ->
9
- $.browser.msie and parseInt($.browser.version) >= 8
8
+ # $.browser.msie and parseInt($.browser.version) >= 8 # DEPRECATED
9
+ @ieSupported: -> (document.documentMode || 10) > 8
10
10
 
11
11
  @supported: ->
12
12
  # IE 8+, FF 3.5+, Chrome 4+, Safari 4+, Opera 12+, iOS 3.2+, Android 2.1+
@@ -27,7 +27,7 @@ class Firehose.LongPoll extends Firehose.Transport
27
27
  # We use the lag time to make the client live longer than the server.
28
28
  @_lagTime = 5000
29
29
  @_timeout = @config.longPoll.timeout + @_lagTime
30
- @_okInterval = 0
30
+ @_okInterval = @config.okInterval || 0
31
31
  @_stopRequestLoop = false
32
32
 
33
33
  # Protocol schema we should use for talking to firehose server.
@@ -8,6 +8,7 @@ class Firehose.Transport
8
8
  constructor: (config={}) ->
9
9
  @config = config
10
10
  @_retryDelay = 3000
11
+ @
11
12
 
12
13
  # Lets rock'n'roll! Connect to the server.
13
14
  connect: (delay = 0) =>
@@ -4,9 +4,8 @@ KEEPALIVE_PING_TIMEOUT = 20000
4
4
  class Firehose.WebSocket extends Firehose.Transport
5
5
  name: -> 'WebSocket'
6
6
 
7
- # Check if WebSocket is an object in the window.
8
- @supported: ->
9
- window.WebSocket?
7
+ @ieSupported:-> (document.documentMode || 10) > 9
8
+ @supported :-> window.WebSocket? # Check if WebSocket is an object in the window.
10
9
 
11
10
  constructor: (args) ->
12
11
  super args
@@ -1,3 +1,5 @@
1
+ require 'sprockets'
2
+
1
3
  module Firehose
2
4
  # Deal with bundling Sprocket assets into environments (like Rails or Sprockets)
3
5
  module Assets
@@ -7,12 +9,33 @@ module Firehose
7
9
 
8
10
  # Integrate Firehose ./lib/assets files into a sprocket-enabled environment.
9
11
  module Sprockets
12
+ # Entry-point Javascript for Sprockets project.
13
+ JAVASCRIPT = "firehose.js"
14
+
10
15
  # Drop flash and javascript paths to Firehose assets into a sprockets environment.
11
16
  def self.configure(env)
12
17
  env.append_path Firehose::Assets.path('javascripts')
13
18
  env
14
19
  end
15
20
 
21
+ # The "main" javascript that folks should compile and use in their
22
+ # web applications.
23
+ def self.javascript
24
+ Firehose::Assets::Sprockets.environment[JAVASCRIPT].source
25
+ end
26
+
27
+ # Return a new sprockets environment configured with Firehose.
28
+ def self.environment
29
+ configure ::Sprockets::Environment.new
30
+ end
31
+
32
+ # Quick and dirty way for folks to compile the Firehose assets to a path
33
+ # from the CLI and use. These are usualy non-ruby (or non-sprockets) folks
34
+ # who want to run the firehose process and use the JS in a web app.
35
+ def self.manifest(directory)
36
+ ::Sprockets::Manifest.new(environment, directory)
37
+ end
38
+
16
39
  # Try to automatically configure Sprockets if its detected in the project.
17
40
  def self.auto_detect
18
41
  if defined? ::Sprockets and ::Sprockets.respond_to? :append_path
@@ -20,7 +43,7 @@ module Firehose
20
43
  end
21
44
  end
22
45
 
23
- def self.manifest
46
+ def self.manifest_paths
24
47
  paths = []
25
48
  paths << File.basename(Firehose::Assets.path('/javascripts/firehose/firehose.js.coffee'), '.coffee')
26
49
  paths