Skip to content
This repository has been archived by the owner on Apr 11, 2023. It is now read-only.

Commit

Permalink
releasing 0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Kreeftmeijer committed Jun 27, 2010
2 parents ffb8f04 + 3383394 commit a31fdeb
Show file tree
Hide file tree
Showing 33 changed files with 366 additions and 422 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Expand Up @@ -5,4 +5,6 @@ coverage
rdoc
doc
pkg
tmp
tmp
*.gem
.bundle
29 changes: 29 additions & 0 deletions Gemfile
@@ -0,0 +1,29 @@
source 'http://rubygems.org'

group :active_record do
gem 'activerecord', '>= 2.3.5'
end

group :data_mapper do
gem 'dm-core', '>= 0.10.2'
end

group :mongo_mapper do
gem 'mongo_mapper', '>= 0.7.0'
end

group :sequel do
gem 'sequel', '>= 3.8.0'
end

group :mongoid do
gem 'mongoid'
gem 'builder'
gem 'tzinfo'
end

group :test do
gem 'rspec', '1.3.0'
end

gem 'yard', '>= 0.5.2'
8 changes: 5 additions & 3 deletions README.textile
@@ -1,16 +1,18 @@
h1. Navvy

Navvy is a simple Ruby background job processor inspired by "delayed_job":http://github.com/tobi/delayed_job, but aiming for database agnosticism. Currently Navvy supports ActiveRecord, MongoMapper, Sequel and DataMapper but it's extremely easy to write an adapter for your favorite ORM. Besides plain Ruby (1.8 & 1.9) it completely supports Rails Edge.
Navvy is a simple Ruby background job processor inspired by "delayed_job":http://github.com/tobi/delayed_job, but aiming for database agnosticism. Currently Navvy supports ActiveRecord, MongoMapper, Sequel, DataMapper and Mongoid but it's extremely easy to write an adapter for your favorite ORM.

Navvy doesn't depend on Rails, it's a pure Ruby library. There are generators for Rails 2 and Rails 3, though.

??“Navvy is a shorter form of navigator (UK) or navigational engineer (USA) and is particularly applied to describe the manual labourers working on major civil engineering projects. The term was coined in the late 18th century in Britain when numerous canals were being built, which were also sometimes known as "navigations". Canal navvies typically worked with shovels, pickaxes and barrows.”?? - "Wikipedia":http://en.wikipedia.org/wiki/Navvy

h2. Using Navvy

There are some "Installation Guide":http://wiki.github.com/jeffkreeftmeijer/navvy/installation (even for "Rails 3":http://wiki.github.com/jeffkreeftmeijer/navvy/installation-on-rails-edge) and a "Getting Started Guide":http://wiki.github.com/jeffkreeftmeijer/navvy/getting-started to put you on the right track. Any questions? Don't hesitate to "ask":http://github.com/inbox/new/jeffkreeftmeijer.
Check out the "Installation Guide":http://wiki.github.com/jeffkreeftmeijer/navvy/installation and the "Getting Started Guide":http://wiki.github.com/jeffkreeftmeijer/navvy/getting-started to get up and running. If you have any questions or problems, don't hesitate to "ask":http://github.com/inbox/new/jeffkreeftmeijer.

h2. Contributing

Found any issues? Have a great idea? Want to help? Great! Create an issue "issue":http://github.com/jeffkreeftmeijer/navvy/issues for it, or even better; "fork the project":http://github.com/jeffkreeftmeijer/navvy/fork. Pull requests are always welcome. :)
Found an issue? Have a great idea? Want to help? Great! Create an issue "issue":http://github.com/jeffkreeftmeijer/navvy/issues for it, "ask":http://github.com/inbox/new/jeffkreeftmeijer, or even better; fork the project and fix the problem yourself. Pull requests are always welcome. :)

h2. License

Expand Down
46 changes: 7 additions & 39 deletions Rakefile
@@ -1,50 +1,19 @@
require 'rubygems'
require 'rake'

begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "navvy"
gem.summary = %Q{Simple background job processor inspired by delayed_job, but aiming for database agnosticism.}
gem.description = %Q{Simple background job processor inspired by delayed_job, but aiming for database agnosticism.}
gem.email = "jeff@kreeftmeijer.nl"
gem.homepage = "http://github.com/jeffkreeftmeijer/navvy"
gem.authors = ["Jeff Kreeftmeijer"]

gem.add_development_dependency "rspec", ">= 1.2.9"
gem.add_development_dependency "yard", ">= 0.5.2"
gem.add_development_dependency "sequel", ">= 3.8.0"
gem.add_development_dependency "sqlite3-ruby", ">= 1.2.5"
gem.add_dependency "daemons", ">= 1.0.10"
end
Jeweler::GemcutterTasks.new
rescue LoadError
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
end

require 'spec/rake/spectask'

adapters = Dir[File.dirname(__FILE__) + '/lib/navvy/job/*.rb'].map{|file| File.basename(file, '.rb') }

task :spec do
['spec:active_record', 'spec:mongo_mapper', 'spec:sequel', 'spec:data_mapper'].each do |spec|
adapters.map{|adapter| "spec:#{adapter}"}.each do |spec|
Rake::Task[spec].invoke
end
end

namespace :spec do
Spec::Rake::SpecTask.new(:active_record) do |spec|
spec.spec_files = FileList['spec/setup/active_record.rb', 'spec/*_spec.rb']
end

Spec::Rake::SpecTask.new(:mongo_mapper) do |spec|
spec.spec_files = FileList['spec/setup/mongo_mapper.rb', 'spec/*_spec.rb']
end

Spec::Rake::SpecTask.new(:sequel) do |spec|
spec.spec_files = FileList['spec/setup/sequel.rb', 'spec/*_spec.rb']
end

Spec::Rake::SpecTask.new(:data_mapper) do |spec|
spec.spec_files = FileList['spec/setup/data_mapper.rb', 'spec/*_spec.rb']
adapters.each do |adapter|
Spec::Rake::SpecTask.new(adapter) do |spec|
spec.spec_files = FileList["spec/setup/#{adapter}.rb", 'spec/*_spec.rb']
end
end
end

Expand All @@ -54,7 +23,6 @@ Spec::Rake::SpecTask.new(:rcov) do |spec|
spec.rcov = true
end

task :spec => :check_dependencies
task :default => :spec

begin
Expand Down
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

15 changes: 10 additions & 5 deletions generators/navvy/navvy_generator.rb
@@ -1,14 +1,19 @@
class NavvyGenerator < Rails::Generator::Base
default_options :orm => 'active_record'

def manifest
record do |m|
options = {
:migration_file_name => 'create_jobs'
}
m.migration_template 'migration.rb', 'db/migrate', options
m.file 'script', 'script/navvy', :chmod => 0755
m.migration_template "#{options[:orm]}_migration.rb", 'db/migrate', {:migration_file_name => 'create_jobs'}
end
end

def add_options!(opt)
opt.separator ''
opt.separator 'Options:'
opt.on('--active_record', 'Generate a migration file for ActiveRecord. (default)') { options[:orm] = 'active_record' }
opt.on('--sequel', 'Generate a migration file for Sequel.') { options[:orm] = 'sequel' }
end

def banner
"Usage: #{$0} #{spec.name}"
end
Expand Down
4 changes: 0 additions & 4 deletions generators/navvy/templates/script

This file was deleted.

23 changes: 23 additions & 0 deletions generators/navvy/templates/sequel_migration.rb
@@ -0,0 +1,23 @@
Sequel.migration do
up do
create_table(:jobs) do
primary_key :id, :type => Integer
String :object
String :method_name
String :arguments, :text => true
Integer :priority, :default => 0
String :return
String :exception
Integer :parent_id
DateTime :created_at
DateTime :run_at
DateTime :started_at
DateTime :completed_at
DateTime :failed_at
end
end

down do
drop_table(:jobs)
end
end
18 changes: 12 additions & 6 deletions lib/generators/navvy_generator.rb
Expand Up @@ -2,21 +2,27 @@
class NavvyGenerator < Rails::Generators::Base
include Rails::Generators::Migration

class_option :active_record,
:desc => 'Generate a migration file for ActiveRecord. (default)',
:type => 'boolean'

class_option :sequel,
:desc => 'Generate a migration file for Sequel.',
:type => 'boolean'

def self.source_root
File.join(File.dirname(__FILE__), '..', '..', 'generators', 'navvy', 'templates')
end

def install_navvy
migration_template(
'migration.rb',
"#{orm}_migration.rb",
'db/migrate/create_jobs.rb'
)
end

copy_file(
'script',
'script/navvy',
:chmod => 0755
)
def orm
options[:sequel] ? 'sequel' : 'active_record'
end

protected
Expand Down
10 changes: 7 additions & 3 deletions lib/navvy.rb
@@ -1,16 +1,20 @@
require File.expand_path(File.dirname(__FILE__) + '/navvy/worker')
require File.expand_path(File.dirname(__FILE__) + '/navvy/log')
require File.expand_path(File.dirname(__FILE__) + '/navvy/logger')
require File.expand_path(File.dirname(__FILE__) + '/navvy/configuration')

module Navvy
class << self
attr_writer :configuration
end


def self.logger
@logger || Navvy.configuration.logger
end

def self.configuration
@configuration ||= Configuration.new
end

def self.configure
yield(self.configuration)
end
Expand Down
10 changes: 4 additions & 6 deletions lib/navvy/configuration.rb
@@ -1,15 +1,13 @@
module Navvy
class Configuration
attr_accessor :job_limit, :keep_jobs, :logger, :quiet, :sleep_time,
:max_attempts

attr_accessor :job_limit, :keep_jobs, :logger, :sleep_time, :max_attempts

def initialize
@job_limit = 100
@keep_jobs = false
@logger = nil
@quiet = false
@logger = Navvy::Logger.new
@sleep_time = 5
@max_attempts = 25
end
end
end
end
6 changes: 3 additions & 3 deletions lib/navvy/job.rb
Expand Up @@ -152,14 +152,14 @@ def status

alias_method :completed?, :completed_at?
alias_method :failed?, :failed_at?

private

##
# Turn a constant with potential namespacing into an object
#
# @return [Class] class

def constantize(str)
names = str.split('::')
names.shift if names.empty? || names.first.empty?
Expand Down
1 change: 0 additions & 1 deletion lib/navvy/job/active_record.rb
@@ -1,4 +1,3 @@
require 'rubygems'
require 'active_record'

module Navvy
Expand Down
1 change: 0 additions & 1 deletion lib/navvy/job/data_mapper.rb
@@ -1,4 +1,3 @@
require 'rubygems'
require 'dm-core'

module Navvy
Expand Down
1 change: 0 additions & 1 deletion lib/navvy/job/mongo_mapper.rb
@@ -1,4 +1,3 @@
require 'rubygems'
require 'mongo_mapper'

module Navvy
Expand Down

0 comments on commit a31fdeb

Please sign in to comment.