Hi- Below is a patch I used for a project I'm working that I thought might be useful to others.
Our situation is that we have an aw-etl project running on a machine (with some other services) that needs to be upgraded to Rails 2.1. Since aw-etl does not work with Rails 2.1 yet, I thought I would use the handy vendor/rails feature in Rails that allows you to freeze a specific version of Rails with your project. The trouble is that the --rails-root option of aw-etl prevents this from working properly because the option is not processed until after the "require rubygems" statement is executed - this locks you into using whatever version is installed at the system level. The hack below looks for the --rails-root option at the top of the execution process, and imports the Rails environment at that point, rather than at engine initialization time. I couldn't figure out a reasonable way of including a test with this patch, but it is definitely working for us. Perhaps if someone else needs this, they can try it out and confirm that it works? Thanks! Darin Wilson (patch was created from the etl/trunk directory of the activewarehouse source) Index: lib/etl/engine.rb =================================================================== --- lib/etl/engine.rb (revision 908) +++ lib/etl/engine.rb (working copy) @@ -25,7 +25,8 @@ @log_write_mode = 'w' if options[:newlog] @skip_bulk_import = options[:skip_bulk_import] @read_locally = options[:read_locally] - @rails_root = options[:rails_root] + # the --rails_root option is handled in lib/etl.rb, before any other require statements + @rails_root = options[:rails_root] require File.join(@rails_root, 'config/environment') if @rails_root Index: lib/etl.rb =================================================================== --- lib/etl.rb (revision 908) +++ lib/etl.rb (working copy) @@ -29,6 +29,17 @@ require 'yaml' require 'erb' +# we don't want to parse all of the args just yet, but we want to +# initialize the Rails environment if the --rails-root option was +# supplied - this will let us use the Rails version in vendor/rails +# if it's there +ARGV.each_with_index do |arg, i| + if arg == '--rails-root' && (i + 1) < ARGV.length + require File.join(ARGV[i + 1], 'config/environment') + break + end +end + require 'rubygems' unless Kernel.respond_to?(:gem) _______________________________________________ Activewarehouse-discuss mailing list Activewarehouse-discuss@rubyforge.org http://rubyforge.org/mailman/listinfo/activewarehouse-discuss