forked from mtylty/backgroundrb-rails3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rake tasks and script/backgroundrb should be working
- Loading branch information
Showing
15 changed files
with
124 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,4 @@ coverage | |
pkg | ||
tmp | ||
Gemfile.lock | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1 @@ | ||
# Backgroundrb | ||
# FIXME: check if data that we are writing to the socket should end with newline | ||
require "pathname" | ||
require "packet" | ||
require "ostruct" | ||
|
||
BACKGROUNDRB_ROOT = Rails.root.realpath.to_s | ||
require "backgroundrb/bdrb_config" | ||
unless defined?(BDRB_CONFIG) | ||
BDRB_CONFIG = BackgrounDRb::Config.read_config("#{BACKGROUNDRB_ROOT}/config/backgroundrb.yml") | ||
end | ||
|
||
require "backgroundrb/bdrb_client_helper" | ||
require "backgroundrb/bdrb_job_queue" | ||
require "backgroundrb/bdrb_conn_error" | ||
require "backgroundrb/rails_worker_proxy" | ||
require "backgroundrb/bdrb_connection" | ||
require "backgroundrb/bdrb_cluster_connection" | ||
require "backgroundrb/bdrb_start_stop" | ||
require "backgroundrb/bdrb_result" | ||
MiddleMan = BackgrounDRb::ClusterConnection.new | ||
|
||
|
||
require "backgroundrb/railtie" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Backgroundrb | ||
# FIXME: check if data that we are writing to the socket should end with newline | ||
require "pathname" | ||
require "packet" | ||
require "ostruct" | ||
|
||
require "rails" | ||
require "backgroundrb" | ||
|
||
require "backgroundrb/bdrb_config" | ||
require "backgroundrb/bdrb_client_helper" | ||
require "backgroundrb/bdrb_job_queue" | ||
require "backgroundrb/bdrb_conn_error" | ||
require "backgroundrb/rails_worker_proxy" | ||
require "backgroundrb/bdrb_connection" | ||
require "backgroundrb/bdrb_cluster_connection" | ||
require "backgroundrb/bdrb_start_stop" | ||
require "backgroundrb/bdrb_result" | ||
|
||
|
||
module BackgrounDRb | ||
class Railtie < Rails::Railtie | ||
config.bdrb = ActiveSupport::OrderedOptions.new | ||
|
||
unless config.bdrb.has_key? :root | ||
config.bdrb.root = File.expand_path(File.join(__FILE__, '..', '..', '..')) | ||
end | ||
BackgrounDRb::BACKGROUNDRB_ROOT = config.bdrb.root | ||
|
||
config.before_configuration do | ||
config_file = "#{Rails.root}/config/backgroundrb.yml" | ||
|
||
if File.exists?(config_file) && !config.bdrb.has_key?(:config) | ||
config.bdrb.config = BackgrounDRb::Config.read_config(config_file) | ||
end | ||
BackgrounDRb::BDRB_CONFIG = config.bdrb.config | ||
|
||
MiddleMan = BackgrounDRb::ClusterConnection.new if File.exists?(config_file) | ||
end | ||
|
||
rake_tasks do | ||
load "tasks/backgroundrb_tasks.rake" | ||
end | ||
|
||
end | ||
|
||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 5 additions & 17 deletions
22
lib/generators/backgroundrb/bdrb_migration/bdrb_migration_generator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,15 @@ | ||
require 'rails/generators/active_record' | ||
|
||
module Backgroundrb | ||
module Generators | ||
class BdrbMigrationGenerator < Rails::Generators::NamedBase | ||
class BdrbMigrationGenerator < ActiveRecord::Generators::Base | ||
def self.source_root | ||
@source_root ||= File.expand_path('../templates', __FILE__) | ||
end | ||
|
||
def initialize(runtime_args, runtime_options = {}) | ||
runtime_args << 'CreateBackgroundrbQueueTable' if runtime_args.empty? | ||
super | ||
end | ||
|
||
def manifest | ||
record do |m| | ||
m.migration_template 'migration.rb', 'db/migrate', | ||
:assigns => { :bdrb_table_name => default_bdrb_table_name } | ||
end | ||
def copy_backgroundrb_migration | ||
migration_template "migration.rb", "db/migrate/backgroundrb_create_#{table_name}" | ||
end | ||
|
||
protected | ||
|
||
def default_bdrb_table_name | ||
ActiveRecord::Base.pluralize_table_names ? 'bdrb_job_queue'.pluralize : 'bdrb_job_queue' | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.