Module: DtcRake::Tasks

Defined in:
lib/dtc_rake/tasks.rb

Class Method Summary collapse

Class Method Details

.load_tasks(params = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/dtc_rake/tasks.rb', line 5

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