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.
@@ -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
- Adds **step**, **next**, and **continue** commands to your [Pry][pry]
7
- console. Makes for a simple but ghetto debugger.
6
+ Teaches [Pry][pry] about **step**, **next**, and **continue** to create a simple
7
+ debugger.
8
8
 
9
- Rudimentary support for [pry-remote][pry-remote] is included. Ensure pry-remote
10
- is loaded or required before pry-nav. For example, in a Gemfile:
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
- Note: In order to get correct flow control, `Pry.start` is overriden. Use at
19
- your own risk.
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
- ## TODO
35
-
36
- - Thread safety
37
-
38
-
39
- [pry]: http://pry.github.com
40
- [pry-remote]: https://github.com/Mon-Ouie/pry-remote
41
- [changelog]: https://github.com/nixme/pry-nav/blob/master/CHANGELOG.md
42
- [issues]: https://github.com/nixme/pry-nav/issues
43
- [pullrequests]: https://github.com/nixme/pry-nav/pulls
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
@@ -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
@@ -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
- check_local_context
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
- check_local_context
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
- # Checks that a command is executed in a local file context. Extracted
33
- # from https://github.com/pry/pry/blob/master/lib/pry/default_commands/context.rb
34
- def check_local_context
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
@@ -5,8 +5,16 @@ class << Pry
5
5
  alias_method :start_existing, :start
6
6
 
7
7
  def start(target = TOPLEVEL_BINDING, options = {})
8
- PryNav::Tracer.new(options) do
9
- start_existing(target, options.reject { |k, _| k == :pry_remote })
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
@@ -7,8 +7,6 @@ module PryNav
7
7
  @frames_when_stepping = nil # Only break at this frame level
8
8
  @frames = 0 # Traced stack frame level
9
9
  @pry_start_options = pry_start_options # Options to use for Pry.start
10
-
11
- run &block
12
10
  end
13
11
 
14
12
  def run(&block)
@@ -1,3 +1,3 @@
1
1
  module PryNav
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
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.3
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-01 00:00:00.000000000Z
12
+ date: 2011-12-03 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pry
16
- requirement: &70332078184900 !ruby/object:Gem::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: *70332078184900
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