pry-nav 0.0.1 → 0.0.2

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.
@@ -0,0 +1,12 @@
1
+ ## 0.0.2 (2011-11-30)
2
+
3
+ * Rudimentary [pry-remote][pry-remote] support. Still a bit buggy.
4
+ * **continue** command as an alias for **exit-all**
5
+
6
+
7
+ ## 0.0.1 (2011-11-29)
8
+
9
+ * First release. Basic **step** and **next** commands.
10
+
11
+
12
+ [pry-remote]: https://github.com/Mon-Ouie/pry-remote
data/README.md CHANGED
@@ -3,27 +3,44 @@ pry-nav
3
3
 
4
4
  _Simple execution control in Pry_
5
5
 
6
- Adds **step** and **next** commands to your [Pry][pry]
6
+ Adds **step**, **next**, and **continue** commands to your [Pry][pry]
7
7
  console. Makes for a simple but ghetto debugger.
8
8
 
9
- Note: In order to get the correct flow control, `Pry.start` is overriden. Use at
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:
11
+
12
+ ```ruby
13
+ gem 'pry'
14
+ gem 'pry-remote'
15
+ gem 'pry-nav'
16
+ ```
17
+
18
+ Note: In order to get correct flow control, `Pry.start` is overriden. Use at
10
19
  your own risk.
11
20
 
12
21
 
22
+ ## Contributing
23
+
24
+ Patches and bug reports are welcome. Just send a [pull request][pullrequests] or
25
+ file an [issue][issues]. [Project changelog][changelog].
26
+
27
+
13
28
  ## Acknowledgments
14
29
 
15
- - Ruby stdlib [debug.rb][debug.rb]
30
+ - Ruby stdlib's [debug.rb][debug.rb]
16
31
  - [@Mon-Ouie][Mon-Ouie]'s [pry_debug][pry_debug]
17
32
 
18
33
 
19
34
  ## TODO
20
35
 
21
36
  - Thread safety
22
- - Compatibility with [pry-remote][pry-remote]
23
37
 
24
38
 
25
- [pry]: http://pry.github.com
26
- [debug.rb]: https://github.com/ruby/ruby/blob/trunk/lib/debug.rb
27
- [Mon-Ouie]: https://github.com/Mon-Ouie
28
- [pry_debug]: https://github.com/Mon-Ouie/pry_debug
29
- [pry-remote]: https://github.com/Mon-Ouie/pry-remote
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
@@ -2,3 +2,6 @@ require 'pry-nav/version'
2
2
  require 'pry-nav/pry_ext'
3
3
  require 'pry-nav/commands'
4
4
  require 'pry-nav/tracer'
5
+
6
+ # Optionally load pry-remote monkey patches
7
+ require 'pry-nav/pry_remote_ext' if defined? PryRemote
@@ -10,8 +10,13 @@ module PryNav
10
10
  breakout_navigation :next, lines
11
11
  end
12
12
 
13
+ command 'continue', 'Continue program execution and end the Pry session.' do
14
+ run 'exit-all'
15
+ end
16
+
13
17
  alias_command 'n', 'next'
14
18
  alias_command 's', 'step'
19
+ alias_command 'c', 'continue'
15
20
 
16
21
  helpers do
17
22
  def breakout_navigation(action, times)
@@ -1,11 +1,12 @@
1
1
  require 'pry'
2
+ require 'pry-nav/tracer'
2
3
 
3
4
  class << Pry
4
5
  alias_method :start_existing, :start
5
6
 
6
7
  def start(target = TOPLEVEL_BINDING, options = {})
7
8
  PryNav::Tracer.new(options) do
8
- start_existing(target, options)
9
+ start_existing(target, options.reject { |k, _| k == :pry_remote })
9
10
  end
10
11
  end
11
12
  end
@@ -0,0 +1,78 @@
1
+ require 'pry-remote'
2
+
3
+ module PryRemote
4
+
5
+ # Extraction of Object#remote_pry from
6
+ # https://github.com/Mon-Ouie/pry-remote/blob/master/lib/pry-remote.rb
7
+ # into separate `start` and `stop` methods so that a DRb session can last over
8
+ # multiple Pry.start calls.
9
+ module Server
10
+ extend self
11
+
12
+ def start(host, port)
13
+ uri = "druby://#{host}:#{port}"
14
+
15
+ @client = PryRemote::Client.new
16
+ DRb.start_service uri, @client
17
+
18
+ puts "[pry-remote] Waiting for client on #{uri}"
19
+ @client.wait
20
+
21
+ # If client passed stdout and stderr, redirect actual messages there.
22
+ @old_stdout, $stdout =
23
+ if @client.stdout
24
+ [$stdout, @client.stdout]
25
+ else
26
+ [$stdout, $stdout]
27
+ end
28
+
29
+ @old_stderr, $stderr =
30
+ if @client.stderr
31
+ [$stderr, @client.stderr]
32
+ else
33
+ [$stderr, $stderr]
34
+ end
35
+
36
+ # Before Pry starts, save the pager config.
37
+ # We want to disable this because the pager won't do anything useful in
38
+ # this case (it will run on the server).
39
+ Pry.config.pager, @old_pager = false, Pry.config.pager
40
+
41
+ # As above, but for system config
42
+ Pry.config.system, @old_system = PryRemote::System, Pry.config.system
43
+
44
+ @client
45
+ end
46
+
47
+ def stop
48
+ # Reset output streams
49
+ $stdout = @old_stdout
50
+ $stderr = @old_stderr
51
+
52
+ # Reset config
53
+ Pry.config.pager = @old_pager
54
+
55
+ # Reset system
56
+ Pry.config.system = @old_system
57
+
58
+ puts "[pry-remote] Remote sesion terminated"
59
+ @client.kill
60
+
61
+ DRb.stop_service
62
+ end
63
+ end
64
+ end
65
+
66
+ class Object
67
+ # Override pry-remote's Object#remote_pry to use the above
68
+ # PryRemote::Server. The PryNav::Tracer instance is responsible for
69
+ # terminating the DRb server by calling PryRemote::Server#stop
70
+ def remote_pry(host = 'localhost', port = 9876)
71
+ client = PryRemote::Server.start(host, port)
72
+ Pry.start self, {
73
+ :input => client.input_proxy,
74
+ :output => client.output,
75
+ :pry_remote => true
76
+ }
77
+ end
78
+ end
@@ -48,6 +48,7 @@ module PryNav
48
48
  @frames_when_stepping = @frames.size
49
49
  else
50
50
  stop
51
+ PryRemote::Server.stop if @pry_start_options[:pry_remote]
51
52
  end
52
53
  end
53
54
 
@@ -1,3 +1,3 @@
1
1
  module PryNav
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
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.1
4
+ version: 0.0.2
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-11-29 00:00:00.000000000 Z
12
+ date: 2011-11-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pry
16
- requirement: &70106424403940 !ruby/object:Gem::Requirement
16
+ requirement: &70264352532260 !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: *70106424403940
24
+ version_requirements: *70264352532260
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
@@ -30,12 +30,14 @@ extensions: []
30
30
  extra_rdoc_files: []
31
31
  files:
32
32
  - .gitignore
33
+ - CHANGELOG.md
33
34
  - Gemfile
34
35
  - README.md
35
36
  - Rakefile
36
37
  - lib/pry-nav.rb
37
38
  - lib/pry-nav/commands.rb
38
39
  - lib/pry-nav/pry_ext.rb
40
+ - lib/pry-nav/pry_remote_ext.rb
39
41
  - lib/pry-nav/tracer.rb
40
42
  - lib/pry-nav/version.rb
41
43
  - pry-nav.gemspec