Sha256: ad6aa28c2135251862ca77387c9bac3b45520eb6a546155cf1d3dcc1f7bc08a0

Contents?: true

Size: 523 Bytes

Versions: 5

Compression:

Stored size: 523 Bytes

Contents

module ATP
  module Processors
    # Removes any empty on_pass and on_fail branches
    class EmptyBranchRemover < Processor
      # Delete any on-fail child if it's 'empty'
      def on_test(node)
        if on_pass = node.find(:on_pass)
          node = node.remove(on_pass) if on_pass.children.empty?
        end
        if on_fail = node.find(:on_fail)
          node = node.remove(on_fail) if on_fail.children.empty?
        end
        node = node.updated(nil, process_all(node.children))
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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