Class: Step

Inherits:
Object
  • Object
show all
Defined in:
lib/wrkflo/step.rb

Direct Known Subclasses

EmacsStep, SSHFSStep, SSHStep, SublimeStep

Constant Summary collapse

@@step_map =

A hash of step aliases to their respective classes. This map determines the class that a given step in a project will be transformed into.

{ }

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, config, project = nil) ⇒ Step

Returns a new instance of Step.



22
23
24
25
26
27
28
29
# File 'lib/wrkflo/step.rb', line 22

def initialize name, config, project=nil
  # The name for this step
  @name = name
  # The options that define this step
  @config = config
  # The project that this step belongs to
  @project = project
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



2
3
4
# File 'lib/wrkflo/step.rb', line 2

def config
  @config
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/wrkflo/step.rb', line 2

def name
  @name
end

#projectObject

Returns the value of attribute project.



2
3
4
# File 'lib/wrkflo/step.rb', line 2

def project
  @project
end

Class Method Details

.add_alias(name) ⇒ Object

Add an alias for this class to the step map. Used by subclasses to register their definitions



11
12
13
# File 'lib/wrkflo/step.rb', line 11

def add_alias name
  @@step_map[name.to_sym] = self
end

.create(name = '', config = {}, project = nil) ⇒ Object

Create a new instance of a Step based on the step map entry. If none exists, a generic Step is created.



17
18
19
# File 'lib/wrkflo/step.rb', line 17

def create name='', config={}, project=nil
  @@step_map[name.to_sym].new(name, config, project) or Step.new(name, config, project)
end

Instance Method Details

#log(message) ⇒ Object

A pass through to this step’s project’s log. If this step has no project, a simple puts call is used instead.



33
34
35
# File 'lib/wrkflo/step.rb', line 33

def log message
  @project ? @project.log(message) : puts(message)
end

#runObject

The code to run when running this step normally



43
44
45
# File 'lib/wrkflo/step.rb', line 43

def run
  log "Nothing to do."
end

#unrunObject

The code to run when running this step backwards



47
48
49
# File 'lib/wrkflo/step.rb', line 47

def unrun
  log "Nothing to do."
end