require "rake" module DtcRake module Tasks def load_tasks(params = {}) # a flag - load the tasks just once, multiple loading # leads to multiple invocation of the same task return if defined? @tasks_loaded params[:exclude] ||= [] params[:include] ||= ["*.rake"] filelist = {} [:exclude, :include].each do |key| filelist[key] = params[key].collect { |file| Dir[File.expand_path("#{File.dirname(__FILE__)}/../tasks/#{file}")] } filelist[key].flatten! end # load an include file only if it not in the exclude list filelist[:include].each do |ext| load ext unless filelist[:exclude].include?(ext) end @tasks_loaded = true end module_function :load_tasks end end