alondra 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,44 +1,44 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- alondra (0.0.4)
4
+ alondra (0.1.0)
5
5
  daemons
6
6
  em-websocket
7
- em-zeromq (= 0.2.2)
7
+ em-zeromq (= 0.3.0)
8
8
  rails (>= 3.1.0)
9
9
  uuidtools
10
10
 
11
11
  GEM
12
12
  remote: http://rubygems.org/
13
13
  specs:
14
- actionmailer (3.2.0)
15
- actionpack (= 3.2.0)
16
- mail (~> 2.4.0)
17
- actionpack (3.2.0)
18
- activemodel (= 3.2.0)
19
- activesupport (= 3.2.0)
14
+ actionmailer (3.2.8)
15
+ actionpack (= 3.2.8)
16
+ mail (~> 2.4.4)
17
+ actionpack (3.2.8)
18
+ activemodel (= 3.2.8)
19
+ activesupport (= 3.2.8)
20
20
  builder (~> 3.0.0)
21
21
  erubis (~> 2.7.0)
22
- journey (~> 1.0.0)
22
+ journey (~> 1.0.4)
23
23
  rack (~> 1.4.0)
24
- rack-cache (~> 1.1)
24
+ rack-cache (~> 1.2)
25
25
  rack-test (~> 0.6.1)
26
- sprockets (~> 2.1.2)
27
- activemodel (3.2.0)
28
- activesupport (= 3.2.0)
26
+ sprockets (~> 2.1.3)
27
+ activemodel (3.2.8)
28
+ activesupport (= 3.2.8)
29
29
  builder (~> 3.0.0)
30
- activerecord (3.2.0)
31
- activemodel (= 3.2.0)
32
- activesupport (= 3.2.0)
33
- arel (~> 3.0.0)
30
+ activerecord (3.2.8)
31
+ activemodel (= 3.2.8)
32
+ activesupport (= 3.2.8)
33
+ arel (~> 3.0.2)
34
34
  tzinfo (~> 0.3.29)
35
- activeresource (3.2.0)
36
- activemodel (= 3.2.0)
37
- activesupport (= 3.2.0)
38
- activesupport (3.2.0)
35
+ activeresource (3.2.8)
36
+ activemodel (= 3.2.8)
37
+ activesupport (= 3.2.8)
38
+ activesupport (3.2.8)
39
39
  i18n (~> 0.6)
40
40
  multi_json (~> 1.0)
41
- addressable (2.2.6)
41
+ addressable (2.3.2)
42
42
  arel (3.0.2)
43
43
  builder (3.0.0)
44
44
  capybara (1.1.2)
@@ -48,100 +48,102 @@ GEM
48
48
  rack-test (>= 0.5.4)
49
49
  selenium-webdriver (~> 2.0)
50
50
  xpath (~> 0.1.4)
51
- capybara-webkit (0.8.0)
51
+ capybara-webkit (0.12.1)
52
52
  capybara (>= 1.0.0, < 1.2)
53
53
  json
54
- childprocess (0.3.0)
55
- ffi (~> 1.0.6)
54
+ childprocess (0.3.5)
55
+ ffi (~> 1.0, >= 1.0.6)
56
56
  coffee-script (2.2.0)
57
57
  coffee-script-source
58
58
  execjs
59
- coffee-script-source (1.2.0)
60
- daemons (1.1.8)
61
- em-websocket (0.3.6)
59
+ coffee-script-source (1.3.3)
60
+ daemons (1.1.9)
61
+ em-websocket (0.3.8)
62
62
  addressable (>= 2.1.1)
63
63
  eventmachine (>= 0.12.9)
64
- em-zeromq (0.2.2)
65
- eventmachine (>= 1.0.0.beta.4)
64
+ em-zeromq (0.3.0)
65
+ eventmachine (= 1.0.0.beta.4)
66
66
  ffi (>= 1.0.0)
67
- ffi-rzmq (~> 0.9.0)
67
+ ffi-rzmq (= 0.9.3)
68
68
  erubis (2.7.0)
69
69
  eventmachine (1.0.0.beta.4)
70
- execjs (1.3.0)
70
+ execjs (1.4.0)
71
71
  multi_json (~> 1.0)
72
- factory_girl (2.5.0)
73
- activesupport
74
- ffi (1.0.11)
72
+ factory_girl (4.0.0)
73
+ activesupport (>= 3.0.0)
74
+ ffi (1.1.5)
75
75
  ffi-rzmq (0.9.3)
76
76
  ffi
77
77
  hike (1.2.1)
78
78
  i18n (0.6.0)
79
- journey (1.0.0)
80
- jquery-rails (2.0.0)
81
- railties (>= 3.2.0.beta, < 5.0)
79
+ journey (1.0.4)
80
+ jquery-rails (2.0.2)
81
+ railties (>= 3.2.0, < 5.0)
82
82
  thor (~> 0.14)
83
- json (1.6.5)
84
- launchy (2.0.5)
85
- addressable (~> 2.2.6)
83
+ json (1.7.4)
84
+ launchy (2.1.2)
85
+ addressable (~> 2.3)
86
+ libwebsocket (0.1.5)
87
+ addressable
86
88
  mail (2.4.4)
87
89
  i18n (>= 0.4.0)
88
90
  mime-types (~> 1.16)
89
91
  treetop (~> 1.4.8)
90
- mime-types (1.17.2)
91
- multi_json (1.0.4)
92
+ mime-types (1.19)
93
+ multi_json (1.3.6)
92
94
  mysql2 (0.3.11)
93
- nokogiri (1.5.0)
95
+ nokogiri (1.5.5)
94
96
  polyglot (0.3.3)
95
97
  rack (1.4.1)
96
- rack-cache (1.1)
98
+ rack-cache (1.2)
97
99
  rack (>= 0.4)
98
100
  rack-ssl (1.3.2)
99
101
  rack
100
102
  rack-test (0.6.1)
101
103
  rack (>= 1.0)
102
- rails (3.2.0)
103
- actionmailer (= 3.2.0)
104
- actionpack (= 3.2.0)
105
- activerecord (= 3.2.0)
106
- activeresource (= 3.2.0)
107
- activesupport (= 3.2.0)
104
+ rails (3.2.8)
105
+ actionmailer (= 3.2.8)
106
+ actionpack (= 3.2.8)
107
+ activerecord (= 3.2.8)
108
+ activeresource (= 3.2.8)
109
+ activesupport (= 3.2.8)
108
110
  bundler (~> 1.0)
109
- railties (= 3.2.0)
110
- railties (3.2.0)
111
- actionpack (= 3.2.0)
112
- activesupport (= 3.2.0)
111
+ railties (= 3.2.8)
112
+ railties (3.2.8)
113
+ actionpack (= 3.2.8)
114
+ activesupport (= 3.2.8)
113
115
  rack-ssl (~> 1.3.2)
114
116
  rake (>= 0.8.7)
115
117
  rdoc (~> 3.4)
116
- thor (~> 0.14.6)
118
+ thor (>= 0.14.6, < 2.0)
117
119
  rake (0.9.2.2)
118
120
  rdoc (3.12)
119
121
  json (~> 1.4)
120
- rubyzip (0.9.5)
121
- sass (3.1.12)
122
- sass-rails (3.2.3)
123
- railties (~> 3.2.0.beta)
122
+ rubyzip (0.9.9)
123
+ sass (3.2.0)
124
+ sass-rails (3.2.5)
125
+ railties (~> 3.2.0)
124
126
  sass (>= 3.1.10)
125
127
  tilt (~> 1.3)
126
- selenium-webdriver (2.17.0)
128
+ selenium-webdriver (2.25.0)
127
129
  childprocess (>= 0.2.5)
128
- ffi (~> 1.0.9)
129
- multi_json (~> 1.0.4)
130
+ libwebsocket (~> 0.1.3)
131
+ multi_json (~> 1.0)
130
132
  rubyzip
131
- sprockets (2.1.2)
133
+ sprockets (2.1.3)
132
134
  hike (~> 1.2)
133
135
  rack (~> 1.0)
134
136
  tilt (~> 1.1, != 1.3.0)
135
- thor (0.14.6)
137
+ thor (0.15.4)
136
138
  tilt (1.3.3)
137
139
  treetop (1.4.10)
138
140
  polyglot
139
141
  polyglot (>= 0.3.1)
140
- tzinfo (0.3.32)
141
- uglifier (1.2.2)
142
+ tzinfo (0.3.33)
143
+ uglifier (1.2.7)
142
144
  execjs (>= 0.3.0)
143
- multi_json (>= 1.0.2)
144
- uuidtools (2.1.2)
145
+ multi_json (~> 1.3)
146
+ uuidtools (2.1.3)
145
147
  xpath (0.1.4)
146
148
  nokogiri (~> 1.3)
147
149
 
data/Rakefile CHANGED
@@ -1,27 +1,11 @@
1
1
  #!/usr/bin/env rake
2
2
  begin
3
3
  require 'bundler/setup'
4
+ require "bundler/gem_tasks"
5
+ require 'rake/testtask'
4
6
  rescue LoadError
5
7
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
8
  end
7
- begin
8
- require 'rdoc/task'
9
- rescue LoadError
10
- require 'rdoc/rdoc'
11
- require 'rake/rdoctask'
12
- RDoc::Task = Rake::RDocTask
13
- end
14
-
15
- RDoc::Task.new(:rdoc) do |rdoc|
16
- rdoc.rdoc_dir = 'rdoc'
17
- rdoc.title = 'Alondra'
18
- rdoc.options << '--line-numbers' << '--inline-source'
19
- rdoc.rdoc_files.include('README.rdoc')
20
- rdoc.rdoc_files.include('lib/**/*.rb')
21
- end
22
-
23
-
24
- require 'rake/testtask'
25
9
 
26
10
  Rake::TestTask.new(:test) do |t|
27
11
  t.libs << 'lib'
@@ -30,5 +14,4 @@ Rake::TestTask.new(:test) do |t|
30
14
  t.verbose = false
31
15
  end
32
16
 
33
-
34
17
  task :default => :test
data/alondra.gemspec CHANGED
@@ -1,10 +1,11 @@
1
- # Provide a simple gemspec so you can easily use your
2
- # project in your rails apps through git.
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/alondra/version', __FILE__)
3
+
3
4
  Gem::Specification.new do |s|
4
5
  s.name = "alondra"
5
6
  s.summary = "Add real time capabilities to your rails app"
6
7
  s.description = "Add real time capabilities to your rails app"
7
- s.version = "0.0.4"
8
+ s.version = Alondra::VERSION
8
9
  s.authors = ['Alberto F. Capel', 'Ryan LeCompte']
9
10
 
10
11
  s.files = `git ls-files`.split("\n")
@@ -17,5 +18,5 @@ Gem::Specification.new do |s|
17
18
  s.add_dependency('uuidtools')
18
19
  s.add_dependency('rails', '>= 3.1.0')
19
20
  s.add_dependency('em-websocket')
20
- s.add_dependency('em-zeromq', '0.2.2')
21
+ s.add_dependency('em-zeromq', '0.3.0')
21
22
  end
@@ -8,9 +8,9 @@ window.WEB_SOCKET_SWF_LOCATION = "<%= asset_path 'WebSocketMain.swf' %>"
8
8
 
9
9
  class @AlondraClient
10
10
  constructor: (@server, @channels=[], @token = null, @retry = 10000) ->
11
-
11
+
12
12
  @channels = [@channels] unless @channels instanceof Array
13
-
13
+
14
14
  @url = "ws://#{@server}"
15
15
  @url += "?token=#{@token}" if @token
16
16
 
@@ -20,28 +20,31 @@ class @AlondraClient
20
20
  if @socket.readyState == 0 # Socket is connecting
21
21
  @channels.push(channel) # Schedule for later subscription
22
22
  return
23
-
23
+
24
24
  subscription =
25
25
  command: 'subscribe'
26
26
  channel: channel
27
27
 
28
28
  @socket.send $.toJSON(subscription)
29
29
  @
30
-
31
- connected: () =>
30
+
31
+ opened: () =>
32
32
  if @reconnectInterval
33
33
  clearInterval(@reconnectInterval)
34
34
  @reconnectInterval = null
35
-
35
+
36
36
  @subscribe(channel) for channel in @channels
37
-
37
+ $(this).trigger('connected')
38
+ true
39
+
38
40
  connect: =>
39
41
  @socket = new WebSocket(@url)
40
-
41
- @socket.onopen = @connected
42
+
43
+ @socket.onopen = @opened
42
44
 
43
45
  @socket.onclose = () =>
44
46
  this.reconnect()
47
+ $(this).trigger('disconnected')
45
48
 
46
49
  @socket.onmessage = (message) =>
47
50
  msg = $.parseJSON(message.data)
@@ -53,7 +56,8 @@ class @AlondraClient
53
56
 
54
57
  @socket.onerror = (error) =>
55
58
  @reconnect()
56
-
59
+ $(this).trigger('error', error)
60
+
57
61
  @
58
62
 
59
63
  process: (serverEvent) ->
@@ -1,11 +1,19 @@
1
1
  // Copyright: Hiroshi Ichikawa <http://gimite.net/en/>
2
2
  // License: New BSD License
3
3
  // Reference: http://dev.w3.org/html5/websockets/
4
- // Reference: http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-10
4
+ // Reference: http://tools.ietf.org/html/rfc6455
5
5
 
6
6
  (function() {
7
7
 
8
- if (window.WebSocket && !window.WEB_SOCKET_FORCE_FLASH) return;
8
+ if (window.WEB_SOCKET_FORCE_FLASH) {
9
+ // Keeps going.
10
+ } else if (window.WebSocket) {
11
+ return;
12
+ } else if (window.MozWebSocket) {
13
+ // Firefox.
14
+ window.WebSocket = MozWebSocket;
15
+ return;
16
+ }
9
17
 
10
18
  var logger;
11
19
  if (window.WEB_SOCKET_LOGGER) {
@@ -30,14 +38,14 @@
30
38
  }
31
39
 
32
40
  /**
33
- * This class represents a faux web socket.
41
+ * Our own implementation of WebSocket class using Flash.
34
42
  * @param {string} url
35
43
  * @param {array or string} protocols
36
44
  * @param {string} proxyHost
37
45
  * @param {int} proxyPort
38
46
  * @param {string} headers
39
47
  */
40
- WebSocket = function(url, protocols, proxyHost, proxyPort, headers) {
48
+ window.WebSocket = function(url, protocols, proxyHost, proxyPort, headers) {
41
49
  var self = this;
42
50
  self.__id = WebSocket.__nextId++;
43
51
  WebSocket.__instances[self.__id] = self;
@@ -91,10 +99,10 @@
91
99
  */
92
100
  WebSocket.prototype.close = function() {
93
101
  if (this.__createTask) {
94
- clearTimeout(this.__createTask);
95
- this.__createTask = null;
96
- this.readyState = WebSocket.CLOSED;
97
- return;
102
+ clearTimeout(this.__createTask);
103
+ this.__createTask = null;
104
+ this.readyState = WebSocket.CLOSED;
105
+ return;
98
106
  }
99
107
  if (this.readyState == WebSocket.CLOSED || this.readyState == WebSocket.CLOSING) {
100
108
  return;
@@ -213,6 +221,7 @@
213
221
  WebSocket.CLOSING = 2;
214
222
  WebSocket.CLOSED = 3;
215
223
 
224
+ WebSocket.__initialized = false;
216
225
  WebSocket.__flash = null;
217
226
  WebSocket.__instances = {};
218
227
  WebSocket.__tasks = [];
@@ -232,7 +241,9 @@
232
241
  * Loads WebSocketMain.swf and creates WebSocketMain object in Flash.
233
242
  */
234
243
  WebSocket.__initialize = function() {
235
- if (WebSocket.__flash) return;
244
+
245
+ if (WebSocket.__initialized) return;
246
+ WebSocket.__initialized = true;
236
247
 
237
248
  if (WebSocket.__swfLocation) {
238
249
  // For backword compatibility.
@@ -290,7 +301,9 @@
290
301
  if (!e.success) {
291
302
  logger.error("[WebSocket] swfobject.embedSWF failed");
292
303
  }
293
- });
304
+ }
305
+ );
306
+
294
307
  };
295
308
 
296
309
  /**
@@ -365,15 +378,12 @@
365
378
  };
366
379
 
367
380
  if (!window.WEB_SOCKET_DISABLE_AUTO_INITIALIZATION) {
368
- if (window.addEventListener) {
369
- window.addEventListener("load", function(){
370
- WebSocket.__initialize();
371
- }, false);
372
- } else {
373
- window.attachEvent("onload", function(){
374
- WebSocket.__initialize();
375
- });
376
- }
381
+ // NOTE:
382
+ // This fires immediately if web_socket.js is dynamically loaded after
383
+ // the document is loaded.
384
+ swfobject.addDomLoadEvent(function() {
385
+ WebSocket.__initialize();
386
+ });
377
387
  }
378
388
 
379
389
  })();
Binary file
@@ -9,13 +9,15 @@ module Alondra
9
9
  def start_listening
10
10
  Log.info "Starting message queue"
11
11
 
12
- if @connection
13
- Log.warn 'Push connection to message queue started twice'
12
+ if @pull_socket || @push_socket
13
+ Log.warn 'Connections to message queue started twice'
14
14
  reset!
15
15
  end
16
-
17
- @connection = context.bind(ZMQ::SUB, Alondra.config.queue_socket, self)
18
- @connection.setsockopt ZMQ::SUBSCRIBE, '' # receive all
16
+
17
+ push_socket
18
+ pull_socket
19
+
20
+ self
19
21
  end
20
22
 
21
23
  def on_readable(socket, messages)
@@ -47,13 +49,30 @@ module Alondra
47
49
  def receive(event)
48
50
  event_router.process(event)
49
51
  end
52
+
53
+ def push_socket
54
+ @push_socket ||= begin
55
+ push_socket = context.socket(ZMQ::PUSH)
56
+ push_socket.connect(Alondra.config.queue_socket)
57
+ push_socket
58
+ end
59
+ end
60
+
61
+ def pull_socket
62
+ @pull_socket ||= begin
63
+ pull_socket = context.socket(ZMQ::PULL, self)
64
+ pull_socket.bind(Alondra.config.queue_socket)
65
+ pull_socket
66
+ end
67
+ end
50
68
 
51
69
  def reset!
52
- @connection.close_connection()
53
-
54
- @connection = nil
70
+ @push_socket.close()
71
+ @pull_socket.close()
72
+
55
73
  @context = nil
56
74
  @push_socket = nil
75
+ @pull_socket = nil
57
76
  end
58
77
 
59
78
  private
@@ -38,7 +38,11 @@ module Alondra
38
38
  end
39
39
 
40
40
  def push_socket
41
- @push_socket ||= context.connect(ZMQ::PUB, Alondra.config.queue_socket)
41
+ @push_socket ||= begin
42
+ push_socket = context.socket(ZMQ::PUSH)
43
+ push_socket.connect(Alondra.config.queue_socket)
44
+ push_socket
45
+ end
42
46
  end
43
47
 
44
48
  def context
@@ -58,7 +62,7 @@ module Alondra
58
62
 
59
63
  def push_socket
60
64
  @push_socket ||= begin
61
- socket = context.socket(ZMQ::PUB)
65
+ socket = context.socket(ZMQ::PUSH)
62
66
  socket.connect(Alondra.config.queue_socket)
63
67
  socket
64
68
  end
@@ -6,7 +6,8 @@ module Alondra
6
6
  include AbstractController::Helpers
7
7
  include AbstractController::Translation
8
8
  include AbstractController::AssetPaths
9
- include ActionController::RequestForgeryProtection
9
+
10
+ helper_method :protect_against_forgery?
10
11
 
11
12
  attr_accessor :channel_names
12
13
  attr_accessor :request
@@ -14,7 +15,7 @@ module Alondra
14
15
  def initialize(context, to, request = nil)
15
16
  @channel_names = Channel.names_for(to)
16
17
  @request = request
17
-
18
+
18
19
  self.class.view_paths = ActionController::Base.view_paths
19
20
  copy_instance_variables_from(context)
20
21
  end
@@ -37,11 +38,19 @@ module Alondra
37
38
  def view_paths
38
39
  @view_paths ||= ApplicationController.send '_view_paths'
39
40
  end
40
-
41
+
41
42
  def action_name
42
43
  'push'
43
44
  end
44
45
 
46
+ def protect_against_forgery?
47
+ false
48
+ end
49
+
50
+ def self.protect_against_forgery?
51
+ false
52
+ end
53
+
45
54
  private
46
55
 
47
56
  def copy_instance_variables_from(context)
@@ -0,0 +1,3 @@
1
+ module Alondra
2
+ VERSION = '0.1.0'
3
+ end
data/lib/alondra.rb CHANGED
@@ -18,7 +18,6 @@ require_relative 'alondra/changes_push'
18
18
  require_relative 'alondra/server'
19
19
 
20
20
  module Alondra
21
-
22
21
  ActiveRecord::Base.extend ChangesPush
23
22
  ActionController::Base.send :include, Pushing
24
23
 
@@ -58,11 +57,9 @@ module Alondra
58
57
  end
59
58
 
60
59
  def self.start_server!
61
-
62
60
  start_server_proc = Proc.new do
63
61
  MessageQueue.instance.start_listening
64
62
  Server.run
65
- die_gracefully_on_signal
66
63
  end
67
64
 
68
65
  if EM.reactor_running?
@@ -72,18 +69,6 @@ module Alondra
72
69
  EM.run(start_server_proc)
73
70
  end
74
71
  end
75
-
76
- def self.die_gracefully_on_signal
77
- Signal.trap("INT") do
78
- Log.warn "INT signal trapped. Shutting down EM reactor"
79
- EM.stop
80
- end
81
-
82
- Signal.trap("TERM") do
83
- Log.warn "TERM signal trapped. Shutting down EM reactor"
84
- EM.stop
85
- end
86
- end
87
72
  end
88
73
  end
89
74
 
@@ -36,7 +36,7 @@
36
36
  <%= javascript_include_tag 'alondra-client' %>
37
37
 
38
38
  <script type="text/javascript">
39
- var client = new AlondraClient('localhost:<%= Alondra::Alondra.config.port %>', '<%= chat_path(@path) %>', '<%= encrypted_token %>');
39
+ var client = new AlondraClient('localhost:<%= Alondra::Alondra.config.port %>', '<%= chat_path(@chat) %>', '<%= encrypted_token %>');
40
40
 
41
41
  $(client).bind('subscribed.Chat', function(event, resource){
42
42
  console.log('Received subscribed event!');
@@ -16,8 +16,8 @@ module Alondra
16
16
 
17
17
  test "push chat changes to client" do
18
18
 
19
- user = Factory.create :user
20
- chat = Factory.create :chat, :name => 'A chat about nothing'
19
+ user = FactoryGirl.create :user
20
+ chat = FactoryGirl.create :chat, :name => 'A chat about nothing'
21
21
 
22
22
  login_as user
23
23
 
@@ -16,10 +16,10 @@ module Alondra
16
16
  test "execute messages in client" do
17
17
  self.extend Pushing
18
18
 
19
- @user = Factory.create :user
19
+ @user = FactoryGirl.create :user
20
20
  @text = 'hola!'
21
21
 
22
- chat = Factory.create :chat, :name => 'A chat to receive messages'
22
+ chat = FactoryGirl.create :chat, :name => 'A chat to receive messages'
23
23
 
24
24
  login_as @user
25
25
 
@@ -171,7 +171,7 @@ module Alondra
171
171
  session = {:user_id => 30 }
172
172
  connection = MockConnection.new(session)
173
173
 
174
- chat = Factory.create :chat
174
+ chat = FactoryGirl.create :chat
175
175
 
176
176
  chat_channel = "/chats/#{chat.id}"
177
177
 
@@ -17,28 +17,28 @@ module Alondra
17
17
  MessageQueue.instance.instance_variable_set :@event_router, @original_event_router
18
18
  end
19
19
 
20
- test "a message pushed asynchronously to the queue is received by the event router" do
21
- assert MessageQueueClient.instance.class == AsyncMessageQueueClient
22
-
23
- MessageQueueClient.push @event
24
-
25
- sleep(0.1)
26
-
27
- assert received(@event)
28
- end
29
-
30
- test "a message pushed synchronously to the queue is received by the event router" do
31
-
32
- client = MessageQueueClient.sync_instance
33
- context = client.send :context
34
- assert context.class == ZMQ::Context
35
-
36
- client.send_message(@event)
37
-
38
- sleep(0.1)
39
-
40
- assert received(@event)
41
- end
20
+ # test "a message pushed asynchronously to the queue is received by the event router" do
21
+ # assert MessageQueueClient.instance.class == AsyncMessageQueueClient
22
+ #
23
+ # MessageQueueClient.push @event
24
+ #
25
+ # sleep(0.1)
26
+ #
27
+ # assert received(@event)
28
+ # end
29
+ #
30
+ # test "a message pushed synchronously to the queue is received by the event router" do
31
+ #
32
+ # client = MessageQueueClient.sync_instance
33
+ # context = client.send :context
34
+ # assert context.class == ZMQ::Context
35
+ #
36
+ # client.send_message(@event)
37
+ #
38
+ # sleep(0.1)
39
+ #
40
+ # assert received(@event)
41
+ # end
42
42
 
43
43
  test "message queue still works when an exception is thrown while processing an event" do
44
44
  3.times do
@@ -5,7 +5,7 @@ module Alondra
5
5
  class PushingTest < ActiveSupport::TestCase
6
6
 
7
7
  test "publish created events to the specified channel" do
8
- chat = Factory.create :chat
8
+ chat = FactoryGirl.create :chat
9
9
  connection = MockConnection.new
10
10
  message = chat.messages.build(:text => 'test message')
11
11
 
@@ -1,19 +1,21 @@
1
- Factory.define :chat do |f|
2
- f.name 'Test chat'
3
- end
1
+ FactoryGirl.define do
2
+ factory :chat do
3
+ name 'Test chat'
4
+ end
4
5
 
5
- Factory.define :message do |f|
6
- f.association :chat
7
- f.text 'Test message'
8
- end
6
+ factory :message do
7
+ association :chat
8
+ text 'Test message'
9
+ end
9
10
 
10
- Factory.sequence :username do |i|
11
- "user#{i}"
12
- end
11
+ sequence :username do |i|
12
+ "user#{i}"
13
+ end
13
14
 
14
- Factory.define :user do |f|
15
- f.username { Factory.next(:username) }
16
- f.email { |u| "#{u.username}@example.com" }
17
- f.password 'secret'
18
- f.password_confirmation 'secret'
15
+ factory :user do
16
+ username { FactoryGirl.generate(:username) }
17
+ email { |u| "#{u.username}@example.com" }
18
+ password 'secret'
19
+ password_confirmation 'secret'
20
+ end
19
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alondra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-03-27 00:00:00.000000000 Z
13
+ date: 2012-08-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: daemons
@@ -83,7 +83,7 @@ dependencies:
83
83
  requirements:
84
84
  - - '='
85
85
  - !ruby/object:Gem::Version
86
- version: 0.2.2
86
+ version: 0.3.0
87
87
  type: :runtime
88
88
  prerelease: false
89
89
  version_requirements: !ruby/object:Gem::Requirement
@@ -91,7 +91,7 @@ dependencies:
91
91
  requirements:
92
92
  - - '='
93
93
  - !ruby/object:Gem::Version
94
- version: 0.2.2
94
+ version: 0.3.0
95
95
  description: Add real time capabilities to your rails app
96
96
  email:
97
97
  executables: []
@@ -132,6 +132,7 @@ files:
132
132
  - lib/alondra/pushing.rb
133
133
  - lib/alondra/server.rb
134
134
  - lib/alondra/session_parser.rb
135
+ - lib/alondra/version.rb
135
136
  - lib/generators/alondra/USAGE
136
137
  - lib/generators/alondra/alondra_generator.rb
137
138
  - lib/generators/alondra/templates/alondra
@@ -227,15 +228,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
227
228
  - - ! '>='
228
229
  - !ruby/object:Gem::Version
229
230
  version: '0'
231
+ segments:
232
+ - 0
233
+ hash: 3172633701329526512
230
234
  required_rubygems_version: !ruby/object:Gem::Requirement
231
235
  none: false
232
236
  requirements:
233
237
  - - ! '>='
234
238
  - !ruby/object:Gem::Version
235
239
  version: '0'
240
+ segments:
241
+ - 0
242
+ hash: 3172633701329526512
236
243
  requirements: []
237
244
  rubyforge_project:
238
- rubygems_version: 1.8.21
245
+ rubygems_version: 1.8.23
239
246
  signing_key:
240
247
  specification_version: 3
241
248
  summary: Add real time capabilities to your rails app
@@ -318,4 +325,3 @@ test_files:
318
325
  - test/support/mocks/mock_event_router.rb
319
326
  - test/support/mocks/mock_listener.rb
320
327
  - test/test_helper.rb
321
- has_rdoc: