I think Rails is very heavy and I'm taking pieces out of my projects and making them standalone. My library of tasks, I would like it to work outside Rails. So there is no application and no config/application.rb, only the lib/ folder that defines tasks. How should I structure my rakefile to include all the tasks defined in lib/tasks/*rake
? My non-working attempt is below.
#!/usr/bin/env/rake
d = Dir["#{File.dirname(__FILE__)}/src/tasks/*.rake" ]
d.each do |file|
require "tasks/"+ File.basename(file, File.extname(file))
end
The invocation is something like bundle exec rake -T -Isrc
把它放在你的耙文件中
Dir["#{File.dirname(__FILE__)}/src/tasks/*.rake" ].each{ |rake_file| load rake_file }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.