Sha256: b249921d4278f5fa2040ef7184cf98cbf067030df98dce29a49f6631e43bc0c9

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

module ATP
  module Processors
    class ConditionExtractor < Processor
      attr_reader :results, :conditions

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

      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
      alias_method :on_flow_flag, :on_boolean_condition
      alias_method :on_test_result, :on_boolean_condition
      alias_method :on_test_executed, :on_boolean_condition

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

      def on_test(node)
        results << [conditions.uniq, node]
      end
      alias_method :on_group, :on_test
      alias_method :on_log, :on_test
      alias_method :on_enable_flow_flag, :on_test
      alias_method :on_disable_flow_flag, :on_test
      alias_method :on_cz, :on_test
      alias_method :on_set_result, :on_test
      alias_method :on_render, :on_test
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
atp-0.2.1 lib/atp/processors/condition_extractor.rb