Sha256: 4cb17f80e231af6a0550426a6c4f424d7251d61387dc59bb3d0ff9284a0ae8e5

Contents?: true

Size: 759 Bytes

Versions: 34

Compression:

Stored size: 759 Bytes

Contents

<% begin %>
  <% Open3.popen3("bash -x -e") do |stdin, stdout, stderr, wait_thr| %>
    <% output = [] %>
    <% Thread.new do until (line = stdout.gets).nil? do output << [ :stdout, line ] end end %>
    <% Thread.new do until (line = stderr.gets).nil? do output << [ :stderr, line ] end end %>

    <% stdin.puts script %>
    <% stdin.puts "exit" %>
    <% wait_thr.join %>

    <% output.each do |key, line| %>
      <% if key == :stdout %>
        <p><%= h line %></p>
      <% elsif line =~ /^\+ (.*)/ %>
        <p class="text-info">$ <%= h $1 %></p>
      <% else %>
        <p class="text-danger"><%= h line %></p>
      <% end %>
    <% end %>
  <% end %>
<% rescue => error %>
  <%= erb :error, locals: { error: error }, layout: false %>
<% end %>

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
tailog-0.4.6 app/views/script/bash.erb
tailog-0.4.5 app/views/script/bash.erb
tailog-0.4.3 app/views/script/bash.erb
tailog-0.4.2 app/views/script/bash.erb
tailog-0.4.1 app/views/script/bash.erb
tailog-0.4.0 app/views/script/bash.erb
tailog-0.3.7 app/views/script/bash.erb
tailog-0.3.6 app/views/script/bash.erb
tailog-0.3.5 app/views/script/bash.erb
tailog-0.3.4 app/views/script/bash.erb
tailog-0.3.3 app/views/script/bash.erb
tailog-0.3.2 app/views/script/bash.erb
tailog-0.3.1 app/views/script/bash.erb
tailog-0.3.0 app/views/script/bash.erb