Class: RGitFlow::Tasks::Task

Inherits:
Rake::TaskLib
  • Object
show all
Includes:
Printing
Defined in:
lib/rgitflow/tasks/task.rb

Constant Summary

Constants included from Printing

Printing::DEBUG_PREFIX, Printing::ERROR_PREFIX, Printing::INPUT_PREFIX, Printing::STATUS_PREFIX

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Printing

#debug, #error, #prompt, #status

Constructor Details

#initialize(git, name, description, namespaces = ['rgitflow']) {|_self| ... } ⇒ Task

Returns a new instance of Task.

Yields:

  • (_self)

Yield Parameters:



30
31
32
33
34
35
36
37
38
39
# File 'lib/rgitflow/tasks/task.rb', line 30

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

  yield self if block_given?

  define
end

Instance Attribute Details

#afterProc

Runs a +Proc+ after the task

Returns:

  • (Proc)

    a proc to call after running the task



28
29
30
# File 'lib/rgitflow/tasks/task.rb', line 28

def after
  @after
end

#beforeProc

Runs a +Proc+ before the task

Returns:

  • (Proc)

    a proc to call before running the task



24
25
26
# File 'lib/rgitflow/tasks/task.rb', line 24

def before
  @before
end

#descriptionString

The description of the task

Returns:

  • (String)

    the task description



20
21
22
# File 'lib/rgitflow/tasks/task.rb', line 20

def description
  @description
end

#nameString

The name of the task

Returns:

  • (String)

    the task name



16
17
18
# File 'lib/rgitflow/tasks/task.rb', line 16

def name
  @name
end

#namespacesArray<String>

The namespaces of the task

Returns:

  • (Array<String>)

    the task namespaces



12
13
14
# File 'lib/rgitflow/tasks/task.rb', line 12

def namespaces
  @namespaces
end

Instance Method Details

#defineObject (protected)



43
44
45
46
47
48
49
50
# File 'lib/rgitflow/tasks/task.rb', line 43

def define
  desc @description unless ::Rake.application.last_comment
  task([*@namespaces, @name].join(":")) do
    before.call if before.is_a?(Proc)
    run
    after.call if after.is_a?(Proc)
  end
end

#runObject (protected)

Raises:

  • (NotImplementedError)


52
53
54
# File 'lib/rgitflow/tasks/task.rb', line 52

def run
  raise NotImplementedError
end