sinatra-cometio 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.4.2 2013-03-26
2
+
3
+ * refactor Sinatra::CometIO::push
4
+
1
5
  === 0.4.1 2013-03-24
2
6
 
3
7
  * Sinatra::CometIO::Client#timeout = 120
@@ -27,10 +27,8 @@ module Sinatra
27
27
  end
28
28
 
29
29
  def self.push(type, data, opt={})
30
- session_ids = opt[:to].to_s.empty? ? self.sessions.keys : [opt[:to]]
31
- session_ids.each do |id|
32
- next unless self.sessions.include? id
33
- s = self.sessions[id]
30
+ if opt.include? :to and self.sessions.include? opt[:to]
31
+ s = self.sessions[opt[:to]]
34
32
  if s[:queue].empty? and s[:stream] != nil
35
33
  begin
36
34
  s[:stream].write([{:type => type, :data => data}].to_json)
@@ -43,6 +41,10 @@ module Sinatra
43
41
  else
44
42
  s[:queue].push :type => type, :data => data
45
43
  end
44
+ else
45
+ self.sessions.keys.each do |id|
46
+ push type, data, :to => id
47
+ end
46
48
  end
47
49
  end
48
50
 
@@ -1,5 +1,5 @@
1
1
  module Sinatra
2
2
  module CometIO
3
- VERSION = '0.4.1'
3
+ VERSION = '0.4.2'
4
4
  end
5
5
  end
data/sample/README.md CHANGED
@@ -8,7 +8,7 @@ Comet Chat
8
8
  Install Dependencies
9
9
  --------------------
10
10
 
11
- % gem install bundler foreman
11
+ % gem install bundler
12
12
  % bundle install
13
13
 
14
14
 
data/test/test_cometio.rb CHANGED
@@ -22,7 +22,7 @@ class TestCometio < MiniTest::Unit::TestCase
22
22
  push :broadcast, post_data
23
23
  end
24
24
 
25
- 30.times do
25
+ 50.times do
26
26
  break if res != nil
27
27
  sleep 0.1
28
28
  end
@@ -56,7 +56,7 @@ class TestCometio < MiniTest::Unit::TestCase
56
56
  end
57
57
  end
58
58
 
59
- 30.times do
59
+ 50.times do
60
60
  break if res != nil
61
61
  sleep 0.1
62
62
  end
@@ -89,7 +89,7 @@ class TestCometio < MiniTest::Unit::TestCase
89
89
  end
90
90
  end
91
91
 
92
- 30.times do
92
+ 50.times do
93
93
  break if res != nil
94
94
  sleep 0.1
95
95
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-cometio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-23 00:00:00.000000000 Z
12
+ date: 2013-03-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -255,7 +255,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
255
255
  version: '0'
256
256
  segments:
257
257
  - 0
258
- hash: -3631185313350720463
258
+ hash: -2773657054308243354
259
259
  required_rubygems_version: !ruby/object:Gem::Requirement
260
260
  none: false
261
261
  requirements:
@@ -264,7 +264,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
264
264
  version: '0'
265
265
  segments:
266
266
  - 0
267
- hash: -3631185313350720463
267
+ hash: -2773657054308243354
268
268
  requirements: []
269
269
  rubyforge_project:
270
270
  rubygems_version: 1.8.24