app/views/script/ruby_debug.erb in tailog-0.5.1 vs app/views/script/ruby_debug.erb in tailog-0.5.2

- old
+ new

@@ -1,16 +1,28 @@ <% begin %> - <% binding = Object.new.send :binding %> - <% script.each_line do |line| %> - <% next if line.strip.empty? %> - <p class="text-info">&gt; <%= h line %></p> - <% begin %> - <% result = binding.eval(line).inspect %> - <p>=> <%= h result %></p> - <% rescue => error %> - <p class="text-danger"><%= h error.class %>: <%= h error.message %></p> - <% break %> + <% irb = IRB::Irb.new nil, StringInputMethod.new(script + "\n") %> + <% IRB.conf[:MAIN_CONTEXT] = irb.context %> + <% IRB.conf[:OUTPUT] = [] %> + + <% begin %> + <% irb.eval_input %> + <% IRB.Output.each do |key, line| %> + <% case key %> + <% when :stdin %> + <p><%= h line %></p> + <% when :stdout %> + <p class="text-info"><%= h line %></p> + <% when :stderr %> + <p class="text-danger"><%= h line %></p> + <% end %> <% end %> + <% rescue => error %> + <p class="text-danger"><%= h error.class %>: <%= h error.message %></p> + <% error.backtrace.each do |backtrace| %> + <p class="text-danger"> <%= h backtrace %></p> + <% end %> <% end %> + <% rescue => error %> <%= erb :error, locals: { error: error }, layout: false %> <% end %> +