3 ms·
Something that prints out the state after running each line of code? No, I don't think so, but I believe it wouldn't be too hard to rig up something similar wit
by petercooper 8y ago
Something that prints out the state after running each line of code? No, I don't think so, but I believe it wouldn't be too hard to rig up something similar with TracePoint - https://ruby-doc.org/core-2.2.0/TracePoint.html https://ruby-doc.org/core-2.2.0/TracePoint.html - which is a built in Ruby way to trace code execution.
For example, dump this into a file and run it:
TracePoint.trace(:line) do |tp|
STDERR.puts "Ran: #{File.readlines(tp.path)[tp.lineno - 1]}"
end
a = 10
b = 5
puts a
a += b
puts a
puts b
It'll print out each line of code as it runs it. You could then parse each line for identifiers and print them out, etc. It'd be a project, but it's doable.