Class: Steplib::WorkflowUtils

Inherits:
Object
  • Object
show all
Defined in:
lib/steplib/workflow_utils.rb

Class Method Summary collapse

Class Method Details

.create_workflow_base_templateObject



16
17
18
19
20
21
22
23
# File 'lib/steplib/workflow_utils.rb', line 16

def create_workflow_base_template
  workflow_base_template = {
    'format_version' => '0.9.0',
    'environments' => [],
    'steps' => []
  }
  return workflow_base_template
end

.create_workflow_environment_item(title, mapped_to, value, is_expand) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/steplib/workflow_utils.rb', line 7

def create_workflow_environment_item(title, mapped_to, value, is_expand)
  return {
    'title' => title.to_s,         # string
    'mapped_to' => mapped_to.to_s,    # string
    'value' => value.to_s,        # string
    'is_expand' => !!is_expand      # bool
  }
end

.create_workflow_from_step_versions(steplib_step_versions, workflow_environments = []) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/steplib/workflow_utils.rb', line 33

def create_workflow_from_step_versions(steplib_step_versions, workflow_environments=[])
  workflow_data = create_workflow_base_template()
  workflow_data['steps'] = steplib_step_versions.map.with_index { |steplib_step_ver, idx|
    # return:
    create_workflow_step_from_steplib_step(steplib_step_ver, idx, false)
  }
  workflow_data['environments'] = workflow_environments
  return workflow_data
end

.create_workflow_step_from_steplib_step(steplib_step, position_in_workflow, is_always_run = false) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/steplib/workflow_utils.rb', line 25

def create_workflow_step_from_steplib_step(steplib_step, position_in_workflow, is_always_run=false)
  wf_step = HashUtils.deep_copy(steplib_step).merge({
    'position_in_workflow' => position_in_workflow.to_i,
    'is_always_run' => !!is_always_run,
    })
  return wf_step
end