Class: RGitFlow::Tasks::Task

Inherits:
Rake::TaskLib
  • Object
show all
Includes:
Console, 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 Console

#execute, #invoke, #multi_task, #task?

Methods included from Printing

#debug, #error, #prompt, #status

Constructor Details

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

Returns a new instance of Task.

Yields:

  • (_self)

Yield Parameters:



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/rgitflow/tasks/task.rb', line 33

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

Instance Attribute Details

#afterProc

Runs a +Proc+ after the task

Returns:

  • (Proc)

    a proc to call after running the task



31
32
33
# File 'lib/rgitflow/tasks/task.rb', line 31

def after
  @after
end

#beforeProc

Runs a +Proc+ before the task

Returns:

  • (Proc)

    a proc to call before running the task



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

def before
  @before
end

#dependenciesArray<String>

The dependencies of the task

Returns:

  • (Array<String>)

    the dependencies of the task



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

def dependencies
  @dependencies
end

#descriptionString

The description of the task

Returns:

  • (String)

    the task description



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

def description
  @description
end

#nameString

The name of the task

Returns:

  • (String)

    the task name



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

def name
  @name
end

#namespacesArray<String>

The namespaces of the task

Returns:

  • (Array<String>)

    the task namespaces



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

def namespaces
  @namespaces
end

Instance Method Details

#defineObject (protected)



48
49
50
51
52
53
54
55
56
57
# File 'lib/rgitflow/tasks/task.rb', line 48

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

#runObject (protected)

Raises:

  • (NotImplementedError)


59
60
61
# File 'lib/rgitflow/tasks/task.rb', line 59

def run
  raise NotImplementedError
end