app/views/script/ruby.erb in tailog-0.4.8 vs app/views/script/ruby.erb in tailog-0.5.0
- old
+ new
@@ -1,34 +1,16 @@
<% begin %>
- <% # redefine print, puts & p
+ <% input = StringIO.new(script) %>
+ <% output = StringIO.new %>
+ <% binding = Object.new.send :binding %>
- OUTPUT = StringIO.new
-
- def print *args
- OUTPUT.print *args
- end
-
- def puts *args
- OUTPUT.puts *args
- end
-
- def p *args
- OUTPUT.puts *args.map(&:inspect)
- end
-
- %>
-
<% begin %>
- <% binding = Object.new.send :binding %>
- <% binding.eval(script, "(script)", 1) %>
- <% OUTPUT.string.each_line do |line| %>
- <p><%= h line %></p>
- <% end %>
+ <% Pry.start binding, input: input, output: output %>
+ <%= h output.string %>
<% rescue => error %>
<p class="text-danger"><%= h error.class %>: <%= h error.message %></p>
<% error.backtrace.each do |backtrace| %>
- <% next unless backtrace.start_with? "(script)" %>
<p class="text-danger"> <%= h backtrace %></p>
<% end %>
<% end %>
<% rescue => error %>