Class: GitCompound::Command::Procedure::Procedure

Inherits:
Object
  • Object
show all
Extended by:
Logger::Debugger
Defined in:
lib/git_compound/logger/debug/procedure.rb,
lib/git_compound/command/procedure/procedure.rb

Overview

Abstract Procedure class

Direct Known Subclasses

Build, BuildLock, BuildManifest, Check, Tasks, Update

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logger::Debugger

debug_after, debug_before

Constructor Details

#initialize(_opts) ⇒ Procedure

Returns a new instance of Procedure.



7
8
# File 'lib/git_compound/command/procedure/procedure.rb', line 7

def initialize(_opts)
end

Class Attribute Details

.stepsObject (readonly)

Returns the value of attribute steps.



30
31
32
# File 'lib/git_compound/command/procedure/procedure.rb', line 30

def steps
  @steps
end

Class Method Details

.optionsObject

Valid options available for this procedure see Element::Option



35
36
37
# File 'lib/git_compound/command/procedure/procedure.rb', line 35

def options
  {}
end

.to_sObject

Name of procedure



41
42
43
44
45
46
47
48
# File 'lib/git_compound/command/procedure/procedure.rb', line 41

def to_s
  name.split('::').last
    .gsub(/::/, '/')
    .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
    .gsub(/([a-z\d])([A-Z])/, '\1_\2')
    .tr('-', '_')
    .downcase
end

Instance Method Details

#executeObject

Main procedure entry point



18
19
20
21
22
# File 'lib/git_compound/command/procedure/procedure.rb', line 18

def execute
  self.class.steps.to_h.keys.each do |name|
    execute_step(name)
  end
end

#execute!Object

Method with additional messages etc.



12
13
14
# File 'lib/git_compound/command/procedure/procedure.rb', line 12

def execute!
  execute
end

#execute_step(name) ⇒ Object



24
25
26
27
# File 'lib/git_compound/command/procedure/procedure.rb', line 24

def execute_step(name)
  step_proc = self.class.steps.to_h[name]
  instance_eval(&step_proc) if step_proc
end