Sha256: cb873fd851d9c64bccb9d5949314597d832396580d851b19e02a4cf710fb8f85

Contents?: true

Size: 1.85 KB

Versions: 5

Compression:

Stored size: 1.85 KB

Contents

require 'mattock/task'
require 'mattock/command-line'

module Mattock
  module CommandTaskMixin
    include CommandLineDSL

    def self.included(sub)
      sub.extend CommandLineDSL
      sub.runtime_setting(:verify_command, nil)
      sub.runtime_setting(:command)
    end

    def resolve_runtime_configuration
      super
      #If there's a second troublesome command, this becomes a class-level
      #array
      if not verify_command.nil? and verify_command.name == "bundle"
        unless BundleCommandTask === self
          warn "Verify command is 'bundle' - this sometimes has unexpected results.  Consider BundleCommandTask"
        end
      end

      if command.name == "bundle"
        unless BundleCommandTask === self
          warn "Command is 'bundle' - this sometimes has unexpected results.  Consider BundleCommandTask"
        end
      end
    end

    def verify_command
      if @verify_command.respond_to?(:call)
        @verify_command = @verify_command.call
      end
      @verify_command
    end

    def decorated(command)
      command
    end

    def action(args)
      decorated(command).must_succeed!
    end

    def check_verification_command
      !decorated(verify_command).succeeds?
    end

    def needed?
      finalize_configuration
      if verify_command.nil?
        super
      else
        check_verification_command
      end
    end
  end

  class Rake::CommandTask < Rake::Task
    include CommandTaskMixin
    setting :task_name, :run
  end

  class Rake::FileCommandTask < Rake::FileTask
    include CommandTaskMixin

    setting :target_path

    def resolve_configuration
      super
      self.target_path ||= task_name
    end
  end

  class CommandTask < DeprecatedTaskAPI
    def target_class; Rake::CommandTask; end
  end

  class FileCommandTask < DeprecatedTaskAPI
    def target_class; Rake::FileCommandTask; end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mattock-0.7.1 lib/mattock/command-task.rb
mattock-0.7.0 lib/mattock/command-task.rb
mattock-0.5.3 lib/mattock/command-task.rb
mattock-0.5.2 lib/mattock/command-task.rb
mattock-0.5.0 lib/mattock/command-task.rb