pry-nav 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,11 @@
1
+ ## 0.2.0 (2012-02-19)
2
+
3
+ # Removed single letter aliases for **step**, **next**, and **continue** because
4
+ of conflicts with common variable names.
5
+ * Update [pry-remote][pry-remote] support for 0.1.1. Older releases of
6
+ pry-remote no longer supported.
7
+
8
+
1
9
  ## 0.1.0 (2012-02-02)
2
10
 
3
11
  * MRI 1.8.7 support
data/README.md CHANGED
@@ -17,8 +17,12 @@ end
17
17
 
18
18
  **pry-nav** is not yet thread-safe, so only use in single-threaded environments.
19
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:
20
+ If you get `ArgumentError: uncaught throw :breakout_nav` errors, add `require
21
+ 'pry-nav'` before calling `binding.pry`.
22
+
23
+ Rudimentary support for [pry-remote][pry-remote] (>= 0.1.1) is also included.
24
+ Ensure pry-remote is loaded or required before pry-nav. For example, in a
25
+ Gemfile:
22
26
 
23
27
  ```ruby
24
28
  gem 'pry'
@@ -26,6 +30,14 @@ gem 'pry-remote'
26
30
  gem 'pry-nav'
27
31
  ```
28
32
 
33
+ Stepping through code often? Add the following shortcuts to `~/.pryrc`:
34
+
35
+ ```ruby
36
+ Pry.commands.alias_command 'c', 'continue'
37
+ Pry.commands.alias_command 's', 'step'
38
+ Pry.commands.alias_command 'n', 'next'
39
+ ```
40
+
29
41
  Debugging functionality is implemented through
30
42
  [`set_trace_func`][set_trace_func], which imposes a large performance
31
43
  penalty. **pry-nav** traces only when necessary, but due to a workaround for a
@@ -17,4 +17,7 @@ module PryNav
17
17
  file = target.eval('__FILE__')
18
18
  file == Pry.eval_path || (file !~ /(\(.*\))|<.*>/ && file != '' && file != '-e')
19
19
  end
20
+
21
+ # Reference to currently running pry-remote server. Used by the tracer.
22
+ attr_accessor :current_remote_server
20
23
  end
@@ -17,10 +17,6 @@ module PryNav
17
17
  run 'exit-all'
18
18
  end
19
19
 
20
- alias_command 'n', 'next'
21
- alias_command 's', 'step'
22
- alias_command 'c', 'continue'
23
-
24
20
  helpers do
25
21
  def breakout_navigation(action, times)
26
22
  _pry_.binding_stack.clear # Clear the binding stack.
@@ -1,89 +1,31 @@
1
1
  require 'pry-remote'
2
- require 'drb'
3
2
 
4
3
  module PryRemote
5
-
6
- # Extraction of Object#remote_pry from
7
- # https://github.com/Mon-Ouie/pry-remote/blob/master/lib/pry-remote.rb
8
- # into separate `start` and `stop` methods so that a DRb session can last over
9
- # multiple Pry.start calls.
10
- module Server
11
- extend self
12
-
13
- def start(host, port)
14
- uri = "druby://#{host}:#{port}"
15
-
16
- @client = PryRemote::Client.new
17
- @started = true
18
- DRb.start_service uri, @client
19
-
20
- puts "[pry-remote] Waiting for client on #{uri}"
21
- @client.wait
22
-
23
- # If client passed stdout and stderr, redirect actual messages there.
24
- @old_stdout, $stdout =
25
- if @client.stdout
26
- [$stdout, @client.stdout]
27
- else
28
- [$stdout, $stdout]
29
- end
30
-
31
- @old_stderr, $stderr =
32
- if @client.stderr
33
- [$stderr, @client.stderr]
34
- else
35
- [$stderr, $stderr]
36
- end
37
-
38
- # Before Pry starts, save the pager config.
39
- # We want to disable this because the pager won't do anything useful in
40
- # this case (it will run on the server).
41
- Pry.config.pager, @old_pager = false, Pry.config.pager
42
-
43
- # As above, but for system config
44
- Pry.config.system, @old_system = PryRemote::System, Pry.config.system
45
-
46
- @client
47
- end
48
-
49
- def stop
50
- return unless @started
51
-
52
- # Reset output streams
53
- $stdout = @old_stdout
54
- $stderr = @old_stderr
55
-
56
- # Reset config
57
- Pry.config.pager = @old_pager
58
-
59
- # Reset system
60
- Pry.config.system = @old_system
61
-
62
- begin
63
- @client.kill
64
- rescue DRb::DRbConnError
65
- # Ignore connection errors. The CLI client may have killed itself.
66
- ensure
67
- DRb.stop_service
4
+ class Server
5
+ # Override the call to Pry.start to save off current Server, pass a
6
+ # pry_remote flag so pry-nav knows this is a remote session, and not kill
7
+ # the server right away
8
+ def run
9
+ if PryNav.current_remote_server
10
+ raise 'Already running a pry-remote session!'
11
+ else
12
+ PryNav.current_remote_server = self
68
13
  end
69
14
 
70
- @started = false
71
- puts "[pry-remote] Remote sesion terminated"
15
+ setup
16
+ Pry.start @object, {
17
+ :input => client.input_proxy,
18
+ :output => client.output,
19
+ :pry_remote => true
20
+ }
72
21
  end
73
- end
74
- end
75
22
 
76
- class Object
77
- # Override pry-remote's Object#remote_pry to use the above
78
- # PryRemote::Server. The PryNav::Tracer instance is responsible for
79
- # terminating the DRb server by calling PryRemote::Server#stop
80
- def remote_pry(host = 'localhost', port = 9876)
81
- client = PryRemote::Server.start(host, port)
82
- Pry.start self, {
83
- :input => client.input_proxy,
84
- :output => client.output,
85
- :pry_remote => true
86
- }
23
+ # Override to reset our saved global current server session.
24
+ alias_method :teardown_existing, :teardown
25
+ def teardown
26
+ teardown_existing
27
+ PryNav.current_remote_server = nil
28
+ end
87
29
  end
88
30
  end
89
31
 
@@ -92,5 +34,7 @@ end
92
34
  # PryNav::Tracer#run doesn't have a chance to cleanup.
93
35
  at_exit do
94
36
  set_trace_func nil
95
- PryRemote::Server.stop
37
+ if PryNav.current_remote_server
38
+ PryNav.current_remote_server.teardown
39
+ end
96
40
  end
@@ -26,7 +26,9 @@ module PryNav
26
26
  start
27
27
  else
28
28
  stop if RUBY_VERSION == '1.9.2'
29
- PryRemote::Server.stop if @pry_start_options[:pry_remote]
29
+ if @pry_start_options[:pry_remote] && PryNav.current_remote_server
30
+ PryNav.current_remote_server.teardown
31
+ end
30
32
  end
31
33
 
32
34
  return_value
@@ -1,3 +1,3 @@
1
1
  module PryNav
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -20,4 +20,5 @@ Gem::Specification.new do |gem|
20
20
  # Dependencies
21
21
  gem.required_ruby_version = '>= 1.8.7'
22
22
  gem.add_runtime_dependency 'pry', '~> 0.9.8.1'
23
+ gem.add_development_dependency 'pry-remote', '~> 0.1.1'
23
24
  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.1.0
4
+ version: 0.2.0
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: 2012-02-03 00:00:00.000000000 Z
12
+ date: 2012-03-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pry
16
- requirement: &70283139020540 !ruby/object:Gem::Requirement
16
+ requirement: &70301060845020 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,7 +21,18 @@ dependencies:
21
21
  version: 0.9.8.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70283139020540
24
+ version_requirements: *70301060845020
25
+ - !ruby/object:Gem::Dependency
26
+ name: pry-remote
27
+ requirement: &70301060843440 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 0.1.1
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70301060843440
25
36
  description: Turn Pry into a primitive debugger. Adds 'step' and 'next' commands to
26
37
  control execution.
27
38
  email: nixme@stillhope.com