pry-nav 0.3.0 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60380e147933ae1e2ba3ecef2259bec48e90cef46f1fa5c28e4272e3c92b87c2
4
- data.tar.gz: 645b2e7372f791a6d8f907025a9884ac4f8b2e9d2f9c165118c99cca48a5a946
3
+ metadata.gz: 342150dc2c72e13894b2e824b2e0d3104fdd7bfb345e081b509da4cc865e2533
4
+ data.tar.gz: 2b94f22aba1710e1202af420e59521f634202e7c327f67f9a358b16c18fb0d98
5
5
  SHA512:
6
- metadata.gz: c494dfb85a667aa37007e22088085e73444cb08a3525d1f87c129cca087ab8e79851a4cb9791cb5855064b3f50baa88d0186df6c208cbf0fad69e533618bafd1
7
- data.tar.gz: 6ee2450ed59686be5522dd78b9b4da811106e4235a79952e48603c49eca9fd089f93c1b29bff2522243f7caba20c77ee204f1c41855534328065fc9c71eb0118
6
+ metadata.gz: edc7473c442feaf082961bf7be9bb341692e9c47ee1128cbcab90c12b3c394121ad40974a6d84f07ca4cf0926d6f50661a9cfa2b2eba0b194d22bc0820edac21
7
+ data.tar.gz: b3aef7a0f36f115d35ee932f53c5547a98b94ee43637a36f164a996a675465435c514fe824799778dd1f1274f7bf3ebbf4c509e3d404cdbaf910a5df0b2a971f
@@ -0,0 +1,20 @@
1
+ name: Ruby
2
+
3
+ on: [push,pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ strategy:
9
+ matrix:
10
+ ruby-version: ['3.0', 2.7, 2.6, 2.5, 2.4, 2.3, 2.2, 2.1]
11
+ steps:
12
+ - uses: actions/checkout@v2
13
+ - name: Set up Ruby ${{ matrix.ruby-version }}
14
+ uses: ruby/setup-ruby@v1
15
+ with:
16
+ ruby-version: ${{ matrix.ruby-version }}
17
+ - name: Install dependencies
18
+ run: bundle install
19
+ - name: Run tests
20
+ run: bundle exec rake
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ vendor/bundle
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.7.3
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 1.0.0
2
+
3
+ * Drop support for ruby < 2.1.
4
+ * Support Pry 0.14
5
+ * Adding tests
6
+ * Fix warning on ruby 2.7
7
+
1
8
  ## 0.3.0 (2019-04-16)
2
9
 
3
10
  * Fix circular require warning.
data/Gemfile CHANGED
@@ -1,4 +1,7 @@
1
1
  source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in pry-nav.gemspec
4
2
  gemspec
3
+
4
+ gem "test-unit"
5
+
6
+ gem "pry", "~> 0.14.1"
7
+ gem "pry-remote"
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
- ### Using MRI? We recommend [**pry-byebug**][pry-byebug] instead!
1
+ ### Using MRI? We recommend [**break**][break] or [**pry-byebug**][pry-byebug] instead!
2
2
 
3
- # pry-nav
3
+ # pry-nav [![Ruby](https://github.com/nixme/pry-nav/actions/workflows/main.yml/badge.svg)](https://github.com/nixme/pry-nav/actions/workflows/main.yml)
4
4
 
5
5
  _A simple execution control add-on for [Pry][pry]._
6
6
 
7
- Compatible with MRI >= 1.8.7, ![JRuby](https://raw.githubusercontent.com/jruby/collateral/master/logos/PNGs/logo-with-type/full-color/jruby-logo-logo-with-type-small.png) >= 9.1.3.0.
7
+ Compatible with MRI >= 2.1.0, JRuby >= 9.1.3.0.
8
8
 
9
9
  Teaches [Pry][pry] about `step`, `next`, and `continue` to create a simple
10
10
  debugger.
@@ -55,6 +55,7 @@ penalty.
55
55
  * Benjamin R. Haskell ([@benizi](https://github.com/benizi))
56
56
  * Jason R. Clark ([@jasonrclark](https://github.com/jasonrclark))
57
57
  * Ivo Anjo ([@ivoanjo](https://github.com/ivoanjo))
58
+ * Michael Bianco ([@iloveitaly](https://github.com/iloveitaly))
58
59
 
59
60
  Patches and bug reports are welcome. Just send a [pull request][pullrequests] or
60
61
  file an [issue][issues]. [Project changelog][changelog].
@@ -74,3 +75,4 @@ file an [issue][issues]. [Project changelog][changelog].
74
75
  [Mon-Ouie]: https://github.com/Mon-Ouie
75
76
  [pry_debug]: https://github.com/Mon-Ouie/pry_debug
76
77
  [pry-byebug]: https://github.com/deivid-rodriguez/pry-byebug
78
+ [break]: https://github.com/gsamokovarov/break
data/Rakefile CHANGED
@@ -1,2 +1,10 @@
1
- #!/usr/bin/env rake
2
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ task :default => :test
5
+
6
+ Rake::TestTask.new(:test) do |task|
7
+ task.libs << 'test'
8
+ task.test_files = FileList['test/*_test.rb']
9
+ task.verbose = true
10
+ end
@@ -19,11 +19,12 @@ module PryNav
19
19
 
20
20
  helpers do
21
21
  def breakout_navigation(action, times)
22
- _pry_.binding_stack.clear # Clear the binding stack.
23
- throw :breakout_nav, { # Break out of the REPL loop and
24
- :action => action, # signal the tracer.
25
- :times => times
26
- }
22
+ pry_instance.binding_stack.clear # Clear the binding stack.
23
+ throw(
24
+ :breakout_nav, # Break out of the REPL loop and
25
+ action: action, # signal the tracer.
26
+ times: times,
27
+ )
27
28
  end
28
29
 
29
30
  # Ensures that a command is executed in a local file context.
@@ -2,7 +2,7 @@ require 'pry' unless defined? Pry
2
2
  require 'pry-nav/tracer'
3
3
 
4
4
  class << Pry
5
- alias_method :start_without_pry_nav, :start
5
+ alias start_without_pry_nav start
6
6
 
7
7
  def start_with_pry_nav(target = TOPLEVEL_BINDING, options = {})
8
8
  old_options = options.reject { |k, _| k == :pry_remote }
@@ -18,5 +18,5 @@ class << Pry
18
18
  end
19
19
  end
20
20
 
21
- alias_method :start, :start_with_pry_nav
21
+ alias start start_with_pry_nav
22
22
  end
@@ -14,20 +14,21 @@ module PryRemote
14
14
  end
15
15
 
16
16
  setup
17
- Pry.start @object, {
18
- :input => client.input_proxy,
19
- :output => client.output,
20
- :pry_remote => true
21
- }
17
+ Pry.start(
18
+ @object,
19
+ input: client.input_proxy,
20
+ output: client.output,
21
+ pry_remote: true,
22
+ )
22
23
  end
23
24
 
24
25
  # Override to reset our saved global current server session.
25
- alias_method :teardown_without_pry_nav, :teardown
26
+ alias teardown_without_pry_nav teardown
26
27
  def teardown_with_pry_nav
27
28
  teardown_without_pry_nav
28
29
  PryNav.current_remote_server = nil
29
30
  end
30
- alias_method :teardown, :teardown_with_pry_nav
31
+ alias teardown teardown_with_pry_nav
31
32
  end
32
33
  end
33
34
 
@@ -36,7 +37,5 @@ end
36
37
  # PryNav::Tracer#run doesn't have a chance to cleanup.
37
38
  at_exit do
38
39
  set_trace_func nil
39
- if PryNav.current_remote_server
40
- PryNav.current_remote_server.teardown
41
- end
40
+ PryNav.current_remote_server.teardown if PryNav.current_remote_server
42
41
  end
@@ -2,18 +2,16 @@ require 'pry' unless defined? Pry
2
2
 
3
3
  module PryNav
4
4
  class Tracer
5
- def initialize(pry_start_options = {}, &block)
5
+ def initialize(pry_start_options = {})
6
6
  @step_in_lines = -1 # Break after this many lines
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
10
  end
11
11
 
12
- def run(&block)
12
+ def run
13
13
  # For performance, disable any tracers while in the console.
14
- # Unfortunately doesn't work in 1.9.2 because of
15
- # http://redmine.ruby-lang.org/issues/3921. Works fine in 1.8.7 and 1.9.3.
16
- stop unless RUBY_VERSION == '1.9.2'
14
+ stop
17
15
 
18
16
  return_value = nil
19
17
  command = catch(:breakout_nav) do # Coordinates with PryNav::Commands
@@ -25,7 +23,6 @@ module PryNav
25
23
  if process_command(command)
26
24
  start
27
25
  else
28
- stop if RUBY_VERSION == '1.9.2'
29
26
  if @pry_start_options[:pry_remote] && PryNav.current_remote_server
30
27
  PryNav.current_remote_server.teardown
31
28
  end
@@ -60,10 +57,9 @@ module PryNav
60
57
  end
61
58
  end
62
59
 
60
+ private
63
61
 
64
- private
65
-
66
- def tracer(event, file, line, id, binding, klass)
62
+ def tracer(event, file, _line, _id, binding, _klass)
67
63
  # Ignore traces inside pry-nav code
68
64
  return if file && TRACE_IGNORE_FILES.include?(File.expand_path(file))
69
65
 
@@ -81,7 +77,7 @@ module PryNav
81
77
  end
82
78
 
83
79
  # Break on this line?
84
- Pry.start(binding, @pry_start_options) if @step_in_lines == 0
80
+ Pry.start(binding, @pry_start_options) if @step_in_lines.zero?
85
81
 
86
82
  when 'call', 'class'
87
83
  @frames += 1 # Track entering a frame
@@ -1,3 +1,3 @@
1
1
  module PryNav
2
- VERSION = '0.3.0'
2
+ VERSION = '1.0.0'
3
3
  end
data/lib/pry-nav.rb CHANGED
@@ -14,7 +14,12 @@ module PryNav
14
14
  # Checks that a binding is in a local file context. Extracted from
15
15
  # https://github.com/pry/pry/blob/master/lib/pry/default_commands/context.rb
16
16
  def check_file_context(target)
17
- file = target.eval('__FILE__')
17
+ file = if target.respond_to?(:source_location)
18
+ target.source_location.first
19
+ else
20
+ target.eval('__FILE__')
21
+ end
22
+
18
23
  file == Pry.eval_path || (file !~ /(\(.*\))|<.*>/ && file != '' && file != '-e')
19
24
  end
20
25
 
data/pry-nav.gemspec CHANGED
@@ -12,13 +12,12 @@ Gem::Specification.new do |gem|
12
12
  gem.summary = 'Simple execution navigation for Pry.'
13
13
  gem.description = "Turn Pry into a primitive debugger. Adds 'step' and 'next' commands to control execution."
14
14
 
15
- gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
15
+ gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
16
16
  gem.files = `git ls-files`.split("\n")
17
17
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
- gem.require_paths = ["lib"]
18
+ gem.require_paths = ['lib']
19
19
 
20
- # Dependencies
21
- gem.required_ruby_version = '>= 1.8.7'
22
- gem.add_runtime_dependency 'pry', '>= 0.9.10', '< 0.13.0'
23
- gem.add_development_dependency 'pry-remote', '~> 0.1.6'
20
+ gem.required_ruby_version = '>= 2.1.0'
21
+ gem.add_runtime_dependency 'pry', '>= 0.9.10', '< 0.15'
22
+ gem.add_development_dependency 'rake'
24
23
  end
@@ -0,0 +1,98 @@
1
+ # frozen_string_literal: true
2
+
3
+ require ::File.expand_path("test_helper", __dir__)
4
+
5
+ class PryNavTest < Test::Unit::TestCase
6
+ # removing color makes string matching easier
7
+ def setup
8
+ Pry.color = false
9
+ end
10
+
11
+ # lifted from:
12
+ # https://github.com/pry/pry-stack_explorer/blob/e3e6bd202e092712900f0d5f239ee21ab2f32b2b/test/support/io_utils.rb
13
+ def with_pry_output_captured(new_in, new_out = StringIO.new)
14
+ old_in = Pry.input
15
+ old_out = Pry.output
16
+
17
+ # direct stdout so we can test against `puts` in the method we defined above
18
+ old_stdout = $stdout
19
+ $stdout = new_out
20
+
21
+ Pry.input = new_in
22
+ Pry.output = new_out
23
+
24
+ begin
25
+ yield
26
+ ensure
27
+ Pry.input = old_in
28
+ Pry.output = old_out
29
+ $stdout = old_stdout
30
+ end
31
+
32
+ new_out
33
+ end
34
+
35
+ # `step` will step into the frames, while `next` keeps the debugging execution within the frame
36
+ def test_step
37
+ o = NavSample.new
38
+
39
+ r = with_pry_output_captured(
40
+ InputTester.new(
41
+ "step",
42
+
43
+ "step",
44
+ "step",
45
+
46
+ "continue"
47
+ )
48
+ ){ o.nested_bind_with_call }
49
+
50
+ # initial binding display
51
+ assert(r.string.include?("def nested_bind_with_call"))
52
+
53
+ # after two steps, we are in the second frame, let's make sure we get there
54
+ assert(r.string.include?("def nested_bind_call"))
55
+
56
+ assert(/nested_puts\n/ =~ r.string)
57
+ assert(/root_puts\n/ =~ r.string)
58
+ end
59
+
60
+ def test_next
61
+ o = NavSample.new
62
+
63
+ r = with_pry_output_captured(
64
+ InputTester.new(
65
+ "next",
66
+ "next",
67
+ "next",
68
+ "continue"
69
+ )
70
+ ){ o.nested_bind_with_call }
71
+
72
+ assert(r.string.include?("def nested_bind_with_call"))
73
+ refute(r.string.include?("def nested_bind_call"))
74
+
75
+ assert(/nested_puts\n/ =~ r.string)
76
+ assert(/root_puts\n/ =~ r.string)
77
+ end
78
+
79
+ def test_continue
80
+ o = NavSample.new
81
+
82
+ r = with_pry_output_captured(
83
+ InputTester.new(
84
+ "continue",
85
+ )
86
+ ){ o.nested_bind_with_call }
87
+
88
+ assert(r.string.include?("def nested_bind_with_call"))
89
+ refute(r.string.include?("def nested_bind_call"))
90
+
91
+ assert(/nested_puts\n/ =~ r.string)
92
+ assert(/root_puts\n/ =~ r.string)
93
+ end
94
+
95
+ def test_file_context
96
+ assert(PryNav.check_file_context(binding))
97
+ end
98
+ end
@@ -0,0 +1,39 @@
1
+ require 'bundler/setup'
2
+ require 'test/unit'
3
+
4
+ # lets make sure it works will all of the pry extensions
5
+ Bundler.require
6
+
7
+ class NavSample
8
+ def nested_bind_with_call
9
+ Pry.start(binding)
10
+ nested_bind_call
11
+ puts "root_puts"
12
+ end
13
+
14
+ def nested_bind_call
15
+ puts "nested_puts"
16
+ end
17
+ end
18
+
19
+ # lifted from:
20
+ # https://github.com/pry/pry-stack_explorer/blob/e3e6bd202e092712900f0d5f239ee21ab2f32b2b/test/support/input_tester.rb
21
+
22
+ class InputTester
23
+ def initialize(*actions)
24
+ if actions.last.is_a?(Hash) && actions.last.keys == [:history]
25
+ @hist = actions.pop[:history]
26
+ end
27
+
28
+ @orig_actions = actions.dup
29
+ @actions = actions
30
+ end
31
+
32
+ def readline(*)
33
+ @actions.shift.tap{ |line| @hist << line if @hist }
34
+ end
35
+
36
+ def rewind
37
+ @actions = @orig_actions.dup
38
+ end
39
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pry-nav
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gopal Patel
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-16 00:00:00.000000000 Z
11
+ date: 2021-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: 0.9.10
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: 0.13.0
22
+ version: '0.15'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,21 +29,21 @@ dependencies:
29
29
  version: 0.9.10
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: 0.13.0
32
+ version: '0.15'
33
33
  - !ruby/object:Gem::Dependency
34
- name: pry-remote
34
+ name: rake
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - "~>"
37
+ - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: 0.1.6
39
+ version: '0'
40
40
  type: :development
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - "~>"
44
+ - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 0.1.6
46
+ version: '0'
47
47
  description: Turn Pry into a primitive debugger. Adds 'step' and 'next' commands to
48
48
  control execution.
49
49
  email: nixme@stillhope.com
@@ -51,7 +51,9 @@ executables: []
51
51
  extensions: []
52
52
  extra_rdoc_files: []
53
53
  files:
54
+ - ".github/workflows/main.yml"
54
55
  - ".gitignore"
56
+ - ".ruby-version"
55
57
  - CHANGELOG.md
56
58
  - Gemfile
57
59
  - LICENSE
@@ -65,11 +67,13 @@ files:
65
67
  - lib/pry-nav/tracer.rb
66
68
  - lib/pry-nav/version.rb
67
69
  - pry-nav.gemspec
70
+ - test/pry_nav_test.rb
71
+ - test/test_helper.rb
68
72
  homepage: https://github.com/nixme/pry-nav
69
73
  licenses:
70
74
  - MIT
71
75
  metadata: {}
72
- post_install_message:
76
+ post_install_message:
73
77
  rdoc_options: []
74
78
  require_paths:
75
79
  - lib
@@ -77,15 +81,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
77
81
  requirements:
78
82
  - - ">="
79
83
  - !ruby/object:Gem::Version
80
- version: 1.8.7
84
+ version: 2.1.0
81
85
  required_rubygems_version: !ruby/object:Gem::Requirement
82
86
  requirements:
83
87
  - - ">="
84
88
  - !ruby/object:Gem::Version
85
89
  version: '0'
86
90
  requirements: []
87
- rubygems_version: 3.0.1
88
- signing_key:
91
+ rubygems_version: 3.1.6
92
+ signing_key:
89
93
  specification_version: 4
90
94
  summary: Simple execution navigation for Pry.
91
- test_files: []
95
+ test_files:
96
+ - test/pry_nav_test.rb
97
+ - test/test_helper.rb