Skip to content

Commit

Permalink
fix client
Browse files Browse the repository at this point in the history
  • Loading branch information
maccman committed Sep 3, 2010
1 parent eab44cd commit 9da5c15
Show file tree
Hide file tree
Showing 9 changed files with 163 additions and 0 deletions.
5 changes: 5 additions & 0 deletions client/.document
@@ -0,0 +1,5 @@
README.rdoc
lib/**/*.rb
bin/*
features/**/*.feature
LICENSE
21 changes: 21 additions & 0 deletions client/.gitignore
@@ -0,0 +1,21 @@
## MAC OS
.DS_Store

## TEXTMATE
*.tmproj
tmtags

## EMACS
*~
\#*
.\#*

## VIM
*.swp

## PROJECT::GENERAL
coverage
rdoc
pkg

## PROJECT::SPECIFIC
20 changes: 20 additions & 0 deletions client/LICENSE
@@ -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.
7 changes: 7 additions & 0 deletions client/README
@@ -0,0 +1,7 @@
= Juggernaut

Description goes here.

== Copyright

Copyright (c) 2010 Alex MacCaw. See LICENSE for details.
18 changes: 18 additions & 0 deletions client/Rakefile
@@ -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
1 change: 1 addition & 0 deletions client/VERSION
@@ -0,0 +1 @@
2.0.0
23 changes: 23 additions & 0 deletions client/examples/model_observer.rb
@@ -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
49 changes: 49 additions & 0 deletions client/juggernaut.gemspec
@@ -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

19 changes: 19 additions & 0 deletions client/lib/juggernaut.rb
@@ -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.