Class: DTK::DSL::Template::V1::Workflow

Inherits:
DTK::DSL::Template::V1 show all
Defined in:
lib/dsl/template/v1/workflow.rb,
lib/dsl/template/v1/workflow/semantic_parse.rb

Defined Under Namespace

Modules: Constant, Hashkey Classes: SemanticParse

Constant Summary

Constants inherited from DTK::DSL::Template::V1

VERSION

Instance Attribute Summary

Attributes included from NestedDSLFile::Mixin

#nested_file_content

Attributes included from Generation::Mixin

#filter, #top

Attributes included from Parsing::Mixin

#file_obj, #parent_key

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DTK::DSL::Template::V1

#dsl_version, #template_version

Methods inherited from DTK::DSL::Template

#add, create_for_generation, create_for_parsing, #initialize, #merge, #req, #set, #set?, #val

Methods included from Parsing::ClassMixin

#elements_collection_type, #empty_input_hash, #file_parser_output_array, #file_parser_output_hash, #parse_element, #parse_elements

Methods included from Generation::ClassMixin

#generate_elements

Methods included from Generation::Mixin

#generate?, #generate_yaml_file_path__content_array, #generate_yaml_object, #generate_yaml_object?, #generate_yaml_text, #yaml_object_type

Methods included from Parsing::Mixin

#parse, #parsing_error

Constructor Details

This class inherits a constructor from DTK::DSL::Template

Class Method Details

.generate_elements(workflows_content, parent) ⇒ Object

For generation



61
62
63
64
65
# File 'lib/dsl/template/v1/workflow.rb', line 61

def self.generate_elements(workflows_content, parent)
  workflows_content.inject({}) do |h, (name, workflow)| 
    h.merge(name => generate_element(workflow, parent))
  end
end

.parse_elements(input_hash, parent_info) ⇒ Object



42
43
44
45
46
# File 'lib/dsl/template/v1/workflow.rb', line 42

def self.parse_elements(input_hash, parent_info)
  input_hash.inject(file_parser_output_hash) do |h, (name, workflow)|
    h.merge(name => parse_element(workflow, parent_info, :index => name))
  end
end

Instance Method Details

#generate!Object



67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/dsl/template/v1/workflow.rb', line 67

def generate!
  set? :Name, val(:Name)
  set? :SubtaskOrder, val(:SubtaskOrder)
  if subtasks = val(:Subtasks)
    generated_subtasks = subtasks.map do |subtask|
      generated_subtask = generate_subtask(subtask)
      generated_subtask.empty? ? nil : generated_subtask
    end.compact
    set :Subtasks, generated_subtasks unless generated_subtasks.empty?
  end
  merge(uninterpreted_keys)
end

#parse!Object



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/dsl/template/v1/workflow.rb', line 48

def parse!
  remove_processed_keys_from_input_hash! do
    set? :Import, input_key_value?(:Import)
    set? :Flatten, input_key_value?(:Flatten)
    set? :Name, input_key_value?(:Name)
    set? :SubtaskOrder, input_key_value?(:SubtaskOrder)
    set? :Subtasks, parse_subtasks?
  end
  # handle keys not processed
  merge change_strings_to_symbols(input_hash) unless input_hash.empty?
end

#parser_output_typeObject

For parsing



38
39
40
# File 'lib/dsl/template/v1/workflow.rb', line 38

def parser_output_type
  :hash
end