Sha256: a637f6e03e2f5a02a33965c44e9ebc86d6ca9b21cf26b35be7cc8a7d2083068f

Contents?: true

Size: 1.56 KB

Versions: 9

Compression:

Stored size: 1.56 KB

Contents

require 'rake'
require 'rake/tasklib'

module RGitFlow
  module Tasks
    class Task < ::Rake::TaskLib
      include RGitFlow::Printing
      include RGitFlow::Console
      # The namespaces of the task
      # @return [Array<String>] the task namespaces
      attr_accessor :namespaces

      # The name of the task
      # @return [String] the task name
      attr_accessor :name

      # The description of the task
      # @return [String] the task description
      attr_accessor :description

      # The dependencies of the task
      # @return [Array<String>] the dependencies of the task
      attr_accessor :dependencies

      # Runs a +Proc+ before the task
      # @return [Proc] a proc to call before running the task
      attr_accessor :before

      # Runs a +Proc+ after the task
      # @return [Proc] a proc to call after running the task
      attr_accessor :after

      def initialize(git, name, description, namespaces = ['rgitflow'],
                     dependencies = [])
        @git = git
        @name = name
        @description = description
        @namespaces = namespaces
        @dependencies = dependencies

        yield self if block_given?

        define
      end

      protected

      def define
        full_name = [*@namespaces, @name].join(":")

        desc @description unless ::Rake.application.last_comment
        task full_name => @dependencies do
          before.call if before.is_a?(Proc)
          run
          after.call if after.is_a?(Proc)
        end
      end

      def run
        raise NotImplementedError
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rgitflow-0.2.2 lib/rgitflow/tasks/task.rb
rgitflow-0.2.1.pre.alpha.pre.32 lib/rgitflow/tasks/task.rb
rgitflow-0.2.1.pre.alpha.pre.28 lib/rgitflow/tasks/task.rb
rgitflow-0.2.0.pre.alpha.pre.27 lib/rgitflow/tasks/task.rb
rgitflow-0.2.0.pre.alpha.pre.26 lib/rgitflow/tasks/task.rb
rgitflow-0.2.0.pre.alpha.pre.25 lib/rgitflow/tasks/task.rb
rgitflow-0.2.0 lib/rgitflow/tasks/task.rb
rgitflow-0.2.0.pre.alpha.pre.23 lib/rgitflow/tasks/task.rb
rgitflow-0.2.0.pre.alpha.pre.22 lib/rgitflow/tasks/task.rb