Sha256: 0a3afdf9ed83fe623da508a0a8cb4edcdd47f4bae0d34676c1ca492cbb278b8a

Contents?: true

Size: 775 Bytes

Versions: 9

Compression:

Stored size: 775 Bytes

Contents

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
dtc_rake-1.2.1 lib/dtc_rake/tasks.rb
dtc_rake-1.2.0 lib/dtc_rake/tasks.rb
dtc_rake-1.1.0 lib/dtc_rake/tasks.rb
dtc_rake-1.0.0 lib/dtc_rake/tasks.rb
dtc_rake-1.0.0.pre.beta.2 lib/dtc_rake/tasks.rb
dtc_rake-1.0.0.pre.beta.1 lib/dtc_rake/tasks.rb
dtc_rake-0.2.0 lib/dtc_rake/tasks.rb
dtc_rake-0.1.2 lib/dtc_rake/tasks.rb
dtc_rake-0.1.0 lib/dtc_rake/tasks.rb