app/views/script/ruby.erb in tailog-0.5.9 vs app/views/script/ruby.erb in tailog-0.6.0

- old
+ new

@@ -1,11 +1,20 @@ <% begin %> - <% output = StringIO.new %> + <% irb = IRB::Irb.new nil, StringInputMethod.new(script + "\nexit\n") %> + <% IRB.conf[:MAIN_CONTEXT] = irb.context %> + <% IRB.conf[:OUTPUT] = [] %> <% begin %> - <% output.send :eval, script %> - <% output.string.each_line do |line| %> - <p><%= h line %></p> + <% irb.eval_input %> + <% IRB.Output.each do |key, line| %> + <% case key + when :stdin %> + <p class="text-info"><%= h line %></p> + <% when :stdout %> + <p><%= 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>