Sha256: da08b176cb491badcc9269002d1232a62f973b4aa946dd31caa3cfb468809396

Contents?: true

Size: 1010 Bytes

Versions: 4

Compression:

Stored size: 1010 Bytes

Contents

require 'ostruct'
require 'rake/tasklib'
require 'corundum/configurable'

module Corundum
  class TaskLib < Rake::TaskLib
    include Configurable

    def default_configuration(*tasklibs)
    end

    def resolve_configuration
    end

    def in_namespace(*tasknames)
      if tasknames.empty?
        if block_given?
          if @namespace_name.nil?
            yield
          else
            namespace @namespace_name do
              yield
            end
          end
        end
      else
        tasknames.map do |taskname|
          [@namespace_name, taskname].compact.join(":")
        end
      end
    end

    def root_task
      @namespace_name || :default
    end

    def default_namespace
      nil
    end

    def [](taskname)
      in_namespace(taskname).first
    end

    def initialize(*tasklibs)
      setting(:namespace_name, default_namespace)

      default_configuration(*tasklibs)

      yield self if block_given?

      resolve_configuration

      define
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
corundum-0.0.6 lib/corundum/tasklib.rb
corundum-0.0.5 lib/corundum/tasklib.rb
corundum-0.0.3 lib/corundum/tasklib.rb
corundum-0.0.2 lib/corundum/tasklib.rb