diff --git a/Rakefile b/Rakefile index 7e79afe7bc..21466b0052 100644 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,13 @@ # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. -require(File.join(File.dirname(__FILE__), 'config', 'boot')) +begin + # Load up the environment instead of just the boot file because we want all of the tasks available. + require(File.join(File.dirname(__FILE__), 'config', 'environment')) +rescue + # Load up the boot file instead because there's something wrong with the environment. + require(File.join(File.dirname(__FILE__), 'config', 'boot')) +end require 'rake' require 'rake/testtask' @@ -9,11 +15,18 @@ require 'rake/rdoctask' require 'tasks/rails' +# When running Refinery from a gem we lose the rake tasks, so add them back in: unless REFINERY_ROOT == RAILS_ROOT - # Load any custom rakefile extensions (for the gem only) Dir[File.join(REFINERY_ROOT, %w(vendor plugins * ** tasks ** *.rake))].sort.each { |ext| load ext } end +# We also need to load in the rake tasks from gem plugins whether Refinery is a gem or not: +if defined?($refinery_gem_plugin_lib_paths) && !$refinery_gem_plugin_lib_paths.nil? + $refinery_gem_plugin_lib_paths.each do |path| + Dir[File.join(path, %w(tasks ** *.rake))].sort.each { |ext| load ext } + end +end + desc 'Removes trailing whitespace' task :whitespace do sh %{find . -name '*.*rb' -exec sed -i '' 's/\t/ /g' {} \\; -exec sed -i '' 's/ *$//g' {} \\; } diff --git a/VERSION b/VERSION index a9fc1026ea..66b2946511 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.9.5.24 +0.9.5.25 diff --git a/bin/refinery-update-core b/bin/refinery-update-core index eca8e52d0e..ec2a521dc5 100644 --- a/bin/refinery-update-core +++ b/bin/refinery-update-core @@ -17,6 +17,9 @@ unless RAILS_ROOT.nil? or RAILS_ROOT.length == 0 # copy in any new migrations. FileUtils::cp Dir[File.join(REFINERY_ROOT, %w(db migrate *.rb))], File.join(RAILS_ROOT, %w(db migrate)) + # replace rakefile. + FileUtils::cp File.join(REFINERY_ROOT, %w(Rakefile)), File.join(RAILS_ROOT, %w(Rakefile)) + # read in the config files app_config = File.open(File.join(RAILS_ROOT, %w(config environment.rb)), "r").read environment_updated = false diff --git a/vendor/plugins/refinery/lib/refinery/initializer.rb b/vendor/plugins/refinery/lib/refinery/initializer.rb index 48d3eaaffc..779bc747d0 100644 --- a/vendor/plugins/refinery/lib/refinery/initializer.rb +++ b/vendor/plugins/refinery/lib/refinery/initializer.rb @@ -13,15 +13,17 @@ def default_plugin_paths end end if defined? Rails::Plugin::Loader - class GemedPluginLoader < Rails::Plugin::Loader + class PluginLoader < Rails::Plugin::Loader def add_plugin_load_paths super - # add plugin lib paths to the $LOAD_PATH so that rake tasks etc. can be run when using a gem. - plugins.each do |plugin| - plugin.load_paths.reject { |path| path.scan(/refinerycms.+?vendor\/plugins\/.+?\/lib/).empty? }.each do |path| - $LOAD_PATH.unshift path - end + # add plugin lib paths to the $LOAD_PATH so that rake tasks etc. can be run when using a gem for refinery or gems for plugins. + search_for = Regexp.new(File.join('(', REFINERY_ROOT, %w(vendor plugins \)? .+? lib))) + paths = plugins.collect{ |plugin| plugin.load_paths }.flatten.reject{|path| path.scan(search_for).empty? or path.include?('/rails-') } + paths = paths.reject{ |path| path.include?(REFINERY_ROOT) } if REFINERY_ROOT == RAILS_ROOT # superfluous when not in gem. + ($refinery_gem_plugin_lib_paths = paths).each do |path| + $LOAD_PATH.unshift path end + $LOAD_PATH.uniq! end end end @@ -30,7 +32,7 @@ class Initializer < Rails::Initializer def self.run(command = :process, configuration = Configuration.new) Rails.configuration = configuration configuration.reload_plugins = true if RAILS_ENV =~ /development/ and REFINERY_ROOT == RAILS_ROOT # seems to work, don't in gem. - configuration.plugin_loader = Refinery::GemedPluginLoader unless REFINERY_ROOT == RAILS_ROOT # only do this in a gem. + configuration.plugin_loader = Refinery::PluginLoader super end