Sha256: bec520ea7fde588ed8f7b489dd40ee06ab901e10e458ab2eae47b1fe402f54fd

Contents?: true

Size: 819 Bytes

Versions: 3

Compression:

Stored size: 819 Bytes

Contents

<% begin %>

  <% # redefine print, puts & p

    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 %>
  <% 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 %>
  <%= erb :error, locals: { error: error }, layout: false %>
<% end %>

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tailog-0.4.8 app/views/script/ruby.erb
tailog-0.4.7 app/views/script/ruby.erb
tailog-0.4.6 app/views/script/ruby.erb