tailog 0.5.1 → 0.5.2
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/index.erb +14 -8
- data/app/views/script/ruby.erb +4 -5
- data/app/views/script/ruby_debug.erb +22 -10
- data/lib/tailog/ext/irb.rb +51 -0
- 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: dbe0ce3cbc6cfee5b3f0654a74e6c1b7b88e3095
|
4
|
+
data.tar.gz: 64b6ce2ddab91b524011d8d9e826ad70df0c5c42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a8eabf2bd84d64aebb6bf3670ff0a6cfb87b8661b1992838f2a58fdb569754cce0f07f842bb3207554b60f376860a6390998e9fe241af73e5d0d48a86d81821
|
7
|
+
data.tar.gz: 390fb9fbc007d02fd2d6a9acaec2adad9aa4e0e2c011475d8b05a674df2c85081ef852129e7c64e1f0fdb5f84e44ca5920a78bff2275c921fe7c95ce3d569c61
|
data/app/views/script/index.erb
CHANGED
@@ -8,7 +8,10 @@
|
|
8
8
|
<option value="ruby_debug">Ruby (Debug Mode)</option>
|
9
9
|
<option value="bash">Bash</option>
|
10
10
|
</select>
|
11
|
-
<button type="submit" class="btn btn-primary">Submit</button>
|
11
|
+
<button id="submit-button" type="submit" class="btn btn-primary">Submit</button>
|
12
|
+
</div>
|
13
|
+
<div>
|
14
|
+
Press <kbd><kbd>Ctrl</kbd> + <kbd>Enter</kbd></kbd> to submit code
|
12
15
|
</div>
|
13
16
|
</form>
|
14
17
|
|
@@ -19,14 +22,17 @@
|
|
19
22
|
<script type="text/javascript" src="javascripts/mode/shell.js"></script>
|
20
23
|
<link rel="stylesheet" type="text/css" href="stylesheets/codemirror.css">
|
21
24
|
<script type="text/javascript">
|
25
|
+
var mac = CodeMirror.keyMap.default == CodeMirror.keyMap.macDefault;
|
26
|
+
CodeMirror.keyMap.default["Tab"] = function(editor) {
|
27
|
+
var spaces = Array(editor.getOption("indentUnit") + 1).join(" ");
|
28
|
+
editor.replaceSelection(spaces);
|
29
|
+
};
|
30
|
+
CodeMirror.keyMap.default[(mac ? "Cmd" : "Ctrl") + "-Enter"] = function(editor) {
|
31
|
+
$("#submit-button").trigger('click');
|
32
|
+
};
|
33
|
+
|
22
34
|
var editor = CodeMirror.fromTextArea($("#editor")[0], {
|
23
|
-
lineNumbers: true
|
24
|
-
extraKeys: {
|
25
|
-
Tab: function(editor) {
|
26
|
-
var spaces = Array(editor.getOption("indentUnit") + 1).join(" ");
|
27
|
-
editor.replaceSelection(spaces);
|
28
|
-
}
|
29
|
-
}
|
35
|
+
lineNumbers: true
|
30
36
|
});
|
31
37
|
|
32
38
|
ModeMap = {
|
data/app/views/script/ruby.erb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
<% begin %>
|
2
|
-
|
3
|
-
<% input = StringIO.new(script) %>
|
4
2
|
<% output = StringIO.new %>
|
5
|
-
<% binding = Object.new.send :binding %>
|
6
3
|
|
7
4
|
<% begin %>
|
8
|
-
<%
|
9
|
-
|
5
|
+
<% output.send :eval, script %>
|
6
|
+
<% output.string.each_line do |line| %>
|
7
|
+
<p><%= h line %></p>
|
8
|
+
<% end %>
|
10
9
|
<% rescue => error %>
|
11
10
|
<p class="text-danger"><%= h error.class %>: <%= h error.message %></p>
|
12
11
|
<% error.backtrace.each do |backtrace| %>
|
@@ -1,16 +1,28 @@
|
|
1
1
|
<% begin %>
|
2
|
-
<%
|
3
|
-
<%
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
2
|
+
<% irb = IRB::Irb.new nil, StringInputMethod.new(script + "\n") %>
|
3
|
+
<% IRB.conf[:MAIN_CONTEXT] = irb.context %>
|
4
|
+
<% IRB.conf[:OUTPUT] = [] %>
|
5
|
+
|
6
|
+
<% begin %>
|
7
|
+
<% irb.eval_input %>
|
8
|
+
<% IRB.Output.each do |key, line| %>
|
9
|
+
<% case key %>
|
10
|
+
<% when :stdin %>
|
11
|
+
<p><%= h line %></p>
|
12
|
+
<% when :stdout %>
|
13
|
+
<p class="text-info"><%= 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>
|
12
22
|
<% end %>
|
13
23
|
<% end %>
|
24
|
+
|
14
25
|
<% rescue => error %>
|
15
26
|
<%= erb :error, locals: { error: error }, layout: false %>
|
16
27
|
<% end %>
|
28
|
+
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'irb'
|
2
|
+
|
3
|
+
IRB.setup nil
|
4
|
+
|
5
|
+
def IRB.Output
|
6
|
+
IRB.conf[:OUTPUT]
|
7
|
+
end
|
8
|
+
|
9
|
+
class IRB::WorkSpace
|
10
|
+
def evaluate(context, statements, file = __FILE__, line = __LINE__)
|
11
|
+
@after_ruby_debug_erb = false
|
12
|
+
eval(statements, @binding, file, line)
|
13
|
+
end
|
14
|
+
|
15
|
+
FILTER_BACKTRACE_REGEX = /#{__FILE__}/
|
16
|
+
def filter_backtrace backtrace
|
17
|
+
return if @after_ruby_debug_erb
|
18
|
+
if backtrace =~ FILTER_BACKTRACE_REGEX
|
19
|
+
@after_ruby_debug_erb = true
|
20
|
+
return
|
21
|
+
else
|
22
|
+
backtrace.sub(/:\s*in `irb_binding'/, '')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class IRB::Irb
|
28
|
+
def output_value
|
29
|
+
context = IRB.CurrentContext
|
30
|
+
IRB.Output << [ :stdout, context.return_format % context.inspect_last_value ]
|
31
|
+
end
|
32
|
+
|
33
|
+
def print *args
|
34
|
+
IRB.Output << [ :stderr, args.join ]
|
35
|
+
end
|
36
|
+
|
37
|
+
def printf format, *args
|
38
|
+
IRB.Output << [ :stderr, format % args ]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
class StringInputMethod < StringIO
|
43
|
+
attr_accessor :prompt
|
44
|
+
def encoding; string.encoding end
|
45
|
+
|
46
|
+
def gets
|
47
|
+
line = super
|
48
|
+
IRB.Output << [ :stdin, line ] if line
|
49
|
+
line
|
50
|
+
end
|
51
|
+
end
|
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.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bbtfr
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -98,6 +98,7 @@ files:
|
|
98
98
|
- lib/tailog/eval.rb
|
99
99
|
- lib/tailog/ext/file.rb
|
100
100
|
- lib/tailog/ext/integer.rb
|
101
|
+
- lib/tailog/ext/irb.rb
|
101
102
|
- lib/tailog/request_id.rb
|
102
103
|
- lib/tailog/version.rb
|
103
104
|
- lib/tailog/watch_methods.rb
|