pry-de 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +25 -21
- data/bin/rbacktracedit +3 -0
- data/lib/pry-de.rb +12 -0
- data/lib/pry-de/backtrace_edit.rb +73 -4
- data/lib/pry-de/version.rb +1 -1
- data/test/test_backtrace_edit.rb +44 -3
- data/vim/ftplugin/ruby_pry-de.vim +1 -1
- metadata +5 -3
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
GIT
|
2
2
|
remote: git://github.com/pry/pry.git
|
3
|
-
revision:
|
3
|
+
revision: 2eca2e1b7e3ff6b9a7471eacc3db1e910f40e567
|
4
4
|
specs:
|
5
|
-
pry (0.9.
|
5
|
+
pry (0.9.11)
|
6
6
|
coderay (~> 1.0.5)
|
7
7
|
method_source (~> 0.8)
|
8
8
|
slop (~> 3.3.1)
|
@@ -10,7 +10,7 @@ GIT
|
|
10
10
|
PATH
|
11
11
|
remote: .
|
12
12
|
specs:
|
13
|
-
pry-de (0.0.
|
13
|
+
pry-de (0.0.4)
|
14
14
|
guard
|
15
15
|
pry-full
|
16
16
|
|
@@ -20,7 +20,7 @@ GEM
|
|
20
20
|
awesome_print (1.1.0)
|
21
21
|
binding_of_caller (0.6.8)
|
22
22
|
bond (0.4.2)
|
23
|
-
coderay (1.0.
|
23
|
+
coderay (1.0.8)
|
24
24
|
columnize (0.3.6)
|
25
25
|
debugger (1.1.4)
|
26
26
|
columnize (>= 0.3.1)
|
@@ -28,31 +28,32 @@ GEM
|
|
28
28
|
debugger-ruby_core_source (~> 1.1.3)
|
29
29
|
debugger-linecache (1.1.2)
|
30
30
|
debugger-ruby_core_source (>= 1.1.1)
|
31
|
-
debugger-ruby_core_source (1.1.
|
31
|
+
debugger-ruby_core_source (1.1.5)
|
32
32
|
diff-lcs (1.1.3)
|
33
|
-
diffy (2.0
|
33
|
+
diffy (2.1.0)
|
34
34
|
eventmachine (1.0.0)
|
35
|
-
ffi (1.
|
35
|
+
ffi (1.2.0)
|
36
36
|
grit (2.5.0)
|
37
37
|
diff-lcs (~> 1.1)
|
38
38
|
mime-types (~> 1.15)
|
39
39
|
posix-spawn (~> 0.3.6)
|
40
|
-
guard (1.
|
40
|
+
guard (1.5.4)
|
41
41
|
listen (>= 0.4.2)
|
42
|
+
lumberjack (>= 1.0.2)
|
43
|
+
pry (>= 0.9.10)
|
42
44
|
thor (>= 0.14.6)
|
43
45
|
guard-minitest (0.5.0)
|
44
46
|
guard (>= 0.4)
|
45
47
|
highline (1.6.15)
|
46
48
|
interception (0.3)
|
47
|
-
jist (1.0
|
49
|
+
jist (1.2.0)
|
48
50
|
json
|
49
51
|
json (1.7.5)
|
50
|
-
listen (0.
|
51
|
-
|
52
|
+
listen (0.6.0)
|
53
|
+
lumberjack (1.0.2)
|
54
|
+
method_source (0.8.1)
|
52
55
|
mime-types (1.19)
|
53
56
|
nokogiri (1.5.5)
|
54
|
-
plymouth (0.3.2)
|
55
|
-
pry-exception_explorer (>= 0.1.7)
|
56
57
|
posix-spawn (0.3.6)
|
57
58
|
pry-awesome_print (9.6.5)
|
58
59
|
awesome_print (~> 1.1.0)
|
@@ -64,19 +65,22 @@ GEM
|
|
64
65
|
pry-doc (0.4.4)
|
65
66
|
pry (>= 0.9.9.6)
|
66
67
|
yard (~> 0.8.1)
|
68
|
+
pry-docmore (0.0.2)
|
69
|
+
pry
|
70
|
+
pry-doc
|
67
71
|
pry-editline (1.1.1)
|
68
72
|
pry-exception_explorer (0.1.9)
|
69
73
|
pry-stack_explorer (>= 0.3.9)
|
70
|
-
pry-full (0
|
74
|
+
pry-full (1.0)
|
71
75
|
bond
|
72
76
|
jist
|
73
|
-
plymouth
|
74
77
|
pry-awesome_print
|
75
78
|
pry-debugger
|
76
79
|
pry-developer_tools
|
77
80
|
pry-doc
|
81
|
+
pry-docmore
|
78
82
|
pry-editline
|
79
|
-
pry-exception_explorer
|
83
|
+
pry-exception_explorer (= 0.1.9)
|
80
84
|
pry-git
|
81
85
|
pry-highlight
|
82
86
|
pry-pretty-numeric
|
@@ -100,11 +104,11 @@ GEM
|
|
100
104
|
eventmachine
|
101
105
|
highline
|
102
106
|
pry (~> 0.9)
|
103
|
-
pry-rescue (0.
|
104
|
-
interception
|
107
|
+
pry-rescue (0.13)
|
108
|
+
interception (>= 0.3)
|
105
109
|
pry
|
106
|
-
pry-stack_explorer (0.4.
|
107
|
-
binding_of_caller (~> 0.6.
|
110
|
+
pry-stack_explorer (0.4.7)
|
111
|
+
binding_of_caller (~> 0.6.8)
|
108
112
|
pry-syntax-hacks (0.0.6)
|
109
113
|
pry (>= 0.9.8)
|
110
114
|
pry-theme (0.1.3)
|
@@ -113,7 +117,7 @@ GEM
|
|
113
117
|
ffi (>= 0.5.0)
|
114
118
|
slop (3.3.3)
|
115
119
|
thor (0.16.0)
|
116
|
-
yard (0.8.
|
120
|
+
yard (0.8.3)
|
117
121
|
|
118
122
|
PLATFORMS
|
119
123
|
ruby
|
data/bin/rbacktracedit
ADDED
data/lib/pry-de.rb
CHANGED
@@ -48,6 +48,13 @@ module PryDe
|
|
48
48
|
run_command 'play --lines 2..-2 -m'
|
49
49
|
end
|
50
50
|
|
51
|
+
command ',lft', 'load _file_ and try-again, for pry-rescue/minitest' do
|
52
|
+
current_file = target.eval '_file_'
|
53
|
+
warn "Reloading: " + current_file
|
54
|
+
load current_file
|
55
|
+
_pry_.run_command 'try-again'
|
56
|
+
end
|
57
|
+
|
51
58
|
command ',refactor' do
|
52
59
|
raw = `git status --porcelain`
|
53
60
|
to_examine = raw.split(/\n/).map do |change|
|
@@ -88,6 +95,11 @@ module PryDe
|
|
88
95
|
end
|
89
96
|
end
|
90
97
|
|
98
|
+
command ',hs', 'hist --save ~/.pry_history - e.g. for vim <leader>ph' do
|
99
|
+
# TODO: make this more efficient. (This actually rewrites the whole thing)
|
100
|
+
run 'hist --save ~/.pry_history'
|
101
|
+
end
|
102
|
+
|
91
103
|
# XXX needs to not recurse.
|
92
104
|
# alias_command ',r', 'hist --replay -1'
|
93
105
|
|
@@ -1,9 +1,78 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
module PryDe
|
2
3
|
class BacktraceEdit
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
class << self
|
5
|
+
def interact
|
6
|
+
warn green 'ZZ to hop to next, :cq to end.'
|
7
|
+
trace.each do |e| edit e end
|
8
|
+
rescue => e
|
9
|
+
puts yellow e
|
10
|
+
end
|
11
|
+
|
12
|
+
def edit input
|
13
|
+
hash = parse_line input
|
14
|
+
path = hash[:path]
|
15
|
+
unless File.exist? path
|
16
|
+
return warn <<-EOT
|
17
|
+
From this line: '#{cyan input}'
|
18
|
+
parsed '#{yellow path}', which does not exist.
|
19
|
+
Assuming to not be a frame and, skipping
|
20
|
+
EOT
|
21
|
+
end
|
22
|
+
viewer = vim_already_open_for(path) ? 'view' : 'vim'
|
23
|
+
offset = ?+ + hash[:line]
|
24
|
+
cmdheight = '+set cmdheight=2'
|
25
|
+
msg = vim_message_for hash[:extra]
|
26
|
+
warn blue "# #{hash[:extra]} ↴"
|
27
|
+
recenter = '+norm zz'
|
28
|
+
verbose_system viewer, path, cmdheight, msg, recenter, offset
|
29
|
+
raise 'OK, done.' unless $?.success?
|
30
|
+
end
|
31
|
+
|
32
|
+
def trace
|
33
|
+
require 'jist'
|
34
|
+
trace = Jist.paste
|
35
|
+
return trace_via_stdin if trace.empty? or not trace[/:in /]
|
36
|
+
trace.split ?\n
|
37
|
+
end
|
38
|
+
|
39
|
+
def trace_via_stdin
|
40
|
+
warn yellow 'Copy from clipboard not working.'
|
41
|
+
warn cyan 'Paste manually, then hit ^d'
|
42
|
+
STDIN.readlines
|
43
|
+
end
|
44
|
+
|
45
|
+
def vim_already_open_for path
|
46
|
+
swpfile = "%s/.%s.swp" % [ File.dirname(path), File.basename(path) ]
|
47
|
+
File.exist? swpfile
|
48
|
+
end
|
49
|
+
|
50
|
+
def vim_message_for str
|
51
|
+
cleaned = str.gsub ?", '\\"'
|
52
|
+
'+set ch=2|echo "%s"' % cleaned
|
53
|
+
end
|
54
|
+
|
55
|
+
def parse_line input
|
56
|
+
input.chomp!
|
57
|
+
r = Hash[[:path, :line, :extra].zip(input.split(?:, 3))]
|
58
|
+
r[:path].sub! /^\s*from /, ''
|
59
|
+
r
|
60
|
+
end
|
61
|
+
|
62
|
+
def verbose_system *args
|
63
|
+
require 'shellwords'
|
64
|
+
cmd = args.map(&:shellescape).join ' '
|
65
|
+
warn cyan ' '+cmd
|
66
|
+
system *args
|
67
|
+
end
|
68
|
+
|
69
|
+
def green str; color 32, str end
|
70
|
+
def yellow str; color 33, str end
|
71
|
+
def blue str; color 34, str end
|
72
|
+
def cyan str; color 36, str end
|
73
|
+
def color num, str
|
74
|
+
"\e[#{num}m#{str}\e[0m" % [num, str]
|
75
|
+
end
|
7
76
|
end
|
8
77
|
end
|
9
78
|
end
|
data/lib/pry-de/version.rb
CHANGED
data/test/test_backtrace_edit.rb
CHANGED
@@ -6,12 +6,53 @@ class TestBacktraceEdit < MiniTest::Unit::TestCase
|
|
6
6
|
def test_first_line_parse
|
7
7
|
input = '/blah/src/scrap/foo.rb:4:in `jump\': foo (RuntimeError)'
|
8
8
|
expected = {
|
9
|
-
|
9
|
+
path: '/blah/src/scrap/foo.rb',
|
10
10
|
line: '4',
|
11
|
-
|
12
|
-
error: ' foo (RuntimeError)'
|
11
|
+
extra: 'in `jump\': foo (RuntimeError)'
|
13
12
|
}
|
14
13
|
actual = PryDe::BacktraceEdit.parse_line input
|
15
14
|
assert_equal expected, actual
|
16
15
|
end
|
16
|
+
|
17
|
+
def test_line_parse_with_leading_from
|
18
|
+
input = ' from /blah/src/scrap/foo.rb:6:in `block in buz\'`'
|
19
|
+
expected = {
|
20
|
+
path: '/blah/src/scrap/foo.rb',
|
21
|
+
line: '6',
|
22
|
+
extra: 'in `block in buz\'`'
|
23
|
+
}
|
24
|
+
actual = PryDe::BacktraceEdit.parse_line input
|
25
|
+
assert_equal expected, actual
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_a_bunch
|
29
|
+
examples = <<EOT.split ?\n
|
30
|
+
/usr/lib64/ruby/1.9.1/drb/drb.rb:736:in `rescue in block in open'
|
31
|
+
/usr/lib64/ruby/1.9.1/drb/drb.rb:730:in `block in open'
|
32
|
+
/usr/lib64/ruby/1.9.1/drb/drb.rb:729:in `each'
|
33
|
+
/usr/lib64/ruby/1.9.1/drb/drb.rb:729:in `open'
|
34
|
+
/usr/lib64/ruby/1.9.1/drb/drb.rb:1191:in `initialize'
|
35
|
+
/usr/lib64/ruby/1.9.1/drb/drb.rb:1171:in `new'
|
36
|
+
/usr/lib64/ruby/1.9.1/drb/drb.rb:1171:in `open'
|
37
|
+
/usr/lib64/ruby/1.9.1/drb/drb.rb:1087:in `block in method_missing'
|
38
|
+
/usr/lib64/ruby/1.9.1/drb/drb.rb:1105:in `with_friend'
|
39
|
+
/usr/lib64/ruby/1.9.1/drb/drb.rb:1086:in `method_missing'
|
40
|
+
/usr/lib64/ruby/1.9.1/drb/drb.rb:1074:in `respond_to?'
|
41
|
+
/home/rking/.gem/ruby/1.9.1/gems/spork-0.9.2/lib/spork/run_strategy/forking.rb:10:in `block in run'
|
42
|
+
/home/rking/.gem/ruby/1.9.1/gems/spork-0.9.2/lib/spork/forker.rb:21:in `block in initialize'
|
43
|
+
/home/rking/.gem/ruby/1.9.1/gems/spork-0.9.2/lib/spork/forker.rb:18:in `fork'
|
44
|
+
/home/rking/.gem/ruby/1.9.1/gems/spork-0.9.2/lib/spork/forker.rb:18:in `initialize'
|
45
|
+
/home/rking/.gem/ruby/1.9.1/gems/spork-0.9.2/lib/spork/run_strategy/forking.rb:9:in `new'
|
46
|
+
/home/rking/.gem/ruby/1.9.1/gems/spork-0.9.2/lib/spork/run_strategy/forking.rb:9:in `run'
|
47
|
+
/home/rking/.gem/ruby/1.9.1/gems/spork-0.9.2/lib/spork/server.rb:48:in `run'
|
48
|
+
/usr/lib64/ruby/1.9.1/drb/drb.rb:1548:in `perform_without_block'
|
49
|
+
/usr/lib64/ruby/1.9.1/drb/drb.rb:1508:in `perform'
|
50
|
+
/usr/lib64/ruby/1.9.1/drb/drb.rb:1586:in `block (2 levels) in main_loop'
|
51
|
+
/usr/lib64/ruby/1.9.1/drb/drb.rb:1582:in `loop'
|
52
|
+
/usr/lib64/ruby/1.9.1/drb/drb.rb:1582:in `block in main_loop'`
|
53
|
+
EOT
|
54
|
+
examples.each do |eg|
|
55
|
+
assert PryDe::BacktraceEdit.parse_line(eg), "no-explode for '#{eg}'"
|
56
|
+
end
|
57
|
+
end
|
17
58
|
end
|
@@ -6,5 +6,5 @@ map <Leader><Leader>p <Leader>bp
|
|
6
6
|
iabbr bpry require'pry';binding.pry
|
7
7
|
|
8
8
|
" Nab lines from ~/.pry_history (respects "count")
|
9
|
-
nmap <Leader>
|
9
|
+
nmap <Leader>ph :<c-u>let pc = (v:count1 ? v:count1 : 1)<cr>:read !tail -<c-r>=pc<cr> ~/.pry_history<cr>:.-<c-r>=pc-1<cr>:norm <c-r>=pc<cr>==<cr>
|
10
10
|
" ↑ thanks to Houl, ZyX-i, and paradigm of #vim for all dogpiling on this one.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry-de
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-12-06 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: pry-full
|
@@ -62,7 +62,8 @@ dependencies:
|
|
62
62
|
version: '0'
|
63
63
|
description: ! 'For the concept, see: https://github.com/pry/pry/wiki/pry-de'
|
64
64
|
email: pry-de@sharpsaw.org
|
65
|
-
executables:
|
65
|
+
executables:
|
66
|
+
- rbacktracedit
|
66
67
|
extensions: []
|
67
68
|
extra_rdoc_files: []
|
68
69
|
files:
|
@@ -78,6 +79,7 @@ files:
|
|
78
79
|
- Rakefile
|
79
80
|
- TODO-Pry
|
80
81
|
- VERSION
|
82
|
+
- bin/rbacktracedit
|
81
83
|
- lib/pry-de.rb
|
82
84
|
- lib/pry-de/backtrace_edit.rb
|
83
85
|
- lib/pry-de/version.rb
|