Skip to content

Commit

Permalink
renaming due to jack name conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
dj2 committed Oct 8, 2009
1 parent cf0dd84 commit 6edbe0e
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 93 deletions.
4 changes: 2 additions & 2 deletions README.rdoc
@@ -1,4 +1,4 @@
= Jack
= EMJack
An attempt to wrap portions of the Beanstalk protocol with EventMachine. Every command
will return a deferrable object. That object will succeed or fail depending on the
reply returned from Beanstalk.
Expand All @@ -18,7 +18,7 @@ are no available jobs.

= Examples
EM.run {
jack = Jack::Connection.new
jack = EMJack::Connection.new

r = jack.use('mytube')
r.callback { |tube| puts "Using #{tube}" }
Expand Down
6 changes: 3 additions & 3 deletions Rakefile
Expand Up @@ -2,15 +2,15 @@ require 'rake'
require 'rake/rdoctask'
require 'rake/gempackagetask'

spec = eval(File.read(File.join(File.dirname(__FILE__), "jack.gemspec")))
spec = eval(File.read(File.join(File.dirname(__FILE__), "em-jack.gemspec")))

task :default => :gem

desc 'Generate RDoc documentation for Jack'
desc 'Generate RDoc documentation for EMJack'
Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_files.include('README.rdoc', 'COPYING', 'lib/**/*.rb')
rdoc.main = 'README.rdoc'
rdoc.title = 'Jack Documentation'
rdoc.title = 'EM Jack Documentation'

rdoc.rdoc_dir = 'doc'
rdoc.options << '--line-numbers'
Expand Down
12 changes: 6 additions & 6 deletions jack.gemspec → em-jack.gemspec
@@ -1,9 +1,9 @@
Gem::Specification.new do |s|
s.name = %q{jack}
s.version = "0.0.2"
s.name = %q{em-jack}
s.version = "0.0.3"
s.authors = ["dan sinclair"]
s.email = %q{dj2@everburning.com}
s.homepage = %q{http://http://github.com/dj2/jack/}
s.homepage = %q{http://http://github.com/dj2/em-jack/}

s.summary = %q{An evented Beanstalk client.}
s.description = %q{An evented Beanstalk client.}
Expand All @@ -12,10 +12,10 @@ Gem::Specification.new do |s|

s.has_rdoc = true
s.extra_rdoc_files = ['README.rdoc']
s.rdoc_options << '--title' << 'Jack Documentation' <<
s.rdoc_options << '--title' << 'EM-Jack Documentation' <<
'--main' << 'README.rdoc' <<
'--line-numbers'

s.files = %w(README.rdoc COPYING lib/jack.rb lib/jack/beanstalk_connection.rb
lib/jack/connection.rb lib/jack/errors.rb lib/jack/job.rb)
s.files = %w(README.rdoc COPYING lib/em-jack.rb lib/em-jack/beanstalk_connection.rb
lib/em-jack/connection.rb lib/em-jack/errors.rb lib/em-jack/job.rb)
end
12 changes: 12 additions & 0 deletions lib/em-jack.rb
@@ -0,0 +1,12 @@
$:.unshift(File.dirname(__FILE__))

require 'em-jack/job'
require 'em-jack/errors'
require 'em-jack/beanstalk_connection'
require 'em-jack/connection'

module EMJack
module VERSION
STRING = '0.0.3'
end
end
@@ -1,6 +1,6 @@
require 'eventmachine'

module Jack
module EMJack
class BeanstalkConnection < EM::Connection
attr_accessor :client

Expand Down
12 changes: 6 additions & 6 deletions lib/jack/connection.rb → lib/em-jack/connection.rb
@@ -1,7 +1,7 @@
require 'eventmachine'
require 'yaml'

module Jack
module EMJack
class Connection
RETRY_COUNT = 5

Expand All @@ -20,7 +20,7 @@ def initialize(opts = {})
@in_reserve = false
@deferrables = []

@conn = EM::connect(host, port, Jack::BeanstalkConnection) do |conn|
@conn = EM::connect(host, port, EMJack::BeanstalkConnection) do |conn|
conn.client = self
end

Expand Down Expand Up @@ -61,7 +61,7 @@ def stats(type = nil, val = nil)
when nil then @conn.send(:stats)
when :tube then @conn.send(:'stats-tube', val)
when :job then @conn.send(:'stats-job', val.jobid)
else raise Jack::InvalidCommand.new
else raise EMJack::InvalidCommand.new
end
add_deferrable
end
Expand All @@ -71,7 +71,7 @@ def list(type = nil)
when nil then @conn.send(:'list-tubes')
when :used then @conn.send(:'list-tube-used')
when :watched then @conn.send(:'list-tubes-watched')
else raise Jack::InvalidCommand.new
else raise EMJack::InvalidCommand.new
end
add_deferrable
end
Expand Down Expand Up @@ -110,7 +110,7 @@ def disconnected
# XXX I think I need to run out the deferrables as failed here
# since the connection was dropped

raise Jack::Disconnected if @retries >= RETRY_COUNT
raise EMJack::Disconnected if @retries >= RETRY_COUNT
@retries += 1
EM.add_timer(1) { @conn.reconnect(@host, @port) }
end
Expand Down Expand Up @@ -185,7 +185,7 @@ def received(data)
break if body.nil?

df = @deferrables.shift
job = Jack::Job.new(self, id, body)
job = EMJack::Job.new(self, id, body)
df.succeed(job)
next

Expand Down
2 changes: 1 addition & 1 deletion lib/jack/errors.rb → lib/em-jack/errors.rb
@@ -1,4 +1,4 @@
module Jack
module EMJack
class Disconnected < RuntimeError
end

Expand Down
2 changes: 1 addition & 1 deletion lib/jack/job.rb → lib/em-jack/job.rb
@@ -1,4 +1,4 @@
module Jack
module EMJack
class Job
attr_accessor :jobid, :body, :ttr, :conn

Expand Down
12 changes: 0 additions & 12 deletions lib/jack.rb

This file was deleted.

8 changes: 4 additions & 4 deletions shell.rb
Expand Up @@ -2,7 +2,7 @@

require 'rubygems'
require 'eventmachine'
require 'jack'
require 'em-jack'
require 'pp'

$stdout.sync = true
Expand All @@ -11,7 +11,7 @@ class KeyboardHandler < EM::Connection
include EM::Protocols::LineText2

def post_init
@jack = Jack::Connection.new
@jack = EMJack::Connection.new

print "> "
end
Expand Down Expand Up @@ -45,7 +45,7 @@ def receive_line(line)

when /^delete / then
id = line.gsub(/delete /, '').to_i
job = Jack::Job.new(@jack, id, "asdf")
job = EMJack::Job.new(@jack, id, "asdf")
df = job.delete
df.callback { puts "Deleted" }
df
Expand Down Expand Up @@ -81,7 +81,7 @@ def receive_line(line)
df

when /^stats-job\s+(\d+)/ then
j = Jack::Job.new(@jack, $1, "blah")
j = EMJack::Job.new(@jack, $1, "blah")
df = j.stats
df.callback { |stats| pp stats }
df
Expand Down

0 comments on commit 6edbe0e

Please sign in to comment.