<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,70 +1,42 @@
-require 'rake'
 require 'rubygems'
-require 'rake/testtask'
-require 'rake/rdoctask'
-require 'spec/rake/spectask'
-require 'rake/contrib/sshpublisher'
-
-desc 'Default: run unit tests.'
-task :default =&gt; :test
-
-desc 'Test the backgroundrb plugin.'
-Rake::TestTask.new(:test) do |t|
-  t.libs &lt;&lt; 'lib'
-  t.pattern = 'test/**/*_test.rb'
-  t.verbose = true
-end
-
-desc &quot;Run all specs&quot;
-Spec::Rake::SpecTask.new('specs') do |t|
-  t.spec_opts = [&quot;--format&quot;, &quot;specdoc&quot;]
-  t.libs = ['lib', 'server/lib' ]
-  t.spec_files = FileList['specs/**/*_spec.rb']
-end
-
-desc &quot;RCov&quot;
-Spec::Rake::SpecTask.new('rcov') do |t|
-  t.spec_files = FileList['specs/**/*_spec.rb']
-  t.libs = ['lib', 'server/lib' ]
-  t.rcov = true
+require 'rake/gempackagetask'
+
+PLUGIN = &quot;backgroundrb_merb&quot;
+NAME = &quot;backgroundrb_merb&quot;
+VERSION = &quot;1.0.3&quot;
+AUTHOR = &quot;George Palmer&quot;
+EMAIL = &quot;george.palmer@gmail.com&quot;
+HOMEPAGE = &quot;not yet&quot;
+SUMMARY = &quot;Merb plugin that provides backgroundrb&quot;
+
+spec = Gem::Specification.new do |s|
+  s.name = NAME
+  s.version = VERSION
+  s.platform = Gem::Platform::RUBY
+  s.has_rdoc = true
+  s.extra_rdoc_files = [&quot;README&quot;, &quot;LICENSE&quot;, 'TODO']
+  s.summary = SUMMARY
+  s.description = s.summary
+  s.author = AUTHOR
+  s.email = EMAIL
+  s.homepage = HOMEPAGE
+  s.add_dependency('merb', '&gt;= 0.9.2')
+  s.require_path = 'lib'
+  s.autorequire = PLUGIN
+  s.files = %w(LICENSE README Rakefile TODO) + Dir.glob(&quot;{config,generators,lib,script,server,specs}/**/*&quot;)
 end
 
-desc 'Generate documentation for the backgroundrb plugin.'
-Rake::RDocTask.new(:rdoc) do |rdoc|
-  rdoc.rdoc_dir = 'rdoc'
-  rdoc.title    = 'Backgroundrb'
-  rdoc.options &lt;&lt; '--line-numbers' &lt;&lt; '--inline-source'
-  rdoc.rdoc_files.include('README')
-  rdoc.rdoc_files.include('LICENSE')
-  rdoc.rdoc_files.include('lib/*.rb')
-  rdoc.rdoc_files.include('lib/backgroundrb/*.rb')
-  rdoc.rdoc_files.include('server/*.rb')
-  rdoc.rdoc_files.include('server/lib/*.rb')
-  rdoc.template = 'jamis'
+Rake::GemPackageTask.new(spec) do |pkg|
+  pkg.gem_spec = spec
 end
 
-module Rake
-  class BackgrounDRbPublisher &lt;  SshDirPublisher
-    attr_reader :project, :proj_id, :user
-    def initialize(projname, user)
-      super(
-            &quot;#{user}@rubyforge.org&quot;,
-            &quot;/var/www/gforge-projects/backgroundrb&quot;,
-            &quot;doc/output&quot;)
-    end
-  end
+task :install =&gt; [:package] do
+  sh %{sudo gem install pkg/#{NAME}-#{VERSION}}
 end
 
-desc &quot;Publish documentation to Rubyforge&quot;
-task :publish_rdoc =&gt; [:rdoc] do
-  user = ENV['RUBYFORGE_USER']
-  publisher = Rake::BackgrounDRbPublisher.new('backgroundrb', user)
-  publisher.upload
-end
-
-namespace :git do 
-  desc &quot;Push changes to central git repo&quot;
-  task :push do 
-    sh(&quot;git push origin master&quot;)
+namespace :jruby do
+  desc &quot;Run :package and install the resulting .gem with jruby&quot;
+  task :install =&gt; :package do
+    sh %{#{SUDO} jruby -S gem install pkg/#{NAME}-#{Merb::VERSION}.gem --no-rdoc --no-ri}
   end
-end
+end
\ No newline at end of file</diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -1,30 +1,33 @@
 #!/usr/bin/env ruby
 
-rails_root = File.expand_path(File.join(File.dirname(__FILE__)+&quot;/..&quot;))
-RAILS_HOME = rails_root
-PACKET_APP = rails_root + &quot;/vendor/plugins/backgroundrb&quot;
-WORKER_ROOT = rails_root + &quot;/lib/workers&quot;
+# Add backgroundrb folders to load path
+backgroundrb_dir = Dir.glob(File.expand_path(File.dirname(__FILE__) + &quot;/../gems/gems/backgroundrb_merb*&quot;)).last
+[&quot;lib/backgroundrb_merb&quot;, &quot;server/lib&quot;].each { |x| $LOAD_PATH.unshift(backgroundrb_dir + &quot;/#{x}&quot;)}
 
-[&quot;server&quot;,&quot;server/lib&quot;,&quot;lib&quot;,&quot;lib/backgroundrb&quot;].each { |x| $LOAD_PATH.unshift(PACKET_APP + &quot;/#{x}&quot;)}
+# Add workers to load path
+WORKER_ROOT = File.expand_path(File.dirname(__FILE__) + &quot;/../lib/workers&quot;)
 $LOAD_PATH.unshift(WORKER_ROOT)
 
-require RAILS_HOME + '/config/boot.rb'
-
-# parse CLI options and set RAILS_ENV before loading RoR environment
-require &quot;bdrb_config.rb&quot;
-BackgrounDRb::Config.parse_cmd_options ARGV
-
-require RAILS_HOME + '/config/environment'
+# Take preference to local merb gems
 require &quot;rubygems&quot;
+Gem.clear_paths
+Gem.path.unshift(File.expand_path(File.dirname(__FILE__) + &quot;/../gems/gems&quot;))
+
+# Require dependencies
+require 'merb-core'
+require 'activerecord'
 require &quot;yaml&quot;
 require &quot;erb&quot;
 require &quot;logger&quot;
 require &quot;packet&quot;
-require &quot;backgroundrb_server&quot;
+require &quot;bdrb_config.rb&quot;
+require &quot;master_worker.rb&quot;
 
-CONFIG_FILE = BackgrounDRb::Config.read_config(&quot;#{RAILS_HOME}/config/backgroundrb.yml&quot;)
-pid_file = &quot;#{RAILS_HOME}/tmp/pids/backgroundrb_#{CONFIG_FILE[:backgroundrb][:port]}.pid&quot;
-SERVER_LOGGER = &quot;#{RAILS_HOME}/log/backgroundrb_server_#{CONFIG_FILE[:backgroundrb][:port]}.log&quot;
+# Parse CLI options
+BackgrounDRbMerb::Config.parse_cmd_options ARGV
+CONFIG_FILE = BackgrounDRbMerb::Config.read_config(&quot;#{Merb.root}/config/backgroundrb.yml&quot;)
+pid_file = &quot;#{Merb.root}/tmp/backgroundrb_#{CONFIG_FILE[:backgroundrb][:port]}.pid&quot;
+SERVER_LOGGER = &quot;#{Merb.root}/log/backgroundrb_server_#{CONFIG_FILE[:backgroundrb][:port]}.log&quot;
 
 case ARGV[0]
 when 'start'
@@ -39,7 +42,7 @@ when 'start'
       [STDIN, STDOUT, STDERR].each {|desc| desc.reopen(log_file)}
     end
 
-    BackgrounDRb::MasterProxy.new()
+    BackgrounDRbMerb::MasterProxy.new()
   end
 when 'stop'
   pid = nil
@@ -57,5 +60,5 @@ when 'stop'
     File.delete(pid_file) if File.exists?(pid_file)
   end
 else
-  BackgrounDRb::MasterProxy.new()
-end
+  BackgrounDRbMerb::MasterProxy.new()
+end
\ No newline at end of file</diff>
      <filename>script/backgroundrb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,4 @@
-module BackgrounDRb
+module BackgrounDRbMerb
   class CronTrigger
     WDAYS = { 0 =&gt; &quot;Sunday&quot;,1 =&gt; &quot;Monday&quot;,2 =&gt; &quot;Tuesday&quot;,3 =&gt; &quot;Wednesday&quot;, 4 =&gt; &quot;Thursday&quot;, 5 =&gt; &quot;Friday&quot;, 6 =&gt; &quot;Saturday&quot; }
     LeapYearMonthDays = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]</diff>
      <filename>server/lib/cron_trigger.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,4 @@
-module BackgrounDRb
+module BackgrounDRbMerb
   class InvalidDumpError &lt; RuntimeError
   end
 end</diff>
      <filename>server/lib/invalid_dump_error.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,7 +3,7 @@ class LogWorker &lt; Packet::Worker
   #set_no_auto_load(true)
   attr_accessor :log_file
   def worker_init
-    @log_file = Logger.new(&quot;#{RAILS_HOME}/log/backgroundrb_#{CONFIG_FILE[:backgroundrb][:port]}.log&quot;)
+    @log_file = Logger.new(&quot;#{Merb.root}/log/backgroundrb_#{CONFIG_FILE[:backgroundrb][:port]}.log&quot;)
   end
 
   def receive_data p_data</diff>
      <filename>server/lib/log_worker.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,5 @@
 #!/usr/bin/env ruby
-module BackgrounDRb
+module BackgrounDRbMerb
   # Class wraps a logger object for debugging internal errors within server
   class DebugMaster
     attr_accessor :log_mode,:logger,:log_flag
@@ -9,7 +9,7 @@ module BackgrounDRb
       if @log_mode == :foreground
         @logger = ::Logger.new(STDOUT)
       else
-        @logger = ::Logger.new(&quot;#{RAILS_HOME}/log/backgroundrb_#{CONFIG_FILE[:backgroundrb][:port]}_debug.log&quot;)
+        @logger = ::Logger.new(&quot;#{Merb.root}/log/backgroundrb_#{CONFIG_FILE[:backgroundrb][:port]}_debug.log&quot;)
       end
     end
 
@@ -154,12 +154,12 @@ module BackgrounDRb
     attr_accessor :config_file,:reloadable_workers,:worker_triggers,:reactor
     def initialize
       raise &quot;Running old Ruby version, upgrade to Ruby &gt;= 1.8.5&quot; unless check_for_ruby_version
-      @config_file = BackgrounDRb::Config.read_config(&quot;#{RAILS_HOME}/config/backgroundrb.yml&quot;)
+      @config_file = BackgrounDRbMerb::Config.read_config(&quot;#{Merb.root}/config/backgroundrb.yml&quot;)
 
       log_flag = CONFIG_FILE[:backgroundrb][:debug_log].nil? ? true : CONFIG_FILE[:backgroundrb][:debug_log]
       debug_logger = DebugMaster.new(CONFIG_FILE[:backgroundrb][:log],log_flag)
 
-      load_rails_env
+      load_merb_env
 
       find_reloadable_worker
 
@@ -204,9 +204,9 @@ module BackgrounDRb
         case value[:trigger_args]
         when String
           cron_args = value[:trigger_args] || &quot;0 0 0 0 0&quot;
-          trigger = BackgrounDRb::CronTrigger.new(cron_args)
+          trigger = BackgrounDRbMerb::CronTrigger.new(cron_args)
         when Hash
-          trigger = BackgrounDRb::Trigger.new(value[:trigger_args])
+          trigger = BackgrounDRbMerb::Trigger.new(value[:trigger_args])
         end
         worker_method_triggers[key] = { :trigger =&gt; trigger,:data =&gt; value[:data],:runtime =&gt; trigger.fire_after_time(Time.now).to_i }
       end
@@ -257,21 +257,18 @@ module BackgrounDRb
       end
     end
 
-    def load_rails_env
+    def load_merb_env
       run_env = CONFIG_FILE[:backgroundrb][:environment] || 'development'
-      ENV[&quot;RAILS_ENV&quot;] = run_env
-      RAILS_ENV.replace(run_env) if defined?(RAILS_ENV)
-      require RAILS_HOME + '/config/environment.rb'
       lazy_load = CONFIG_FILE[:backgroundrb][:lazy_load].nil? ? true : CONFIG_FILE[:backgroundrb][:lazy_load].nil?
-      p lazy_load
-      load_rails_models unless lazy_load
+      require_merb_files unless lazy_load
       ActiveRecord::Base.allow_concurrency = true
     end
 
-    def load_rails_models
-      model_root = RAILS_HOME + &quot;/app/models&quot;
-      models = Dir[&quot;#{model_root}/**/*.rb&quot;]
-      models.each { |x|
+    def require_merb_files
+      debug_logger = DebugMaster.new(CONFIG_FILE[:backgroundrb][:log],true)
+       
+      files = Dir[&quot;#{Merb.root}/app/models/**/*.rb&quot;]
+      files.each { |x|
         begin
           require x
         rescue LoadError
@@ -300,7 +297,4 @@ module BackgrounDRb
     def check_for_ruby_version; return RUBY_VERSION &gt;= &quot;1.8.5&quot;; end
 
   end # end of module BackgrounDRb
-end
-
-
-
+end
\ No newline at end of file</diff>
      <filename>server/lib/master_worker.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,4 @@
-module BackgrounDRb
+module BackgrounDRbMerb
   # this class is a dummy class that implements things required for passing data to
   # actual logger worker
   class PacketLogger
@@ -182,9 +182,9 @@ module BackgrounDRb
     # does initialization of worker stuff and invokes create method in
     # user defined worker class
     def worker_init
-      @config_file = BackgrounDRb::Config.read_config(&quot;#{RAILS_HOME}/config/backgroundrb.yml&quot;)
+      @config_file = BackgrounDRbMerb::Config.read_config(&quot;#{Merb.root}/config/backgroundrb.yml&quot;)
       log_flag = @config_file[:backgroundrb][:debug_log].nil? ? true : @config_file[:backgroundrb][:debug_log]
-      load_rails_env
+      load_merb_env
       @logger = PacketLogger.new(self,log_flag)
       @thread_pool = ThreadPool.new(pool_size || 20,@logger)
 
@@ -260,9 +260,9 @@ module BackgrounDRb
         case value[:trigger_args]
         when String
           cron_args = value[:trigger_args] || &quot;0 0 0 0 0&quot;
-          trigger = BackgrounDRb::CronTrigger.new(cron_args)
+          trigger = BackgrounDRbMerb::CronTrigger.new(cron_args)
         when Hash
-          trigger = BackgrounDRb::Trigger.new(value[:trigger_args])
+          trigger = BackgrounDRbMerb::Trigger.new(value[:trigger_args])
         end
         @worker_method_triggers[key] = { :trigger =&gt; trigger,:data =&gt; value[:data],:runtime =&gt; trigger.fire_after_time(Time.now).to_i }
       end
@@ -345,14 +345,11 @@ module BackgrounDRb
     end
     
     private
-    def load_rails_env
-      db_config_file = YAML.load(ERB.new(IO.read(&quot;#{RAILS_HOME}/config/database.yml&quot;)).result)
+    def load_merb_env
+      db_config_file = YAML.load(ERB.new(IO.read(&quot;#{Merb.root}/config/database.yml&quot;)).result)
       run_env = @config_file[:backgroundrb][:environment] || 'development'
-      ENV[&quot;RAILS_ENV&quot;] = run_env
-      RAILS_ENV.replace(run_env) if defined?(RAILS_ENV)
-      ActiveRecord::Base.establish_connection(db_config_file[run_env])
+      ActiveRecord::Base.establish_connection(db_config_file[run_env.to_sym])
       ActiveRecord::Base.allow_concurrency = true
     end
-
   end # end of class MetaWorker
 end # end of module BackgrounDRb</diff>
      <filename>server/lib/meta_worker.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,4 @@
-module BackgrounDRb
+module BackgrounDRbMerb
   class Trigger
 
     attr_accessor :start_time, :end_time, :repeat_interval</diff>
      <filename>server/lib/trigger.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>TODO.org</filename>
    </removed>
    <removed>
      <filename>lib/backgroundrb.rb</filename>
    </removed>
    <removed>
      <filename>lib/backgroundrb/bdrb_config.rb</filename>
    </removed>
    <removed>
      <filename>lib/backgroundrb/bdrb_conn_error.rb</filename>
    </removed>
    <removed>
      <filename>lib/backgroundrb/rails_worker_proxy.rb</filename>
    </removed>
    <removed>
      <filename>tasks/backgroundrb_tasks.rake</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>72f731818a0c62ba63ebb399ba67d769bb45021a</id>
    </parent>
  </parents>
  <author>
    <name>George Palmer</name>
    <email>george@bablo.com</email>
  </author>
  <url>http://github.com/georgepalmer/backgroundrb_merb/commit/4da9bfbba79a59998a92aa74a494496f7cf14e0b</url>
  <id>4da9bfbba79a59998a92aa74a494496f7cf14e0b</id>
  <committed-date>2008-05-01T09:32:02-07:00</committed-date>
  <authored-date>2008-05-01T09:32:02-07:00</authored-date>
  <message>First attempt at fork to MERB</message>
  <tree>7d747c4464c803f143f8cab71d89fec86ae755fd</tree>
  <committer>
    <name>George Palmer</name>
    <email>george@bablo.com</email>
  </committer>
</commit>
