Sha256: 13d3207e115852f2e471c0a9ac0ddb3ef4dc636a582e8700e00d717ab2b170fe

Contents?: true

Size: 731 Bytes

Versions: 23

Compression:

Stored size: 731 Bytes

Contents

require 'rake'
require 'rake/tasklib'

module Maid
  module Rake
    class Task < ::Rake::TaskLib
      DEFAULT_DESCRIPTION = 'Maid Task'

      def initialize(*args, &task)
        @args      = args
        @task_proc = task
        define
      end

      private

      attr_reader :task_proc

      def args
        @args.reject(&:empty?)
      end

      def task_description
        @task_description ||= begin
          opts = args.detect { |arg| arg.is_a?(Hash) }
          (opts && opts.delete(:description)) || DEFAULT_DESCRIPTION
        end
      end

      def define
        desc task_description
        task *args do |task|
          SingleRule.perform(task.name, task_proc)
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
maid-0.10.0.pre.alpha.1 lib/maid/rake/task.rb
maid-0.9.0.alpha.2 lib/maid/rake/task.rb
maid-0.9.0.alpha.1 lib/maid/rake/task.rb
maid-0.8.0.alpha.4 lib/maid/rake/task.rb
maid-0.8.0.alpha.3 lib/maid/rake/task.rb
maid-0.8.0.alpha.2 lib/maid/rake/task.rb
maid-0.8.0.alpha.1 lib/maid/rake/task.rb
maid-0.7.0 lib/maid/rake/task.rb
maid-0.7.0.beta.1 lib/maid/rake/task.rb
maid-0.7.0.alpha.4 lib/maid/rake/task.rb
maid-0.7.0.alpha.2 lib/maid/rake/task.rb
maid-0.7.0.alpha.1 lib/maid/rake/task.rb
maid-0.6.1 lib/maid/rake/task.rb
maid-0.6.1.alpha.1 lib/maid/rake/task.rb
maid-0.6.0 lib/maid/rake/task.rb
maid-0.6.0.beta.2 lib/maid/rake/task.rb
maid-0.6.0.beta.1 lib/maid/rake/task.rb
maid-0.6.0.alpha.6 lib/maid/rake/task.rb
maid-0.6.0.alpha.5 lib/maid/rake/task.rb
maid-0.6.0.alpha.4 lib/maid/rake/task.rb