Created
June 4, 2012 09:58
-
-
Save sreeix/2867557 to your computer and use it in GitHub Desktop.
Add ability to not load RAILS Stack for rake tasks
This file contains hidden or 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
| # 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