tailog 0.6.8 → 0.6.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/views/script/bash.erb +9 -17
- data/app/views/script/ruby.erb +9 -22
- data/lib/tailog/ext/bash.rb +23 -0
- data/lib/tailog/ext/irb.rb +5 -3
- data/lib/tailog/version.rb +1 -1
- data/lib/tailog.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f16beba202bc6b12214c29111e8902b13d4d57f9
|
4
|
+
data.tar.gz: e9dff97596dfb7da548391f802943a498c944da7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99b581a2eb9737d4433601b9c64d6e77f0c2fc213566cbf768bfc0680642a33ef9dfcf6f8908c4a323e3412e901f34819abf267a97207fefadaeb8233e6037b3
|
7
|
+
data.tar.gz: 48909e91421c2ae410385c893ceb1a0e7ab7a649560d2930edf1ced629fa9025692b53f18533cf0dba5c047bf4211b4a1efade72dee7482353064cefee783867
|
data/app/views/script/bash.erb
CHANGED
@@ -1,21 +1,13 @@
|
|
1
1
|
<% begin %>
|
2
|
-
<%
|
3
|
-
|
4
|
-
<%
|
5
|
-
|
6
|
-
|
7
|
-
<%
|
8
|
-
|
9
|
-
<%
|
10
|
-
|
11
|
-
<% output.each do |key, line| %>
|
12
|
-
<% if key == :stdout %>
|
13
|
-
<p><%= h line %></p>
|
14
|
-
<% elsif line =~ /^\+ (.*)/ %>
|
15
|
-
<p class="text-info">$ <%= h $1 %></p>
|
16
|
-
<% else %>
|
17
|
-
<p class="text-danger"><%= h line %></p>
|
18
|
-
<% end %>
|
2
|
+
<% output = Bash.evaluate_string script %>
|
3
|
+
<% output.each do |key, line| %>
|
4
|
+
<% case key
|
5
|
+
when :stdin %>
|
6
|
+
<p class="text-info"><%= h line %></p>
|
7
|
+
<% when :stdout %>
|
8
|
+
<p><%= h line %></p>
|
9
|
+
<% when :stderr %>
|
10
|
+
<p class="text-danger"><%= h line %></p>
|
19
11
|
<% end %>
|
20
12
|
<% end %>
|
21
13
|
<% rescue => error %>
|
data/app/views/script/ruby.erb
CHANGED
@@ -1,28 +1,15 @@
|
|
1
1
|
<% begin %>
|
2
|
-
<%
|
3
|
-
<%
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
<%
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
<p class="text-info"><%= h line %></p>
|
12
|
-
<% when :stdout %>
|
13
|
-
<p><%= h line %></p>
|
14
|
-
<% when :stderr %>
|
15
|
-
<p class="text-danger"><%= h line %></p>
|
16
|
-
<% end %>
|
17
|
-
<% end %>
|
18
|
-
<% rescue => error %>
|
19
|
-
<p class="text-danger"><%= h error.class %>: <%= h error.message %></p>
|
20
|
-
<% error.backtrace.each do |backtrace| %>
|
21
|
-
<p class="text-danger"> <%= h backtrace %></p>
|
2
|
+
<% output = IRB.evaluate_string script %>
|
3
|
+
<% output.each do |key, line| %>
|
4
|
+
<% case key
|
5
|
+
when :stdin %>
|
6
|
+
<p class="text-info"><%= h line %></p>
|
7
|
+
<% when :stdout %>
|
8
|
+
<p><%= h line %></p>
|
9
|
+
<% when :stderr %>
|
10
|
+
<p class="text-danger"><%= h line %></p>
|
22
11
|
<% end %>
|
23
12
|
<% end %>
|
24
|
-
|
25
13
|
<% rescue => error %>
|
26
14
|
<%= erb :error, locals: { error: error }, layout: false %>
|
27
15
|
<% end %>
|
28
|
-
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Bash
|
2
|
+
def self.evaluate_string script
|
3
|
+
output = []
|
4
|
+
|
5
|
+
Open3.popen3("bash -x -e") do |stdin, stdout, stderr, wait_thr|
|
6
|
+
Thread.new do until (line = stdout.gets).nil? do output << [ :stdout, line ] end end
|
7
|
+
Thread.new do until (line = stderr.gets).nil? do output << [ :stderr, line ] end end
|
8
|
+
|
9
|
+
stdin.puts script
|
10
|
+
stdin.puts "exit"
|
11
|
+
|
12
|
+
wait_thr.join
|
13
|
+
end
|
14
|
+
|
15
|
+
output.map do |key, line|
|
16
|
+
if key == :stderr && line =~ /^\+ (.*)/
|
17
|
+
[:stdin, line]
|
18
|
+
else
|
19
|
+
[key, line]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/tailog/ext/irb.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
require 'irb'
|
2
2
|
|
3
3
|
IRB.init_config nil
|
4
|
-
IRB.conf[:PROMPT_MODE] = :DEFAULT
|
5
|
-
IRB.conf[:VERBOSE] = false
|
6
4
|
|
7
5
|
class << IRB
|
8
6
|
def Output
|
@@ -14,9 +12,13 @@ class << IRB
|
|
14
12
|
conf[:VERBOSE] = false
|
15
13
|
conf[:OUTPUT] = []
|
16
14
|
|
17
|
-
irb = Irb.new nil, StringInputMethod.new(string + "\n")
|
15
|
+
irb = IRB::Irb.new nil, StringInputMethod.new(string + "\nexit\n")
|
18
16
|
conf[:MAIN_CONTEXT] = irb.context
|
19
17
|
irb.eval_input
|
18
|
+
|
19
|
+
result = conf[:OUTPUT]
|
20
|
+
conf[:OUTPUT] = nil
|
21
|
+
result
|
20
22
|
end
|
21
23
|
|
22
24
|
alias_method :raw_irb_exit, :irb_exit
|
data/lib/tailog/version.rb
CHANGED
data/lib/tailog.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tailog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bbtfr
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -95,6 +95,7 @@ files:
|
|
95
95
|
- bin/setup
|
96
96
|
- lib/tailog.rb
|
97
97
|
- lib/tailog/eval.rb
|
98
|
+
- lib/tailog/ext/bash.rb
|
98
99
|
- lib/tailog/ext/file.rb
|
99
100
|
- lib/tailog/ext/integer.rb
|
100
101
|
- lib/tailog/ext/irb.rb
|