meerkat 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/examples/app.rb CHANGED
@@ -7,7 +7,6 @@ class App < Sinatra::Base
7
7
  end
8
8
 
9
9
  post '/' do
10
- puts params
11
10
  Meerkat.publish params[:topic], params[:message]
12
11
  204
13
12
  end
data/examples/config.ru CHANGED
@@ -3,8 +3,8 @@ require 'meerkat'
3
3
  require './app'
4
4
 
5
5
  #Meerkat.backend = Meerkat::Backend::InMemory.new
6
- #Meerkat.backend = Meerkat::Backend::Redis.new
7
- Meerkat.backend = Meerkat::Backend::PG.new :dbname => 'postgres'
6
+ Meerkat.backend = Meerkat::Backend::Redis.new
7
+ #Meerkat.backend = Meerkat::Backend::PG.new :dbname => 'postgres'
8
8
  map '/' do
9
9
  run App
10
10
  end
@@ -1,52 +1,52 @@
1
1
  !!!
2
- %head
3
- %title Meerkat test
4
- %script{:src=>'https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js', :type => 'text/javascript'}
5
- %body
6
- %fieldset
7
- %legend Publish
8
- %form#pub{:method => :post}
9
- %label
10
- Topic:
11
- %input{:name => 'topic', :value => 'foo'}
12
- %label
13
- Message:
14
- %input{:name => 'message'}
15
- %input{:type => 'submit', :value => 'Send'}
2
+ %html
3
+ %head
4
+ %title Meerkat test
5
+ %script{:src=>'https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js', :type => 'text/javascript'}
6
+ %body
7
+ %fieldset
8
+ %legend Publish
9
+ %form#pub{:method => :post}
10
+ %label
11
+ Topic:
12
+ %input{:name => 'topic', :value => 'foo'}
13
+ %label
14
+ Message:
15
+ %input{:name => 'message'}
16
+ %input{:type => 'submit', :value => 'Send'}
16
17
 
17
- %fieldset
18
- %legend Subscribe
19
- %label
20
- Subscribe to
21
- %input#sub_topic{:name => 'topic', :value => 'foo'}
22
- %input#start_subscribe{:type => 'submit', :value => 'Start!'}
18
+ %fieldset
19
+ %legend Subscribe
20
+ %label
21
+ Subscribe to
22
+ %input#sub_topic{:name => 'topic', :value => 'foo'}
23
+ %input#start_subscribe{:type => 'submit', :value => 'Start!'}
23
24
 
24
- %ul#stream
25
+ %ul#stream
25
26
 
26
- :javascript
27
- var source;
28
- function subscribe_to(topic) {
29
- if (source != null) { source.close() }
30
- source = new EventSource('/stream/' + topic)
31
- var stream = document.getElementById('stream')
32
- source.onmessage = function(e) {
33
- console.log(e)
34
- var li = document.createElement('li')
35
- li.innerHTML = JSON.parse(e.data)
36
- stream.appendChild(li)
27
+ :javascript
28
+ var source;
29
+ function subscribe_to(topic) {
30
+ if (source != null) { source.close() }
31
+ source = new EventSource('/stream/' + topic)
32
+ var stream = document.getElementById('stream')
33
+ source.onmessage = function(e) {
34
+ var li = document.createElement('li')
35
+ li.innerHTML = JSON.parse(e.data)
36
+ stream.appendChild(li)
37
+ }
37
38
  }
38
- }
39
39
 
40
- $(function() {
41
- $("#pub").submit(function() {
42
- $.post(this.action, $(this).serialize())
43
- return false
44
- });
40
+ $(function() {
41
+ $("#pub").submit(function() {
42
+ $.post(this.action, $(this).serialize())
43
+ return false
44
+ });
45
45
 
46
- $("#start_subscribe").click(function() {
47
- subscribe_to($("#sub_topic").val())
48
- return false
49
- });
46
+ $("#start_subscribe").click(function() {
47
+ subscribe_to($("#sub_topic").val())
48
+ return false
49
+ });
50
50
 
51
- subscribe_to($("#sub_topic").val())
52
- })
51
+ subscribe_to($("#sub_topic").val())
52
+ })
@@ -8,6 +8,9 @@ module Meerkat
8
8
  EM.next_tick do
9
9
  @sub = EM::Hiredis.connect redis_uri
10
10
  @pub = EM::Hiredis.connect redis_uri
11
+ @sub.on :pmessage do |topic, channel, message|
12
+ @subs[topic].each { |cb| cb.call channel, message }
13
+ end
11
14
  end
12
15
  end
13
16
 
@@ -22,9 +25,6 @@ module Meerkat
22
25
  @subs[topic] = [ callback ]
23
26
  EM.next_tick do
24
27
  @sub.psubscribe topic
25
- @sub.on :pmessage do |topic, channel, message|
26
- @subs[topic].each { |cb| cb.call channel, message }
27
- end
28
28
  end
29
29
  end
30
30
  [topic, callback]
@@ -25,7 +25,7 @@ module Meerkat
25
25
 
26
26
  path_info = Rack::Utils.unescape env["PATH_INFO"]
27
27
  sub = Meerkat.subscribe(path_info) do |topic, json|
28
- body << "event: #{topic}\n"
28
+ body << "event: #{topic}\n" unless path_info == topic
29
29
  body << "data: #{json}\n\n"
30
30
  end
31
31
  body.errback do
@@ -1,3 +1,3 @@
1
1
  module Meerkat
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meerkat
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,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-26 00:00:00.000000000Z
12
+ date: 2011-10-27 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
16
- requirement: &70352680163120 !ruby/object:Gem::Requirement
16
+ requirement: &70174238921400 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70352680163120
24
+ version_requirements: *70174238921400
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rack-test
27
- requirement: &70352680162700 !ruby/object:Gem::Requirement
27
+ requirement: &70174238920780 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70352680162700
35
+ version_requirements: *70174238920780
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: thin_async
38
- requirement: &70352680162280 !ruby/object:Gem::Requirement
38
+ requirement: &70174238920140 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70352680162280
46
+ version_requirements: *70174238920140
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: thin-async-test
49
- requirement: &70352680161860 !ruby/object:Gem::Requirement
49
+ requirement: &70174238919320 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70352680161860
57
+ version_requirements: *70174238919320
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: em-minitest-spec
60
- requirement: &70352680161420 !ruby/object:Gem::Requirement
60
+ requirement: &70174238918880 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70352680161420
68
+ version_requirements: *70174238918880
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: yajl-ruby
71
- requirement: &70352680160960 !ruby/object:Gem::Requirement
71
+ requirement: &70174238918400 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70352680160960
79
+ version_requirements: *70174238918400
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: eventmachine
82
- requirement: &70352680160440 !ruby/object:Gem::Requirement
82
+ requirement: &70174238914700 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *70352680160440
90
+ version_requirements: *70174238914700
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: em-hiredis
93
- requirement: &70352680159960 !ruby/object:Gem::Requirement
93
+ requirement: &70174238914060 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :runtime
100
100
  prerelease: false
101
- version_requirements: *70352680159960
101
+ version_requirements: *70174238914060
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: pg
104
- requirement: &70352680159360 !ruby/object:Gem::Requirement
104
+ requirement: &70174238913360 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,7 +109,7 @@ dependencies:
109
109
  version: '0'
110
110
  type: :runtime
111
111
  prerelease: false
112
- version_requirements: *70352680159360
112
+ version_requirements: *70174238913360
113
113
  description: Requires an evented Ruby dispatcher, like Thin
114
114
  email:
115
115
  - carl.hoerberg@gmail.com
@@ -151,7 +151,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
151
151
  version: '0'
152
152
  segments:
153
153
  - 0
154
- hash: 3801501159995886278
154
+ hash: 2628710167676549953
155
155
  required_rubygems_version: !ruby/object:Gem::Requirement
156
156
  none: false
157
157
  requirements:
@@ -160,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
160
160
  version: '0'
161
161
  segments:
162
162
  - 0
163
- hash: 3801501159995886278
163
+ hash: 2628710167676549953
164
164
  requirements: []
165
165
  rubyforge_project: meerkat
166
166
  rubygems_version: 1.8.6