Class: RGitFlow::Tasks::SCM::Task

Inherits:
Task
  • Object
show all
Defined in:
lib/rgitflow/tasks/scm/task.rb

Direct Known Subclasses

Status, Tag

Constant Summary

Constants included from Printing

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

Instance Attribute Summary

Attributes inherited from Task

#after, #before, #dependencies, #description, #name, #namespaces

Instance Method Summary collapse

Methods inherited from Task

#define, #run

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', 'scm'], dependencies = []) ⇒ Task

Returns a new instance of Task.



7
8
9
10
# File 'lib/rgitflow/tasks/scm/task.rb', line 7

def initialize(git, name, description, namespaces=['rgitflow', 'scm'],
               dependencies=[])
  super(git, name, description, namespaces, dependencies)
end

Instance Method Details

#dirty?Boolean

Returns:

  • (Boolean)


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

def dirty?
  @git.diff.size > 0
end


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/rgitflow/tasks/scm/task.rb', line 16

def print_status
  added    = []
  modified = []
  deleted  = []

  @git.diff.each { |f|
    if f.type == 'new'
      added << f
    elsif f.type == 'modified'
      modified << f
    elsif f.type == 'deleted'
      deleted << f
    end
  }

  debug 'added'
  added.each { |f|
    debug "  #{ANSI::Constants::GREEN}#{ANSI::Constants::BRIGHT}"\
          "#{f.path}#{ANSI::Constants::CLEAR}"
  }

  debug 'modified'
  modified.each { |f|
    debug "  #{ANSI::Constants::YELLOW}#{ANSI::Constants::BRIGHT}"\
          "#{f.path}#{ANSI::Constants::CLEAR}"
  }

  debug 'deleted'
  deleted.each { |f|
    debug "  #{ANSI::Constants::RED}#{ANSI::Constants::BRIGHT}"\
          "#{f.path}#{ANSI::Constants::CLEAR}"
  }
end