pry-moves 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/README.md +108 -0
- data/Rakefile +2 -0
- data/lib/pry-moves.rb +23 -0
- data/lib/pry-moves/cli.rb +1 -0
- data/lib/pry-moves/commands.rb +58 -0
- data/lib/pry-moves/pry_ext.rb +42 -0
- data/lib/pry-moves/pry_remote_ext.rb +42 -0
- data/lib/pry-moves/tracer.rb +141 -0
- data/lib/pry-moves/version.rb +3 -0
- data/playground/Gemfile +6 -0
- data/playground/README.md +40 -0
- data/playground/demo.rb +33 -0
- data/playground/recursions.rb +79 -0
- data/playground/sand.rb +53 -0
- data/playground/tracer.rb +8 -0
- data/pry-moves.gemspec +25 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: db3ea1e074ab85725b2cba35fb6e15a756f4aa6c
|
4
|
+
data.tar.gz: 0c1db4f7b08122e52bea1633658f53f7423c409a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 69e3e09438e94413f4bc53b5e275b37166dc3acbf57ac1e2147740d816a41beb4149c9267b758a4afba227c97dab6fb377511a47338841095c3552d5b3e06366
|
7
|
+
data.tar.gz: 0ea9be1eb417f3b9d44cc3c4685cdba4fde71f2777989985586e7c6e39915687dbcd8167b125961c2de478b341af4a5946798fb65a389a2c2fc770a1de21622c
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
MIT/Expat License
|
2
|
+
|
3
|
+
Copyright (c) 2011 by Gopal Patel
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
### Using [**pry-byebug**][pry-byebug] and not happy with commands behavior? We recommend this project instead
|
2
|
+
|
3
|
+
# pry-moves
|
4
|
+
|
5
|
+
_An execution control add-on for [Pry][pry]._
|
6
|
+
|
7
|
+
|
8
|
+
## Commands:
|
9
|
+
|
10
|
+
* `n` - **next** line in current frame, including block lines (moving to next line goes as naturally expected)
|
11
|
+
* `s` - **step** into function execution
|
12
|
+
* `s func_name` - steps into first method called by name `func_name`
|
13
|
+
* `f` - **finish** execution of current frame and stop at next line on higher level
|
14
|
+
* `c` - **continue**
|
15
|
+
* `bt` - backtrace
|
16
|
+
* `!` - exit
|
17
|
+
|
18
|
+
|
19
|
+
## Examples
|
20
|
+
|
21
|
+
To use, invoke `pry` normally:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
def some_method
|
25
|
+
binding.pry # Execution will stop here.
|
26
|
+
puts 'Hello, World!' # Run 'step' or 'next' in the console to move here.
|
27
|
+
end
|
28
|
+
```
|
29
|
+
|
30
|
+
### Advanced example
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
class A
|
34
|
+
|
35
|
+
def initialize
|
36
|
+
b = :some_code
|
37
|
+
end
|
38
|
+
|
39
|
+
def aa
|
40
|
+
self
|
41
|
+
end
|
42
|
+
|
43
|
+
def bb
|
44
|
+
block do
|
45
|
+
c = :some_code
|
46
|
+
end
|
47
|
+
d = :some_code
|
48
|
+
e = :some_code
|
49
|
+
self
|
50
|
+
end
|
51
|
+
|
52
|
+
def block
|
53
|
+
e = :some_code
|
54
|
+
yield
|
55
|
+
f = :other_code
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
```
|
60
|
+
|
61
|
+
<img src="https://user-images.githubusercontent.com/2452269/27320748-37afe7de-55a0-11e7-8b8f-ae05bcb02f37.jpg" width="377">
|
62
|
+
|
63
|
+
## Technical info
|
64
|
+
|
65
|
+
`pry-moves` is not yet thread-safe, so only use in single-threaded environments.
|
66
|
+
|
67
|
+
Rudimentary support for [`pry-remote`][pry-remote] (>= 0.1.1) is also included.
|
68
|
+
Ensure `pry-remote` is loaded or required before `pry-moves`. For example, in a
|
69
|
+
`Gemfile`:
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
gem 'pry'
|
73
|
+
gem 'pry-remote'
|
74
|
+
gem 'pry-moves'
|
75
|
+
```
|
76
|
+
|
77
|
+
Please note that debugging functionality is implemented through
|
78
|
+
[`set_trace_func`][set_trace_func], which imposes a large performance
|
79
|
+
penalty.
|
80
|
+
|
81
|
+
## Contributors
|
82
|
+
|
83
|
+
* Gopal Patel ([@nixme](https://github.com/nixme))
|
84
|
+
* John Mair ([@banister](https://github.com/banister))
|
85
|
+
* Conrad Irwin ([@ConradIrwin](https://github.com/ConradIrwin))
|
86
|
+
* Benjamin R. Haskell ([@benizi](https://github.com/benizi))
|
87
|
+
* Jason R. Clark ([@jasonrclark](https://github.com/jasonrclark))
|
88
|
+
* Ivo Anjo ([@ivoanjo](https://github.com/ivoanjo))
|
89
|
+
|
90
|
+
Patches and bug reports are welcome. Just send a [pull request][pullrequests] or
|
91
|
+
file an [issue][issues]. [Project changelog][changelog].
|
92
|
+
|
93
|
+
## Acknowledgments
|
94
|
+
|
95
|
+
* Gopal Patel's [pry-nav](https://github.com/nixme/pry-nav)
|
96
|
+
* Ruby stdlib's [debug.rb][debug.rb]
|
97
|
+
* [@Mon-Ouie][Mon-Ouie]'s [pry_debug][pry_debug]
|
98
|
+
|
99
|
+
[pry]: http://pryrepl.org/
|
100
|
+
[pry-remote]: https://github.com/Mon-Ouie/pry-remote
|
101
|
+
[set_trace_func]: http://www.ruby-doc.org/core-1.9.3/Kernel.html#method-i-set_trace_func
|
102
|
+
[pullrequests]: https://github.com/garmoshka-mo/pry-moves/pulls
|
103
|
+
[issues]: https://github.com/garmoshka-mo/pry-moves/issues
|
104
|
+
[changelog]: https://github.com/garmoshka-mo/pry-moves/blob/master/CHANGELOG.md
|
105
|
+
[debug.rb]: https://github.com/ruby/ruby/blob/trunk/lib/debug.rb
|
106
|
+
[Mon-Ouie]: https://github.com/Mon-Ouie
|
107
|
+
[pry_debug]: https://github.com/Mon-Ouie/pry_debug
|
108
|
+
[pry-byebug]: https://github.com/deivid-rodriguez/pry-byebug
|
data/Rakefile
ADDED
data/lib/pry-moves.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'pry-moves/version'
|
2
|
+
require 'pry-moves/pry_ext'
|
3
|
+
require 'pry-moves/commands'
|
4
|
+
require 'pry-moves/tracer'
|
5
|
+
|
6
|
+
# Optionally load pry-remote monkey patches
|
7
|
+
require 'pry-moves/pry_remote_ext' if defined? PryRemote
|
8
|
+
|
9
|
+
module PryMoves
|
10
|
+
TRACE_IGNORE_FILES = Dir[File.join(File.dirname(__FILE__), '**', '*.rb')].map { |f| File.expand_path(f) }
|
11
|
+
|
12
|
+
extend self
|
13
|
+
|
14
|
+
# Checks that a binding is in a local file context. Extracted from
|
15
|
+
# https://github.com/pry/pry/blob/master/lib/pry/default_commands/context.rb
|
16
|
+
def check_file_context(target)
|
17
|
+
file = target.eval('__FILE__')
|
18
|
+
file == Pry.eval_path || (file !~ /(\(.*\))|<.*>/ && file != '' && file != '-e')
|
19
|
+
end
|
20
|
+
|
21
|
+
# Reference to currently running pry-remote server. Used by the tracer.
|
22
|
+
attr_accessor :current_remote_server
|
23
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'pry-moves'
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'pry' unless defined? Pry
|
2
|
+
|
3
|
+
module PryMoves
|
4
|
+
Commands = Pry::CommandSet.new do
|
5
|
+
block_command 'step', 'Step execution into the next line or method.' do |param|
|
6
|
+
check_file_context
|
7
|
+
breakout_navigation :step, param
|
8
|
+
end
|
9
|
+
|
10
|
+
block_command 'finish', 'Finish xule tut neponyatnogo.' do |param|
|
11
|
+
check_file_context
|
12
|
+
breakout_navigation :finish, param
|
13
|
+
end
|
14
|
+
|
15
|
+
block_command 'next', 'Execute the next line within the same stack frame.' do |param|
|
16
|
+
check_file_context
|
17
|
+
breakout_navigation :next, param
|
18
|
+
end
|
19
|
+
|
20
|
+
block_command 'continue', 'Continue program execution and end the Pry session.' do
|
21
|
+
check_file_context
|
22
|
+
run 'exit-all'
|
23
|
+
end
|
24
|
+
|
25
|
+
alias_command 'c', 'continue'
|
26
|
+
alias_command 's', 'step'
|
27
|
+
alias_command 'n', 'next'
|
28
|
+
alias_command 'f', 'finish'
|
29
|
+
|
30
|
+
# Hit Enter to repeat last command
|
31
|
+
command /^$/, "repeat last command" do
|
32
|
+
_pry_.run_command Pry.history.to_a.last
|
33
|
+
end
|
34
|
+
|
35
|
+
helpers do
|
36
|
+
def breakout_navigation(action, param)
|
37
|
+
_pry_.binding_stack.clear # Clear the binding stack.
|
38
|
+
throw :breakout_nav, { # Break out of the REPL loop and
|
39
|
+
:action => action, # signal the tracer.
|
40
|
+
:param => param,
|
41
|
+
:binding => target
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
# Ensures that a command is executed in a local file context.
|
46
|
+
def check_file_context
|
47
|
+
unless PryMoves.check_file_context(target)
|
48
|
+
raise Pry::CommandError, 'Cannot find local context. Did you use `binding.pry`?'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
Pry.commands.import PryMoves::Commands
|
56
|
+
|
57
|
+
Pry.commands.alias_command 'bt', 'pry-backtrace'
|
58
|
+
Pry.commands.alias_command '!', '!!!'
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'pry' unless defined? Pry
|
2
|
+
require 'pry-moves/tracer'
|
3
|
+
|
4
|
+
class << Pry
|
5
|
+
alias_method :start_without_pry_nav, :start
|
6
|
+
|
7
|
+
def start_with_pry_nav(target = TOPLEVEL_BINDING, options = {})
|
8
|
+
old_options = options.reject { |k, _| k == :pry_remote }
|
9
|
+
|
10
|
+
if target.is_a?(Binding) && PryMoves.check_file_context(target)
|
11
|
+
# Wrap the tracer around the usual Pry.start
|
12
|
+
PryMoves::Tracer.new(options).run do
|
13
|
+
start_without_pry_nav(target, old_options)
|
14
|
+
end
|
15
|
+
else
|
16
|
+
# No need for the tracer unless we have a file context to step through
|
17
|
+
start_without_pry_nav(target, old_options)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
alias_method :start, :start_with_pry_nav
|
22
|
+
end
|
23
|
+
|
24
|
+
Binding.class_eval do
|
25
|
+
|
26
|
+
alias original_pry pry
|
27
|
+
|
28
|
+
def pry
|
29
|
+
original_pry unless Pry.config.disable_breakpoints
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
require 'pry-stack_explorer'
|
35
|
+
|
36
|
+
PryStackExplorer::WhenStartedHook.class_eval do
|
37
|
+
|
38
|
+
def remove_debugger_frames(bindings)
|
39
|
+
bindings.drop_while { |b| b.eval("__FILE__") =~ /\/pry-/ }
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'pry' unless defined? Pry
|
2
|
+
require 'pry-remote'
|
3
|
+
|
4
|
+
module PryRemote
|
5
|
+
class Server
|
6
|
+
# Override the call to Pry.start to save off current Server, pass a
|
7
|
+
# pry_remote flag so pry-moves knows this is a remote session, and not kill
|
8
|
+
# the server right away
|
9
|
+
def run
|
10
|
+
if PryMoves.current_remote_server
|
11
|
+
raise 'Already running a pry-remote session!'
|
12
|
+
else
|
13
|
+
PryMoves.current_remote_server = self
|
14
|
+
end
|
15
|
+
|
16
|
+
setup
|
17
|
+
Pry.start @object, {
|
18
|
+
:input => client.input_proxy,
|
19
|
+
:output => client.output,
|
20
|
+
:pry_remote => true
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
# Override to reset our saved global current server session.
|
25
|
+
alias_method :teardown_without_pry_nav, :teardown
|
26
|
+
def teardown_with_pry_nav
|
27
|
+
teardown_without_pry_nav
|
28
|
+
PryMoves.current_remote_server = nil
|
29
|
+
end
|
30
|
+
alias_method :teardown, :teardown_with_pry_nav
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# Ensure cleanup when a program finishes without another break. For example,
|
35
|
+
# 'next' on the last line of a program never hits the tracer proc, and thus
|
36
|
+
# PryMoves::Tracer#run doesn't have a chance to cleanup.
|
37
|
+
at_exit do
|
38
|
+
set_trace_func nil
|
39
|
+
if PryMoves.current_remote_server
|
40
|
+
PryMoves.current_remote_server.teardown
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
require 'pry' unless defined? Pry
|
2
|
+
|
3
|
+
module PryMoves
|
4
|
+
class Tracer
|
5
|
+
def initialize(pry_start_options = {}, &block)
|
6
|
+
@pry_start_options = pry_start_options # Options to use for Pry.start
|
7
|
+
end
|
8
|
+
|
9
|
+
def run(&block)
|
10
|
+
# For performance, disable any tracers while in the console.
|
11
|
+
# Unfortunately doesn't work in 1.9.2 because of
|
12
|
+
# http://redmine.ruby-lang.org/issues/3921. Works fine in 1.8.7 and 1.9.3.
|
13
|
+
stop_tracing unless RUBY_VERSION == '1.9.2'
|
14
|
+
|
15
|
+
return_value = nil
|
16
|
+
command = catch(:breakout_nav) do # Coordinates with PryMoves::Commands
|
17
|
+
return_value = yield
|
18
|
+
{} # Nothing thrown == no navigational command
|
19
|
+
end
|
20
|
+
|
21
|
+
# Adjust tracer based on command
|
22
|
+
if process_command(command)
|
23
|
+
start_tracing command
|
24
|
+
else
|
25
|
+
stop_tracing if RUBY_VERSION == '1.9.2'
|
26
|
+
if @pry_start_options[:pry_remote] && PryMoves.current_remote_server
|
27
|
+
PryMoves.current_remote_server.teardown
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
return_value
|
32
|
+
end
|
33
|
+
|
34
|
+
def start_tracing(command)
|
35
|
+
Pry.config.disable_breakpoints = true
|
36
|
+
set_traced_method command[:binding]
|
37
|
+
case @action
|
38
|
+
when :finish
|
39
|
+
@method_to_finish = @method
|
40
|
+
end
|
41
|
+
set_trace_func method(:tracer).to_proc
|
42
|
+
end
|
43
|
+
|
44
|
+
def stop_tracing
|
45
|
+
Pry.config.disable_breakpoints = false
|
46
|
+
set_trace_func nil
|
47
|
+
end
|
48
|
+
|
49
|
+
def process_command(command = {})
|
50
|
+
@action = command[:action]
|
51
|
+
|
52
|
+
case @action
|
53
|
+
when :step
|
54
|
+
@step_info_funcs = nil
|
55
|
+
if command[:param]
|
56
|
+
func = command[:param].to_sym
|
57
|
+
@step_info_funcs = [func]
|
58
|
+
@step_info_funcs << :initialize if func == :new
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
[:step, :next, :finish].include? @action
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def set_traced_method(binding)
|
69
|
+
@recursion_level = 0
|
70
|
+
|
71
|
+
method = binding.eval 'method(__method__) if __method__'
|
72
|
+
return set_method({file: binding.eval('__FILE__')}) unless method
|
73
|
+
|
74
|
+
source = method.source_location
|
75
|
+
set_method({
|
76
|
+
file: source[0],
|
77
|
+
start: source[1],
|
78
|
+
end: (source[1] + method.source.count("\n") - 1)
|
79
|
+
#thread: binding.eval 'Thread.current' # todo: Нужна проверка по треду?
|
80
|
+
})
|
81
|
+
end
|
82
|
+
|
83
|
+
def set_method(method)
|
84
|
+
#puts "set_traced_method #{method}"
|
85
|
+
@method = method
|
86
|
+
end
|
87
|
+
|
88
|
+
def tracer(event, file, line, id, binding_, klass)
|
89
|
+
#printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, klass
|
90
|
+
# Ignore traces inside pry-moves code
|
91
|
+
return if file && TRACE_IGNORE_FILES.include?(File.expand_path(file))
|
92
|
+
|
93
|
+
traced_method_exit = (@recursion_level < 0 and %w(line call).include? event)
|
94
|
+
# Set new traced method, because we left previous one
|
95
|
+
set_traced_method binding_ if traced_method_exit
|
96
|
+
|
97
|
+
case event
|
98
|
+
when 'line'
|
99
|
+
#debug_info file, line, id
|
100
|
+
if break_here?(file, line, binding_, traced_method_exit)
|
101
|
+
Pry.start(binding_, @pry_start_options)
|
102
|
+
end
|
103
|
+
when 'call', 'return'
|
104
|
+
if within_current_method?(file, line) and !traced_method_exit
|
105
|
+
recursion_step event
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def debug_info(file, line, id)
|
111
|
+
puts "📽 Action:#{@action}; recur:#{@recursion_level}; #{@method[:file]}:#{file}"
|
112
|
+
puts "#{id} #{@method[:start]} > #{line} > #{@method[:end]}"
|
113
|
+
end
|
114
|
+
|
115
|
+
def break_here?(file, line, binding_, traced_method_exit)
|
116
|
+
case @action
|
117
|
+
when :step
|
118
|
+
@step_info_funcs ?
|
119
|
+
@step_info_funcs.include?(binding_.eval('__callee__'))
|
120
|
+
: true
|
121
|
+
when :finish
|
122
|
+
@method_to_finish = @method if @method_to_finish != @method
|
123
|
+
when :next
|
124
|
+
@recursion_level == 0 and within_current_method?(file, line)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def within_current_method?(file, line)
|
129
|
+
@method[:file] == file and (
|
130
|
+
@method[:start].nil? or
|
131
|
+
line.between?(@method[:start], @method[:end])
|
132
|
+
)
|
133
|
+
end
|
134
|
+
|
135
|
+
def recursion_step(event)
|
136
|
+
#puts "recursion_step #{event} #{'call' ? 1 : -1}"
|
137
|
+
@recursion_level += event == 'call' ? 1 : -1
|
138
|
+
end
|
139
|
+
|
140
|
+
end
|
141
|
+
end
|
data/playground/Gemfile
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
## Debug
|
2
|
+
|
3
|
+
```
|
4
|
+
be ruby sand.rb
|
5
|
+
```
|
6
|
+
|
7
|
+
## Conditions to be met
|
8
|
+
|
9
|
+
- publish to gems, reset version, add to readme how to install
|
10
|
+
- Publish on Stakcoverflow
|
11
|
+
-- в своем посте
|
12
|
+
-- поискать вопросов про дебаг в руби, посоветовать эту либу как удобнее чем все другое
|
13
|
+
- есть ли какой-то плейграунд на вебе?
|
14
|
+
|
15
|
+
|
16
|
+
-------------------
|
17
|
+
-------------------
|
18
|
+
|
19
|
+
|
20
|
+
- `binding.pry if debug? :resolve`
|
21
|
+
3 раза просит одно и то же
|
22
|
+
- recursions.rb
|
23
|
+
- `Route::Execution.new(self, context).resolve`
|
24
|
+
отремонтировать finish - должен заходить в следующую функцию
|
25
|
+
- A.new.aa.bb.cc
|
26
|
+
`step cc`
|
27
|
+
- Shouldn't go to the end:
|
28
|
+
```
|
29
|
+
A.new.aa.bb.cc
|
30
|
+
s
|
31
|
+
n
|
32
|
+
```
|
33
|
+
- stack_explorer's up/down shouldn't break
|
34
|
+
|
35
|
+
|
36
|
+
### Maybe?
|
37
|
+
|
38
|
+
- (?) 10 Thread которые выполняют одно и тоже параллельно
|
39
|
+
rand должен быть верный на всех next - поймать кейс, где не тот начинается - чтобы проверит гипотизу, что действительно надо трекать thread
|
40
|
+
|
data/playground/demo.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'pry'
|
2
|
+
require 'pry-moves'
|
3
|
+
|
4
|
+
class A
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
b = :some_code
|
8
|
+
end
|
9
|
+
|
10
|
+
def aa
|
11
|
+
self
|
12
|
+
end
|
13
|
+
|
14
|
+
def bb
|
15
|
+
block do
|
16
|
+
c = :some_code
|
17
|
+
end
|
18
|
+
d = :some_code
|
19
|
+
e = :some_code
|
20
|
+
self
|
21
|
+
end
|
22
|
+
|
23
|
+
def block
|
24
|
+
e = :some_code
|
25
|
+
yield
|
26
|
+
f = :other_code
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
binding.pry
|
32
|
+
A.new.aa.bb
|
33
|
+
c = :some_code
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'pry'
|
2
|
+
require 'pry-moves'
|
3
|
+
|
4
|
+
class Test
|
5
|
+
|
6
|
+
def initialize(i)
|
7
|
+
@index = i
|
8
|
+
end
|
9
|
+
|
10
|
+
def test
|
11
|
+
a = 1
|
12
|
+
b = 2
|
13
|
+
end
|
14
|
+
|
15
|
+
def pimpa
|
16
|
+
pop = 3
|
17
|
+
pop = 4
|
18
|
+
end
|
19
|
+
|
20
|
+
def small
|
21
|
+
binding.pry
|
22
|
+
p = 1
|
23
|
+
end
|
24
|
+
|
25
|
+
def zaloop(p = -1)
|
26
|
+
op = p
|
27
|
+
binding.pry if p == 0 and @index == 2
|
28
|
+
#raise 'abc'
|
29
|
+
iterator do |i|
|
30
|
+
aa = 1
|
31
|
+
zaloop i if op == -1
|
32
|
+
aa = 2
|
33
|
+
aa = 2
|
34
|
+
end
|
35
|
+
rescue
|
36
|
+
a = 3
|
37
|
+
end
|
38
|
+
|
39
|
+
def straight
|
40
|
+
popa = 1
|
41
|
+
a = binding
|
42
|
+
iterator do |i|
|
43
|
+
b = binding
|
44
|
+
pop = 1
|
45
|
+
pop = i
|
46
|
+
pop = 2
|
47
|
+
#binding.pry
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def iterator
|
52
|
+
1.times do |i|
|
53
|
+
pop = 1
|
54
|
+
yield i
|
55
|
+
pop = 2
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
threads = 10.times.map do |i|
|
62
|
+
Thread.new do
|
63
|
+
t = Test.new i
|
64
|
+
#t.small
|
65
|
+
t.zaloop rescue a = :caught
|
66
|
+
#t.straight
|
67
|
+
end
|
68
|
+
end
|
69
|
+
threads.each(&:join)
|
70
|
+
|
71
|
+
|
72
|
+
puts :zoo
|
73
|
+
puts :zoo2
|
74
|
+
|
75
|
+
exit
|
76
|
+
|
77
|
+
t.test and t.pimpa
|
78
|
+
|
79
|
+
puts "here_goes_end\n"
|
data/playground/sand.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'pry'
|
2
|
+
require 'pry-moves'
|
3
|
+
#require 'pry-nav'
|
4
|
+
require './tracer.rb'
|
5
|
+
|
6
|
+
def debug?
|
7
|
+
binding.pry
|
8
|
+
true
|
9
|
+
end
|
10
|
+
|
11
|
+
class A
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
puts :xuilo
|
15
|
+
end
|
16
|
+
|
17
|
+
def aa
|
18
|
+
self
|
19
|
+
end
|
20
|
+
|
21
|
+
def bb
|
22
|
+
#binding.pry
|
23
|
+
a = 1
|
24
|
+
a = 1
|
25
|
+
self
|
26
|
+
end
|
27
|
+
|
28
|
+
def cc
|
29
|
+
self
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
#trace_events
|
35
|
+
|
36
|
+
a = 1123
|
37
|
+
|
38
|
+
puts :prepare
|
39
|
+
|
40
|
+
binding.pry
|
41
|
+
|
42
|
+
A.new.aa.bb.cc
|
43
|
+
|
44
|
+
bb = 1
|
45
|
+
|
46
|
+
exit
|
47
|
+
|
48
|
+
pp = 123 if debug?
|
49
|
+
binding.pry if debug?
|
50
|
+
|
51
|
+
binding.pry
|
52
|
+
|
53
|
+
puts :ok
|
data/pry-moves.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require File.expand_path('../lib/pry-moves/version', __FILE__)
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = 'pry-moves'
|
7
|
+
gem.version = PryMoves::VERSION
|
8
|
+
gem.author = 'Garmoshka Mo'
|
9
|
+
gem.email = 'dan@coav.ru'
|
10
|
+
gem.license = 'MIT'
|
11
|
+
gem.homepage = 'https://github.com/garmoshka-mo/pry-moves'
|
12
|
+
gem.summary = 'Simple execution navigation for Pry.'
|
13
|
+
gem.description = "Turn Pry into a primitive debugger. Adds 'step' and 'next' commands to control execution."
|
14
|
+
|
15
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
16
|
+
gem.files = `git ls-files`.split("\n")
|
17
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
# Dependencies
|
21
|
+
gem.required_ruby_version = '>= 1.8.7'
|
22
|
+
gem.add_runtime_dependency 'pry', '>= 0.9.10', '< 0.11.0'
|
23
|
+
gem.add_runtime_dependency 'pry-stack_explorer', '~> 0.4.9'
|
24
|
+
gem.add_development_dependency 'pry-remote', '~> 0.1.6'
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pry-moves
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Garmoshka Mo
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-06-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pry
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.9.10
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.11.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.9.10
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.11.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: pry-stack_explorer
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 0.4.9
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.4.9
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: pry-remote
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.1.6
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 0.1.6
|
61
|
+
description: Turn Pry into a primitive debugger. Adds 'step' and 'next' commands to
|
62
|
+
control execution.
|
63
|
+
email: dan@coav.ru
|
64
|
+
executables: []
|
65
|
+
extensions: []
|
66
|
+
extra_rdoc_files: []
|
67
|
+
files:
|
68
|
+
- ".gitignore"
|
69
|
+
- Gemfile
|
70
|
+
- LICENSE
|
71
|
+
- README.md
|
72
|
+
- Rakefile
|
73
|
+
- lib/pry-moves.rb
|
74
|
+
- lib/pry-moves/cli.rb
|
75
|
+
- lib/pry-moves/commands.rb
|
76
|
+
- lib/pry-moves/pry_ext.rb
|
77
|
+
- lib/pry-moves/pry_remote_ext.rb
|
78
|
+
- lib/pry-moves/tracer.rb
|
79
|
+
- lib/pry-moves/version.rb
|
80
|
+
- playground/Gemfile
|
81
|
+
- playground/README.md
|
82
|
+
- playground/demo.rb
|
83
|
+
- playground/recursions.rb
|
84
|
+
- playground/sand.rb
|
85
|
+
- playground/tracer.rb
|
86
|
+
- pry-moves.gemspec
|
87
|
+
homepage: https://github.com/garmoshka-mo/pry-moves
|
88
|
+
licenses:
|
89
|
+
- MIT
|
90
|
+
metadata: {}
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: 1.8.7
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.5.1
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: Simple execution navigation for Pry.
|
111
|
+
test_files: []
|