pry-nav 0.0.3 → 0.0.4
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.
- data/CHANGELOG.md +11 -0
- data/LICENSE +20 -0
- data/README.md +30 -19
- data/lib/pry-nav.rb +9 -0
- data/lib/pry-nav/commands.rb +6 -7
- data/lib/pry-nav/pry_ext.rb +10 -2
- data/lib/pry-nav/tracer.rb +0 -2
- data/lib/pry-nav/version.rb +1 -1
- metadata +5 -4
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
## 0.0.4 (2011-12-03)
|
2
|
+
|
3
|
+
* Performance improvement, primarily for 1.9.2: Don't trace unless in a file
|
4
|
+
context. `rails console` or standard `pry` shouldn't experience a slowdown
|
5
|
+
anymore.
|
6
|
+
* The overriden `Pry.start` now returns the output of the original method, not a
|
7
|
+
`PryNav::Tracer` instance.
|
8
|
+
* For consistency with the other nav commands, **continue** now checks for a
|
9
|
+
local file context.
|
10
|
+
|
11
|
+
|
1
12
|
## 0.0.3 (2011-12-01)
|
2
13
|
|
3
14
|
* Performance improvement: Don't trace while in the Pry console. Only works in
|
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
CHANGED
@@ -3,11 +3,22 @@ pry-nav
|
|
3
3
|
|
4
4
|
_Simple execution control in Pry_
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
Teaches [Pry][pry] about **step**, **next**, and **continue** to create a simple
|
7
|
+
debugger.
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
To use, invoke pry normally:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
def some_method
|
13
|
+
binding.pry # Execution will stop here.
|
14
|
+
puts 'Hello World' # Run 'step' or 'next' in the console to move here.
|
15
|
+
end
|
16
|
+
```
|
17
|
+
|
18
|
+
**pry-nav** is not yet thread-safe, so only use in single-threaded environments.
|
19
|
+
|
20
|
+
Rudimentary support for [pry-remote][pry-remote] is also included. Ensure
|
21
|
+
pry-remote is loaded or required before pry-nav. For example, in a Gemfile:
|
11
22
|
|
12
23
|
```ruby
|
13
24
|
gem 'pry'
|
@@ -15,8 +26,11 @@ gem 'pry-remote'
|
|
15
26
|
gem 'pry-nav'
|
16
27
|
```
|
17
28
|
|
18
|
-
|
19
|
-
|
29
|
+
Debugging functionality is implemented through
|
30
|
+
[`set_trace_func`][set_trace_func], which imposes a large performance
|
31
|
+
penalty. **pry-nav** traces only when necessary, but due to a workaround for a
|
32
|
+
[bug in 1.9.2][ruby-bug], the console will feel sluggish. Use 1.9.3 for best
|
33
|
+
results and almost no performance penalty.
|
20
34
|
|
21
35
|
|
22
36
|
## Contributing
|
@@ -31,16 +45,13 @@ file an [issue][issues]. [Project changelog][changelog].
|
|
31
45
|
- [@Mon-Ouie][Mon-Ouie]'s [pry_debug][pry_debug]
|
32
46
|
|
33
47
|
|
34
|
-
|
35
|
-
|
36
|
-
-
|
37
|
-
|
38
|
-
|
39
|
-
[
|
40
|
-
[
|
41
|
-
[
|
42
|
-
[
|
43
|
-
[
|
44
|
-
[debug.rb]: https://github.com/ruby/ruby/blob/trunk/lib/debug.rb
|
45
|
-
[Mon-Ouie]: https://github.com/Mon-Ouie
|
46
|
-
[pry_debug]: https://github.com/Mon-Ouie/pry_debug
|
48
|
+
[pry]: http://pry.github.com
|
49
|
+
[pry-remote]: https://github.com/Mon-Ouie/pry-remote
|
50
|
+
[set_trace_func]: http://www.ruby-doc.org/core-1.9.3/Kernel.html#method-i-set_trace_func
|
51
|
+
[ruby-bug]: http://redmine.ruby-lang.org/issues/3921
|
52
|
+
[pullrequests]: https://github.com/nixme/pry-nav/pulls
|
53
|
+
[issues]: https://github.com/nixme/pry-nav/issues
|
54
|
+
[changelog]: https://github.com/nixme/pry-nav/blob/master/CHANGELOG.md
|
55
|
+
[debug.rb]: https://github.com/ruby/ruby/blob/trunk/lib/debug.rb
|
56
|
+
[Mon-Ouie]: https://github.com/Mon-Ouie
|
57
|
+
[pry_debug]: https://github.com/Mon-Ouie/pry_debug
|
data/lib/pry-nav.rb
CHANGED
@@ -8,4 +8,13 @@ require 'pry-nav/pry_remote_ext' if defined? PryRemote
|
|
8
8
|
|
9
9
|
module PryNav
|
10
10
|
TRACE_IGNORE_FILES = Dir[File.join(File.dirname(__FILE__), '**', '*.rb')]
|
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
|
11
20
|
end
|
data/lib/pry-nav/commands.rb
CHANGED
@@ -3,16 +3,17 @@ require 'pry'
|
|
3
3
|
module PryNav
|
4
4
|
Commands = Pry::CommandSet.new do
|
5
5
|
command 'step', 'Step execution into the next line or method.' do |steps|
|
6
|
-
|
6
|
+
check_file_context
|
7
7
|
breakout_navigation :step, steps
|
8
8
|
end
|
9
9
|
|
10
10
|
command 'next', 'Execute the next line within the same stack frame.' do |lines|
|
11
|
-
|
11
|
+
check_file_context
|
12
12
|
breakout_navigation :next, lines
|
13
13
|
end
|
14
14
|
|
15
15
|
command 'continue', 'Continue program execution and end the Pry session.' do
|
16
|
+
check_file_context
|
16
17
|
run 'exit-all'
|
17
18
|
end
|
18
19
|
|
@@ -29,11 +30,9 @@ module PryNav
|
|
29
30
|
}
|
30
31
|
end
|
31
32
|
|
32
|
-
#
|
33
|
-
|
34
|
-
|
35
|
-
file = target.eval('__FILE__')
|
36
|
-
if file != Pry.eval_path && (file =~ /(\(.*\))|<.*>/ || file == '' || file == '-e')
|
33
|
+
# Ensures that a command is executed in a local file context.
|
34
|
+
def check_file_context
|
35
|
+
unless PryNav.check_file_context(target)
|
37
36
|
raise Pry::CommandError, 'Cannot find local context. Did you use `binding.pry`?'
|
38
37
|
end
|
39
38
|
end
|
data/lib/pry-nav/pry_ext.rb
CHANGED
@@ -5,8 +5,16 @@ class << Pry
|
|
5
5
|
alias_method :start_existing, :start
|
6
6
|
|
7
7
|
def start(target = TOPLEVEL_BINDING, options = {})
|
8
|
-
|
9
|
-
|
8
|
+
old_options = options.reject { |k, _| k == :pry_remote }
|
9
|
+
|
10
|
+
if PryNav.check_file_context(target)
|
11
|
+
# Wrap the tracer around the usual Pry.start
|
12
|
+
PryNav::Tracer.new(options).run do
|
13
|
+
start_existing(target, old_options)
|
14
|
+
end
|
15
|
+
else
|
16
|
+
# No need for the tracer unless we have a file context to step through
|
17
|
+
start_existing(target, old_options)
|
10
18
|
end
|
11
19
|
end
|
12
20
|
end
|
data/lib/pry-nav/tracer.rb
CHANGED
data/lib/pry-nav/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry-nav
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-12-
|
12
|
+
date: 2011-12-03 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: pry
|
16
|
-
requirement: &
|
16
|
+
requirement: &70226772578740 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: 0.9.7.4
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70226772578740
|
25
25
|
description: Turn Pry into a primitive debugger. Adds 'step' and 'next' commands to
|
26
26
|
control execution.
|
27
27
|
email: nixme@stillhope.com
|
@@ -32,6 +32,7 @@ files:
|
|
32
32
|
- .gitignore
|
33
33
|
- CHANGELOG.md
|
34
34
|
- Gemfile
|
35
|
+
- LICENSE
|
35
36
|
- README.md
|
36
37
|
- Rakefile
|
37
38
|
- lib/pry-nav.rb
|