Class: ATP::Processors::ConditionExtractor

Inherits:
ATP::Processor show all
Defined in:
lib/atp/processors/condition_extractor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ATP::Processor

#handler_missing, #n, #n0, #n1, #process

Instance Attribute Details

#conditionsObject (readonly)

Returns the value of attribute conditions.



4
5
6
# File 'lib/atp/processors/condition_extractor.rb', line 4

def conditions
  @conditions
end

#resultsObject (readonly)

Returns the value of attribute results.



4
5
6
# File 'lib/atp/processors/condition_extractor.rb', line 4

def results
  @results
end

Instance Method Details

#on_boolean_condition(node) ⇒ Object Also known as: on_flow_flag, on_test_result, on_test_executed, on_job



13
14
15
16
17
18
19
20
# File 'lib/atp/processors/condition_extractor.rb', line 13

def on_boolean_condition(node)
  children = node.children.dup
  name = children.shift
  state = children.shift
  conditions << node.updated(nil, [name, state])
  process_all(children)
  conditions.pop
end

#on_condition(node) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/atp/processors/condition_extractor.rb', line 26

def on_condition(node)
  children = node.children.dup
  name = children.shift
  conditions << node.updated(nil, [name])
  process_all(children)
  conditions.pop
end

#on_test(node) ⇒ Object Also known as: on_group, on_log, on_enable_flow_flag, on_disable_flow_flag, on_cz, on_set_result, on_render



34
35
36
# File 'lib/atp/processors/condition_extractor.rb', line 34

def on_test(node)
  results << [conditions.uniq, node]
end

#run(nodes) ⇒ Object



6
7
8
9
10
11
# File 'lib/atp/processors/condition_extractor.rb', line 6

def run(nodes)
  @results = []
  @conditions = []
  process_all(nodes)
  @results
end