Skip to content

Instantly share code, notes, and snippets.

@sreeix
Created June 4, 2012 09:58
Show Gist options
  • Select an option

  • Save sreeix/2867557 to your computer and use it in GitHub Desktop.

Select an option

Save sreeix/2867557 to your computer and use it in GitHub Desktop.
Add ability to not load RAILS Stack for rake tasks
# 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 'rake'
def with_rails
require File.expand_path('../config/application', __FILE__)
Sf::Application.send :include, Rake::DSL
Sf::Application.load_tasks
end
def without_rails
Dir[File.expand_path("../lib/tasks/", __FILE__) + '/*.rake'].each do |file|
begin
load file
rescue LoadError
puts 'Load Err.' + $!.inspect
rescue
puts 'random one'
end
end
end
if ENV['DONT_LOAD_RAILS']
without_rails
else
with_rails
end
module ::RakeFileUtils
extend Rake::FileUtilsExt
end
unless ENV['DONT_LOAD_RESQUE']
require 'resque/tasks'
require 'resque_scheduler/tasks'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment