juggernaut 2.0.0.beta1 → 2.0.0.beta2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +3 -2
- data/VERSION +1 -1
- data/examples/juggernaut_observer.js +22 -0
- data/examples/juggernaut_observer.rb +24 -0
- data/juggernaut.gemspec +4 -3
- data/lib/juggernaut.rb +2 -2
- metadata +5 -4
- data/LICENSE +0 -20
data/README
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
= Juggernaut
|
2
2
|
|
3
|
-
|
3
|
+
See http://github.com/maccman/juggernaut
|
4
4
|
|
5
5
|
== Copyright
|
6
6
|
|
7
|
-
Copyright (c) 2010 Alex MacCaw.
|
7
|
+
Copyright (c) 2010 Alex MacCaw.
|
8
|
+
See http://github.com/maccman/juggernaut/blob/master/LICENSE for details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.0.
|
1
|
+
2.0.0.beta2
|
@@ -0,0 +1,22 @@
|
|
1
|
+
// Assumes you're using SuperModel
|
2
|
+
// http://github.com/maccman/supermodel-js
|
3
|
+
|
4
|
+
jQuery(function($){
|
5
|
+
var jug = new Juggernaut;
|
6
|
+
jug.subscribe("/sync/your_user_id", function(sync){
|
7
|
+
var klass = eval(sync.klass);
|
8
|
+
switch(sync.type) {
|
9
|
+
case "create":
|
10
|
+
klass.create(sync.record);
|
11
|
+
break;
|
12
|
+
case "update":
|
13
|
+
klass.update(sync.id, sync.record);
|
14
|
+
break;
|
15
|
+
case "destroy":
|
16
|
+
klass.destroy(sync.id);
|
17
|
+
break;
|
18
|
+
default:
|
19
|
+
throw("Unknown type:" + type);
|
20
|
+
}
|
21
|
+
});
|
22
|
+
})
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class JuggernautObserver < ActiveRecord::Observer
|
2
|
+
observe :activity, :user
|
3
|
+
|
4
|
+
def after_create(rec)
|
5
|
+
publish(:create, rec)
|
6
|
+
end
|
7
|
+
|
8
|
+
def after_update(rec)
|
9
|
+
publish(:update, rec)
|
10
|
+
end
|
11
|
+
|
12
|
+
def after_destroy(rec)
|
13
|
+
publish(:destroy, rec)
|
14
|
+
end
|
15
|
+
|
16
|
+
protected
|
17
|
+
def publish(type, rec)
|
18
|
+
Juggernaut.publish(
|
19
|
+
Array(rec.sync_clients).map {|c| "/sync/#{c}" },
|
20
|
+
{:type => type, :id => rec.id,
|
21
|
+
:klass => rec.class.name, :record => rec}
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
data/juggernaut.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{juggernaut}
|
8
|
-
s.version = "2.0.0.
|
8
|
+
s.version = "2.0.0.beta2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Alex MacCaw"]
|
12
|
-
s.date = %q{2010-09-
|
12
|
+
s.date = %q{2010-09-10}
|
13
13
|
s.description = %q{Use Juggernaut to easily implement realtime chat, collaboration, gaming and much more!}
|
14
14
|
s.email = %q{info@eribium.org}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -18,10 +18,11 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.files = [
|
19
19
|
".document",
|
20
20
|
".gitignore",
|
21
|
-
"LICENSE",
|
22
21
|
"README",
|
23
22
|
"Rakefile",
|
24
23
|
"VERSION",
|
24
|
+
"examples/juggernaut_observer.js",
|
25
|
+
"examples/juggernaut_observer.rb",
|
25
26
|
"juggernaut.gemspec",
|
26
27
|
"lib/juggernaut.rb"
|
27
28
|
]
|
data/lib/juggernaut.rb
CHANGED
@@ -10,8 +10,8 @@ module Juggernaut
|
|
10
10
|
@redis = val
|
11
11
|
end
|
12
12
|
|
13
|
-
def publish(channels, data)
|
14
|
-
message = {:channels => Array(channels), :data => data}
|
13
|
+
def publish(channels, data, options = {})
|
14
|
+
message = ({:channels => Array(channels), :data => data}).merge(options)
|
15
15
|
redis.publish(:juggernaut, message.to_json)
|
16
16
|
end
|
17
17
|
|
metadata
CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
|
|
6
6
|
- 2
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 2.0.0.
|
9
|
+
- beta2
|
10
|
+
version: 2.0.0.beta2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alex MacCaw
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-09-
|
18
|
+
date: 2010-09-10 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -42,10 +42,11 @@ extra_rdoc_files:
|
|
42
42
|
files:
|
43
43
|
- .document
|
44
44
|
- .gitignore
|
45
|
-
- LICENSE
|
46
45
|
- README
|
47
46
|
- Rakefile
|
48
47
|
- VERSION
|
48
|
+
- examples/juggernaut_observer.js
|
49
|
+
- examples/juggernaut_observer.rb
|
49
50
|
- juggernaut.gemspec
|
50
51
|
- lib/juggernaut.rb
|
51
52
|
has_rdoc: true
|
data/LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2010 Alexander MacCaw
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|