Permalink
Browse files

fix client

  • Loading branch information...
1 parent eab44cd commit 9da5c15fcfd56f279921f8c90a380dcb31c11793 @maccman committed Sep 3, 2010
Showing with 163 additions and 0 deletions.
  1. +5 −0 client/.document
  2. +21 −0 client/.gitignore
  3. +20 −0 client/LICENSE
  4. +7 −0 client/README
  5. +18 −0 client/Rakefile
  6. +1 −0 client/VERSION
  7. +23 −0 client/examples/model_observer.rb
  8. +49 −0 client/juggernaut.gemspec
  9. +19 −0 client/lib/juggernaut.rb
View
@@ -0,0 +1,5 @@
+README.rdoc
+lib/**/*.rb
+bin/*
+features/**/*.feature
+LICENSE
View
@@ -0,0 +1,21 @@
+## MAC OS
+.DS_Store
+
+## TEXTMATE
+*.tmproj
+tmtags
+
+## EMACS
+*~
+\#*
+.\#*
+
+## VIM
+*.swp
+
+## PROJECT::GENERAL
+coverage
+rdoc
+pkg
+
+## PROJECT::SPECIFIC
View
@@ -0,0 +1,20 @@
+Copyright (c) 2010 Alexander MacCaw
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
@@ -0,0 +1,7 @@
+= Juggernaut
+
+Description goes here.
+
+== Copyright
+
+Copyright (c) 2010 Alex MacCaw. See LICENSE for details.
View
@@ -0,0 +1,18 @@
+require 'rubygems'
+require 'rake'
+
+begin
+ require 'jeweler'
+ Jeweler::Tasks.new do |gem|
+ gem.name = "juggernaut"
+ gem.summary = %Q{Simple realtime push}
+ gem.description = %Q{Use Juggernaut to easily implement realtime chat, collaboration, gaming and much more!}
+ gem.email = "info@eribium.org"
+ gem.homepage = "http://github.com/maccman/juggernaut"
+ gem.authors = ["Alex MacCaw"]
+ gem.add_dependency "redis", ">= 0"
+ end
+ Jeweler::GemcutterTasks.new
+rescue LoadError
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
+end
View
@@ -0,0 +1 @@
+2.0.0
@@ -0,0 +1,23 @@
+class ModelObserver < ActiveRecord::Observer
+ observe :activity
+
+ def after_create(rec)
+ publish(:create, rec)
+ end
+
+ def after_update(rec)
+ publish(:update, rec)
+ end
+
+ def after_destroy(rec)
+ publish(:destroy, rec)
+ end
+
+ protected
+ def publish(type, rec)
+ Juggernaut.publish(
+ Array(rec.sync_clients).map {|c| "sync/#{c}" },
+ {:type => type, :id => rec.id, :record => rec}
+ )
+ end
+end
View
@@ -0,0 +1,49 @@
+# Generated by jeweler
+# DO NOT EDIT THIS FILE DIRECTLY
+# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = %q{juggernaut}
+ s.version = "2.0.0"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.authors = ["Alex MacCaw"]
+ s.date = %q{2010-09-03}
+ s.description = %q{Use Juggernaut to easily implement realtime chat, collaboration, gaming and much more!}
+ s.email = %q{info@eribium.org}
+ s.extra_rdoc_files = [
+ "LICENSE",
+ "README"
+ ]
+ s.files = [
+ ".document",
+ ".gitignore",
+ "LICENSE",
+ "Rakefile",
+ "VERSION",
+ "lib/juggernaut.rb"
+ ]
+ s.homepage = %q{http://github.com/maccman/juggernaut}
+ s.rdoc_options = ["--charset=UTF-8"]
+ s.require_paths = ["lib"]
+ s.rubygems_version = %q{1.3.7}
+ s.summary = %q{Simple realtime push}
+ s.test_files = [
+ "examples/model_observer.rb"
+ ]
+
+ if s.respond_to? :specification_version then
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
+ s.specification_version = 3
+
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
+ s.add_runtime_dependency(%q<redis>, [">= 0"])
+ else
+ s.add_dependency(%q<redis>, [">= 0"])
+ end
+ else
+ s.add_dependency(%q<redis>, [">= 0"])
+ end
+end
+
View
@@ -0,0 +1,19 @@
+require "redis"
+require "json"
+
+module Juggernaut
+ def redis
+ @redis ||= Redis.new
+ end
+
+ def redis=(val)
+ @redis = val
+ end
+
+ def publish(channels, data)
+ message = {:channels => Array(channels), :data => data}
+ redis.publish(:juggernaut, message.to_json)
+ end
+
+ extend self
+end

0 comments on commit 9da5c15

Please sign in to comment.