Sha256: f5a3425531fe60692518fe2125885825ee00d7bf8bea4e1a6970f4b7bda03e5c

Contents?: true

Size: 1.12 KB

Versions: 5

Compression:

Stored size: 1.12 KB

Contents

module ATP
  module Processors
    # Adds the flow ID to all ids and label names
    class FlowID < Processor
      attr_reader :id

      def run(node, id)
        @id = id
        process(node)
      end

      def on_id(node)
        if node.value =~ /^extern/
          node
        else
          node.updated(nil, ["#{node.value}_#{id}"])
        end
      end

      def on_if_failed(node)
        tid, *nodes = *node
        if tid.is_a?(Array)
          tid = tid.map do |tid|
            if tid =~ /^extern/
              tid
            else
              "#{tid}_#{id}"
            end
          end
        else
          if tid !~ /^extern/
            tid = "#{tid}_#{id}"
          end
        end
        node.updated(nil, [tid] + process_all(nodes))
      end
      alias_method :on_if_any_failed, :on_if_failed
      alias_method :on_if_all_failed, :on_if_failed
      alias_method :on_if_passed, :on_if_failed
      alias_method :on_if_any_passed, :on_if_failed
      alias_method :on_if_all_passed, :on_if_failed
      alias_method :on_if_ran, :on_if_failed
      alias_method :on_unless_ran, :on_if_failed
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
atp-1.1.3 lib/atp/processors/flow_id.rb
atp-1.1.2 lib/atp/processors/flow_id.rb
atp-1.1.1 lib/atp/processors/flow_id.rb
atp-1.1.0 lib/atp/processors/flow_id.rb
atp-1.0.0 lib/atp/processors/flow_id.rb