Permalink
Browse files

Bumping version dependencies

  • Loading branch information...
1 parent a36de0a commit a6e3f8c442fcf87d17ce5a8a8e2efc3c2cf75399 @afcapel committed Nov 8, 2011
Showing with 131 additions and 140 deletions.
  1. +5 −15 Gemfile
  2. +78 −96 Gemfile.lock
  3. +1 −1 README.md
  4. +1 −3 alondra.gemspec
  5. +38 −20 app/assets/javascripts/vendor/web_socket.js
  6. +3 −3 lib/alondra/server.rb
  7. +5 −2 test/dummy/app/models/user.rb
View
20 Gemfile
@@ -1,6 +1,9 @@
source "http://rubygems.org"
-gem 'rails', '3.1.0.rc5'
+# Pusher server
+gemspec
+
+# rails dependecies
gem "mysql2"
# Rails 3.1 - Asset Pipeline
@@ -12,21 +15,8 @@ gem 'uglifier'
# Rails 3.1 - JavaScript
gem 'jquery-rails'
-# Pusher server
-gem 'eventmachine', :git => 'git://github.com/eventmachine/eventmachine.git'
-gem 'em-websocket'
-gem 'em-synchrony'
-gem 'em-http-request'
-gem 'em-zeromq', :git => 'git://github.com/andrewvc/em-zeromq.git'
-
-# Redis driver
-gem "hiredis", ">= 0.3.1"
-gem "redis", ">= 2.2.1"
-
-gem 'uuidtools'
-
gem 'capybara'
-gem 'capybara-webkit', :git => 'git://github.com/thoughtbot/capybara-webkit.git'
+gem 'capybara-webkit'
gem 'launchy'
gem 'factory_girl'
View
174 Gemfile.lock
@@ -1,158 +1,148 @@
-GIT
- remote: git://github.com/andrewvc/em-zeromq.git
- revision: 7d3f2b6ed6e9f39b9d43a1c4dad78f49411bdfdf
+PATH
+ remote: .
specs:
- em-zeromq (0.2.1)
+ alondra (0.0.2)
+ daemons
+ em-websocket
+ em-zeromq (= 0.2.1)
eventmachine (>= 1.0.0.beta.3)
- ffi-rzmq (>= 0.7.2)
-
-GIT
- remote: git://github.com/eventmachine/eventmachine.git
- revision: 3c8ea2ed3d81190eb204fecdf8e9421c7d3f19c9
- specs:
- eventmachine (1.0.0.beta.4)
-
-GIT
- remote: git://github.com/thoughtbot/capybara-webkit.git
- revision: 3b025e7115c8f9688e83df47937f53c5ed029e18
- specs:
- capybara-webkit (0.6.0)
- capybara (~> 1.0.0)
+ ffi-rzmq (= 0.8.0)
+ rails (>= 3.1.0)
+ uuidtools
GEM
remote: http://rubygems.org/
specs:
- actionmailer (3.1.0.rc5)
- actionpack (= 3.1.0.rc5)
+ actionmailer (3.1.1)
+ actionpack (= 3.1.1)
mail (~> 2.3.0)
- actionpack (3.1.0.rc5)
- activemodel (= 3.1.0.rc5)
- activesupport (= 3.1.0.rc5)
+ actionpack (3.1.1)
+ activemodel (= 3.1.1)
+ activesupport (= 3.1.1)
builder (~> 3.0.0)
erubis (~> 2.7.0)
i18n (~> 0.6)
- rack (~> 1.3.1)
- rack-cache (~> 1.0.2)
- rack-mount (~> 0.8.1)
- rack-test (~> 0.6.0)
- sprockets (~> 2.0.0.beta.12)
- activemodel (3.1.0.rc5)
- activesupport (= 3.1.0.rc5)
- bcrypt-ruby (~> 2.1.4)
+ rack (~> 1.3.2)
+ rack-cache (~> 1.1)
+ rack-mount (~> 0.8.2)
+ rack-test (~> 0.6.1)
+ sprockets (~> 2.0.2)
+ activemodel (3.1.1)
+ activesupport (= 3.1.1)
builder (~> 3.0.0)
i18n (~> 0.6)
- activerecord (3.1.0.rc5)
- activemodel (= 3.1.0.rc5)
- activesupport (= 3.1.0.rc5)
- arel (~> 2.1.4)
+ activerecord (3.1.1)
+ activemodel (= 3.1.1)
+ activesupport (= 3.1.1)
+ arel (~> 2.2.1)
tzinfo (~> 0.3.29)
- activeresource (3.1.0.rc5)
- activemodel (= 3.1.0.rc5)
- activesupport (= 3.1.0.rc5)
- activesupport (3.1.0.rc5)
+ activeresource (3.1.1)
+ activemodel (= 3.1.1)
+ activesupport (= 3.1.1)
+ activesupport (3.1.1)
multi_json (~> 1.0)
addressable (2.2.6)
- arel (2.1.4)
- bcrypt-ruby (2.1.4)
+ arel (2.2.1)
builder (3.0.0)
- capybara (1.0.1)
+ capybara (1.1.1)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0)
xpath (~> 0.1.4)
- childprocess (0.2.1)
+ capybara-webkit (0.7.2)
+ capybara (< 1.2, >= 1.0.0)
+ childprocess (0.2.2)
ffi (~> 1.0.6)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.1.2)
- em-http-request (0.3.0)
- addressable (>= 2.0.0)
- escape_utils
- eventmachine (>= 0.12.9)
- em-synchrony (0.2.0)
- eventmachine (>= 0.12.9)
- em-websocket (0.3.1)
+ daemons (1.1.4)
+ em-websocket (0.3.5)
addressable (>= 2.1.1)
eventmachine (>= 0.12.9)
+ em-zeromq (0.2.1)
+ eventmachine (>= 1.0.0.beta.3)
+ ffi-rzmq (>= 0.7.2)
erubis (2.7.0)
- escape_utils (0.2.3)
- execjs (1.2.4)
+ eventmachine (1.0.0.beta.4)
+ execjs (1.2.9)
multi_json (~> 1.0)
- factory_girl (2.0.4)
+ factory_girl (2.2.0)
+ activesupport
ffi (1.0.9)
ffi-rzmq (0.8.0)
hike (1.2.1)
- hiredis (0.3.2)
i18n (0.6.0)
- jquery-rails (1.0.13)
+ jquery-rails (1.0.16)
railties (~> 3.0)
thor (~> 0.14)
- json (1.5.3)
- json_pure (1.5.3)
+ json (1.6.1)
+ json_pure (1.6.1)
launchy (2.0.5)
addressable (~> 2.2.6)
mail (2.3.0)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
- mime-types (1.16)
+ mime-types (1.17.2)
multi_json (1.0.3)
mysql2 (0.3.7)
nokogiri (1.5.0)
- polyglot (0.3.2)
- rack (1.3.2)
- rack-cache (1.0.2)
+ polyglot (0.3.3)
+ rack (1.3.5)
+ rack-cache (1.1)
rack (>= 0.4)
- rack-mount (0.8.2)
+ rack-mount (0.8.3)
rack (>= 1.0.0)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
rack (>= 1.0)
- rails (3.1.0.rc5)
- actionmailer (= 3.1.0.rc5)
- actionpack (= 3.1.0.rc5)
- activerecord (= 3.1.0.rc5)
- activeresource (= 3.1.0.rc5)
- activesupport (= 3.1.0.rc5)
+ rails (3.1.1)
+ actionmailer (= 3.1.1)
+ actionpack (= 3.1.1)
+ activerecord (= 3.1.1)
+ activeresource (= 3.1.1)
+ activesupport (= 3.1.1)
bundler (~> 1.0)
- railties (= 3.1.0.rc5)
- railties (3.1.0.rc5)
- actionpack (= 3.1.0.rc5)
- activesupport (= 3.1.0.rc5)
+ railties (= 3.1.1)
+ railties (3.1.1)
+ actionpack (= 3.1.1)
+ activesupport (= 3.1.1)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
- rake (0.9.2)
- rdoc (3.9.2)
- redis (2.2.2)
+ rake (0.9.2.2)
+ rdoc (3.11)
+ json (~> 1.4)
rubyzip (0.9.4)
- sass (3.1.7)
- sass-rails (3.1.0.rc.5)
- actionpack (~> 3.1.0.rc1)
- railties (~> 3.1.0.rc1)
+ sass (3.1.10)
+ sass-rails (3.1.4)
+ actionpack (~> 3.1.0)
+ railties (~> 3.1.0)
sass (>= 3.1.4)
- sprockets (>= 2.0.0.beta.9)
- selenium-webdriver (2.4.0)
+ sprockets (~> 2.0.0)
+ tilt (~> 1.3.2)
+ selenium-webdriver (2.10.0)
childprocess (>= 0.2.1)
- ffi (>= 1.0.7)
+ ffi (= 1.0.9)
json_pure
rubyzip
- sprockets (2.0.0.beta.13)
+ sprockets (2.0.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (!= 1.3.0, ~> 1.1)
thor (0.14.6)
- tilt (1.3.2)
+ tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
- tzinfo (0.3.29)
- uglifier (1.0.1)
+ tzinfo (0.3.31)
+ uglifier (1.0.4)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
uuidtools (2.1.2)
@@ -163,22 +153,14 @@ PLATFORMS
ruby
DEPENDENCIES
+ alondra!
capybara
- capybara-webkit!
+ capybara-webkit
coffee-script
- em-http-request
- em-synchrony
- em-websocket
- em-zeromq!
- eventmachine!
factory_girl
- hiredis (>= 0.3.1)
jquery-rails
json
launchy
mysql2
- rails (= 3.1.0.rc5)
- redis (>= 2.2.1)
sass-rails
uglifier
- uuidtools
View
2 README.md
@@ -17,7 +17,7 @@ To subscribe to a channel you can use the built in helper:
```
Alondra uses [conventions to map records and classes to channel names](https://github.com/afcapel/alondra/wiki/Event-conventions).
-The lastexample will subscribe the browser to a channel named '/chats/:chat_id'.
+The last example will subscribe the browser to a channel named '/chats/:chat_id'.
Then, the Alondra client will render any message pushed to that channel.
If you don't want to use Alondra conventions, you can always provide your own
View
4 alondra.gemspec
@@ -18,8 +18,6 @@ Gem::Specification.new do |s|
s.add_dependency('rails', '>= 3.1.0')
s.add_dependency('eventmachine', '>= 1.0.0.beta.3')
s.add_dependency('em-websocket')
- s.add_dependency('em-synchrony')
- s.add_dependency('em-http-request')
- s.add_dependency('ffi', '1.0.9')
+ s.add_dependency('ffi-rzmq', '0.8.0')
s.add_dependency('em-zeromq', '0.2.1')
end
View
58 app/assets/javascripts/vendor/web_socket.js
@@ -1,24 +1,29 @@
// Copyright: Hiroshi Ichikawa <http://gimite.net/en/>
// License: New BSD License
// Reference: http://dev.w3.org/html5/websockets/
-// Reference: http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol
+// Reference: http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-10
(function() {
- if (window.WebSocket) return;
-
- var console = window.console;
- if (!console || !console.log || !console.error) {
- console = {log: function(){ }, error: function(){ }};
+ if (window.WebSocket && !window.WEB_SOCKET_FORCE_FLASH) return;
+
+ var logger;
+ if (window.WEB_SOCKET_LOGGER) {
+ logger = WEB_SOCKET_LOGGER;
+ } else if (window.console && window.console.log && window.console.error) {
+ // In some environment, console is defined but console.log or console.error is missing.
+ logger = window.console;
+ } else {
+ logger = {log: function(){ }, error: function(){ }};
}
// swfobject.hasFlashPlayerVersion("10.0.0") doesn't work with Gnash.
- if (!swfobject.getFlashPlayerVersion().major >= 10) {
- console.error("Flash Player >= 10.0.0 is required.");
+ if (swfobject.getFlashPlayerVersion().major < 10) {
+ logger.error("Flash Player >= 10.0.0 is required.");
return;
}
if (location.protocol == "file:") {
- console.error(
+ logger.error(
"WARNING: web-socket-js doesn't work in file:///... URL " +
"unless you set Flash Security Settings properly. " +
"Open the page via Web server i.e. http://...");
@@ -46,8 +51,9 @@
}
// Uses setTimeout() to make sure __createFlash() runs after the caller sets ws.onopen etc.
// Otherwise, when onopen fires immediately, onopen is called before it is set.
- setTimeout(function() {
+ self.__createTask = setTimeout(function() {
WebSocket.__addTask(function() {
+ self.__createTask = null;
WebSocket.__flash.create(
self.__id, url, protocols, proxyHost || null, proxyPort || 0, headers || null);
});
@@ -84,6 +90,12 @@
* Close this web socket gracefully.
*/
WebSocket.prototype.close = function() {
+ if (this.__createTask) {
+ clearTimeout(this.__createTask);
+ this.__createTask = null;
+ this.readyState = WebSocket.CLOSED;
+ return;
+ }
if (this.readyState == WebSocket.CLOSED || this.readyState == WebSocket.CLOSING) {
return;
}
@@ -137,14 +149,15 @@
events[i](event);
}
var handler = this["on" + event.type];
- if (handler) handler(event);
+ if (handler) handler.apply(this, [event]);
};
/**
* Handles an event from Flash.
* @param {Object} flashEvent
*/
WebSocket.prototype.__handleEvent = function(flashEvent) {
+
if ("readyState" in flashEvent) {
this.readyState = flashEvent.readyState;
}
@@ -156,8 +169,10 @@
if (flashEvent.type == "open" || flashEvent.type == "error") {
jsEvent = this.__createSimpleEvent(flashEvent.type);
} else if (flashEvent.type == "close") {
- // TODO implement jsEvent.wasClean
jsEvent = this.__createSimpleEvent("close");
+ jsEvent.wasClean = flashEvent.wasClean ? true : false;
+ jsEvent.code = flashEvent.code;
+ jsEvent.reason = flashEvent.reason;
} else if (flashEvent.type == "message") {
var data = decodeURIComponent(flashEvent.message);
jsEvent = this.__createMessageEvent("message", data);
@@ -166,6 +181,7 @@
}
this.dispatchEvent(jsEvent);
+
};
WebSocket.prototype.__createSimpleEvent = function(type) {
@@ -223,18 +239,20 @@
window.WEB_SOCKET_SWF_LOCATION = WebSocket.__swfLocation;
}
if (!window.WEB_SOCKET_SWF_LOCATION) {
- console.error("[WebSocket] set WEB_SOCKET_SWF_LOCATION to location of WebSocketMain.swf");
+ logger.error("[WebSocket] set WEB_SOCKET_SWF_LOCATION to location of WebSocketMain.swf");
return;
}
- if (!WEB_SOCKET_SWF_LOCATION.match(/(^|\/)WebSocketMainInsecure\.swf(\?.*)?$/) &&
+ if (!window.WEB_SOCKET_SUPPRESS_CROSS_DOMAIN_SWF_ERROR &&
+ !WEB_SOCKET_SWF_LOCATION.match(/(^|\/)WebSocketMainInsecure\.swf(\?.*)?$/) &&
WEB_SOCKET_SWF_LOCATION.match(/^\w+:\/\/([^\/]+)/)) {
var swfHost = RegExp.$1;
if (location.host != swfHost) {
- console.error(
+ logger.error(
"[WebSocket] You must host HTML and WebSocketMain.swf in the same host " +
"('" + location.host + "' != '" + swfHost + "'). " +
"See also 'How to host HTML file and SWF file in different domains' section " +
- "in README.md.");
+ "in README.md. If you use WebSocketMainInsecure.swf, you can suppress this message " +
+ "by WEB_SOCKET_SUPPRESS_CROSS_DOMAIN_SWF_ERROR = true;");
}
}
var container = document.createElement("div");
@@ -270,7 +288,7 @@
null,
function(e) {
if (!e.success) {
- console.error("[WebSocket] swfobject.embedSWF failed");
+ logger.error("[WebSocket] swfobject.embedSWF failed");
}
});
};
@@ -307,20 +325,20 @@
WebSocket.__instances[events[i].webSocketId].__handleEvent(events[i]);
}
} catch (e) {
- console.error(e);
+ logger.error(e);
}
}, 0);
return true;
};
// Called by Flash.
WebSocket.__log = function(message) {
- console.log(decodeURIComponent(message));
+ logger.log(decodeURIComponent(message));
};
// Called by Flash.
WebSocket.__error = function(message) {
- console.error(decodeURIComponent(message));
+ logger.error(decodeURIComponent(message));
};
WebSocket.__addTask = function(task) {
View
6 lib/alondra/server.rb
@@ -1,6 +1,4 @@
require 'em-websocket'
-require 'em-synchrony'
-require 'em-synchrony/em-http'
module Alondra
module Server
@@ -13,7 +11,7 @@ def run
websocket.onopen do
session = SessionParser.parse(websocket)
-
+
Rails.logger.info "client connected."
Connection.new(websocket, session)
end
@@ -24,6 +22,7 @@ def run
end
websocket.onerror do |ex|
+ puts "Error: #{ex.message}"
Rails.logger.error "Error: #{ex.message}"
Rails.logger.error ex.backtrace.join("\n")
Connections[websocket].destroy! if Connections[websocket]
@@ -36,6 +35,7 @@ def run
end
EM.error_handler do |error|
+ puts "Error raised during event loop: #{error.message}"
Rails.logger.error "Error raised during event loop: #{error.message}"
Rails.logger.error error.stacktrace if error.respond_to? :stacktrace
end
View
7 test/dummy/app/models/user.rb
@@ -1,3 +1,6 @@
+require 'digest'
+require 'securerandom'
+
class User < ActiveRecord::Base
# new columns need to be added here to be writable through mass assignment
attr_accessible :username, :email, :password, :password_confirmation
@@ -20,14 +23,14 @@ def self.authenticate(login, pass)
end
def encrypt_password(pass)
- BCrypt::Engine.hash_secret(pass, password_salt)
+ Digest::SHA2.hexdigest(pass + password_salt)
end
private
def prepare_password
unless password.blank?
- self.password_salt = BCrypt::Engine.generate_salt
+ self.password_salt = SecureRandom.hex(16)
self.password_hash = encrypt_password(password)
end
end

0 comments on commit a6e3f8c

Please sign in to comment.