Skip to content
Josh Cheek edited this page Jan 8, 2017 · 1 revision

The toplevel of the lib is here. The binary uses the lib, so you can see an example of how to use it by reading that code. The default handler aggregates the event stream into a data structure which you can see here. Here's an example of the simplest library use case:

require 'seeing_is_believing'

# There are a lot of options you can pass here
handler = SeeingIsBelieving.call("[:a, :b, :c].each do |i|
                                    i.upcase
                                  end
                                 ")

# The default handler just aggregates the events into a consolidated result
result = handler.result

# Get at the line results like this
result[2]            # => [":A", ":B", ":C"]
result[2][0]         # => ":A"
result[2][1]         # => ":B"
result[2][2]         # => ":C"
result[2].join(", ") # => ":A, :B, :C"

# Some interesting process information
result.exitstatus # => 0
result.stdout     # => ""
result.stderr     # => ""

# A program can have multiple exceptions if it forks
result.exceptions # => []