sinatra-cometio 0.3.8 → 0.3.9

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.3.9 2013-03-21
2
+
3
+ * emit "error" on push before connect
4
+
1
5
  === 0.3.8 2013-03-19
2
6
 
3
7
  * bugfix gem dependencies
data/lib/js/cometio.js CHANGED
@@ -6,6 +6,10 @@ var CometIO = function(){
6
6
  var self = this;
7
7
 
8
8
  this.push = function(type, data){
9
+ if(!self.session){
10
+ self.emit("error", "CometIO not connected");
11
+ return;
12
+ }
9
13
  $.ajax(
10
14
  {
11
15
  url : self.url,
@@ -1,4 +1,4 @@
1
- // event_emitter.js v0.0.7
1
+ // event_emitter.js v0.0.8
2
2
  // https://github.com/shokai/event_emitter.js
3
3
  // (c) 2013 Sho Hashimoto <hashimoto@shokai.org>
4
4
  // The MIT License
@@ -38,13 +38,15 @@ var EventEmitter = function(){
38
38
  switch(e.type){
39
39
  case type:
40
40
  e.listener(data);
41
+ if(e.once) e.type = null;
41
42
  break
42
- case '*':
43
+ case "*":
43
44
  e.listener(type, data);
45
+ if(e.once) e.type = null;
44
46
  break
45
47
  }
46
- if(e.once) self.removeListener(e.id);
47
48
  }
49
+ self.removeListener();
48
50
  };
49
51
 
50
52
  this.removeListener = function(id_or_type){
@@ -52,10 +54,11 @@ var EventEmitter = function(){
52
54
  var e = self.__events[i];
53
55
  switch(typeof id_or_type){
54
56
  case "number":
55
- if(e.id == id_or_type) self.__events.splice(i,1);
57
+ if(e.id === id_or_type) self.__events.splice(i,1);
56
58
  break
57
59
  case "string":
58
- if(e.type == id_or_type) self.__events.splice(i,1);
60
+ case "object":
61
+ if(e.type === id_or_type) self.__events.splice(i,1);
59
62
  break
60
63
  }
61
64
  }
@@ -63,6 +66,6 @@ var EventEmitter = function(){
63
66
 
64
67
  };
65
68
 
66
- if(typeof module !== 'undefined' && typeof module.exports !== 'undefined'){
69
+ if(typeof module !== "undefined" && typeof module.exports !== "undefined"){
67
70
  module.exports = EventEmitter;
68
71
  }
@@ -41,9 +41,10 @@ module Sinatra
41
41
  end
42
42
 
43
43
  app.post '/cometio/io' do
44
+ from = params[:session]
45
+ halt 400, 'no session' if from.empty?
44
46
  type = params[:type]
45
47
  data = params[:data]
46
- from = params[:session]
47
48
  EM::defer do
48
49
  CometIO.emit type, data, from unless type.to_s.empty?
49
50
  end
@@ -1,5 +1,5 @@
1
1
  module Sinatra
2
2
  module CometIO
3
- VERSION = '0.3.8'
3
+ VERSION = '0.3.9'
4
4
  end
5
5
  end
data/sample/Gemfile.lock CHANGED
@@ -3,11 +3,11 @@ GEM
3
3
  specs:
4
4
  backports (3.1.1)
5
5
  daemons (1.1.9)
6
- event_emitter (0.2.3)
6
+ event_emitter (0.2.4)
7
7
  eventmachine (1.0.3)
8
8
  foreman (0.62.0)
9
9
  thor (>= 0.13.6)
10
- haml (4.0.0)
10
+ haml (4.0.1)
11
11
  tilt
12
12
  httparty (0.10.2)
13
13
  multi_json (~> 1.0)
@@ -20,6 +20,6 @@ Gem::Specification.new do |gem|
20
20
  gem.add_dependency 'sinatra', '>= 1.3.0'
21
21
  gem.add_dependency 'eventmachine', '>= 1.0.0'
22
22
  gem.add_dependency 'json', '>= 1.7.0'
23
- gem.add_dependency 'event_emitter', '~> 0.2'
23
+ gem.add_dependency 'event_emitter', '>= 0.2.4'
24
24
  gem.add_dependency 'httparty', '>= 0.10.2'
25
25
  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.3.8
4
+ version: 0.3.9
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-19 00:00:00.000000000 Z
12
+ date: 2013-03-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra-contrib
@@ -80,17 +80,17 @@ dependencies:
80
80
  requirement: !ruby/object:Gem::Requirement
81
81
  none: false
82
82
  requirements:
83
- - - ~>
83
+ - - ! '>='
84
84
  - !ruby/object:Gem::Version
85
- version: '0.2'
85
+ version: 0.2.4
86
86
  type: :runtime
87
87
  prerelease: false
88
88
  version_requirements: !ruby/object:Gem::Requirement
89
89
  none: false
90
90
  requirements:
91
- - - ~>
91
+ - - ! '>='
92
92
  - !ruby/object:Gem::Version
93
- version: '0.2'
93
+ version: 0.2.4
94
94
  - !ruby/object:Gem::Dependency
95
95
  name: httparty
96
96
  requirement: !ruby/object:Gem::Requirement