pry-byebug 1.1.0 → 1.1.1

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
  SHA1:
3
- metadata.gz: 121ca8dcd9228688b55ebb264c755664ec8c912f
4
- data.tar.gz: ceb7af746b551eb0cec30d952540fcf9e968eb7a
3
+ metadata.gz: e1e394709d63ed2099ec627d75981a29885c9641
4
+ data.tar.gz: 1a79cdd78a21fde30ff264adcbeeec8c96af877c
5
5
  SHA512:
6
- metadata.gz: 03f9ce397f963ae6894b003d81df2900cba0f6a620d4a9d422896fe30484b29f3880ddeb99fbf01514bd51bd4f232d77c3866d29f7a404ff04cdf8aa43b10d9b
7
- data.tar.gz: 2e2a734a5b1757eabd733fdba6036e61752060592c575b08a9aa33d28c12e80bf36fa39e3c8c1c791367b1174126bc9a2cd32c7ec0389824589cab161c0a6cc6
6
+ metadata.gz: 083288cd0f862524132bda50de9ac708ee173e39718bb0594ca176c043cfc49cd35eca27c8ed69b67d3ad70c5d5a3d2ff10e99ffd89c77f4ba509beb2ee7e0ff
7
+ data.tar.gz: 3c0224f0d2895b5f60745ef89d672fc0cc11ac260ddb19ce81ac139f5c9146d3b8615d1ddb9a6610150a01225e832884f541ce91fd77f7720828a9e85fc9db22
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ rvm:
2
+ - 2.0.0
3
+ - ruby-head
4
+ matrix:
5
+ allow_failures:
6
+ - rvm: ruby-head
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
- ## 1.1.0 (2013-06-06)
1
+ ## 1.1.1 (2013-02-07)
2
+
3
+ * Adds some initial tests to the test suite
4
+ * Fixes bug when doing "step n" or "next n" where n > 1 right after binding.pry
2
5
 
6
+
7
+ ## 1.1.0 (2013-06-06)
8
+
3
9
  * Adds a test suite (thanks @teeparham!)
4
10
  * Uses byebug ~> 1.4.0
5
11
  * Uses s, n, f and c aliases by default (thanks @jgakos!)
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- pry-byebug
1
+ pry-byebug [![Gem Version][1]][2] [![Build Status][3]][4]
2
2
  ============
3
3
 
4
4
  _Fast execution control in Pry_
@@ -112,3 +112,7 @@ file an [issue][issues]. [Project changelog][changelog].
112
112
  [issues]: https://github.com/deivid-rodriguez/pry-byebug/issues
113
113
  [changelog]: https://github.com/deivid-rodriguez/pry-byebug/blob/master/CHANGELOG.md
114
114
  [pry-nav]: https://github.com/nixme/pry-nav
115
+ [1]: https://badge.fury.io/rb/pry-byebug.png
116
+ [2]: http://badge.fury.io/rb/pry-byebug
117
+ [3]: https://secure.travis-ci.org/deivid-rodriguez/pry-byebug.png
118
+ [4]: http://travis-ci.org/deivid-rodriguez/pry-byebug
data/Rakefile CHANGED
@@ -1,10 +1,8 @@
1
- #!/usr/bin/env rake
2
1
  require 'bundler/gem_tasks'
3
2
  require 'rake/testtask'
4
3
 
5
4
  desc 'Run tests'
6
5
  Rake::TestTask.new(:test) do |t|
7
- t.libs << 'lib'
8
6
  t.libs << 'test'
9
7
  t.pattern = 'test/**/*_test.rb'
10
8
  end
@@ -48,7 +48,6 @@ module PryByebug
48
48
  end
49
49
  alias_command 'n', 'next'
50
50
 
51
-
52
51
  create_command 'finish' do
53
52
  description 'Execute until current stack frame returns.'
54
53
 
@@ -215,12 +214,11 @@ module PryByebug
215
214
  end
216
215
  alias_command 'breaks', 'breakpoints'
217
216
 
218
-
219
217
  helpers do
220
218
  def breakout_navigation(action, times = nil)
221
- _pry_.binding_stack.clear # Clear the binding stack.
222
- throw :breakout_nav, { # Break out of the REPL loop and
223
- :action => action, # signal the tracer.
219
+ _pry_.binding_stack.clear # Clear the binding stack.
220
+ throw :breakout_nav, { # Break out of the REPL loop and signal tracer
221
+ :action => action,
224
222
  :times => times,
225
223
  :pry => _pry_
226
224
  }
@@ -14,6 +14,7 @@ module PryByebug
14
14
  # Wrap a Pry REPL to catch navigational commands and act on them.
15
15
  def run(initial = true, &block)
16
16
  return_value = nil
17
+
17
18
  command = catch(:breakout_nav) do # Throws from PryByebug::Commands
18
19
  return_value = yield
19
20
  {} # Nothing thrown == no navigational command
@@ -31,18 +32,16 @@ module PryByebug
31
32
  # inside Byebug. If we step normally, it'll stop inside this
32
33
  # Processor. So jump out and stop at the above frame, then step/next
33
34
  # from our callback.
34
- finish
35
35
  @delayed[command[:action]] = times
36
- end
37
-
38
- if :next == command[:action]
36
+ step_out 2
37
+ elsif :next == command[:action]
39
38
  step_over times
40
39
 
41
40
  elsif :step == command[:action]
42
- step times
41
+ step_into times
43
42
 
44
43
  elsif :finish == command[:action]
45
- finish
44
+ step_out
46
45
  end
47
46
  else
48
47
  stop
@@ -64,30 +63,24 @@ module PryByebug
64
63
  end
65
64
  end
66
65
 
67
-
68
66
  # --- Callbacks from byebug C extension ---
69
-
70
67
  def at_line(context, file, line)
71
- # If stopped for a breakpoint or catchpoint, can't play any delayed steps
72
- # as they'll move away from the interruption point. (Unsure if scenario is
73
- # possible, but just keeping assertions in check.)
74
- @delayed = Hash.new(0) unless :step == context.stop_reason
68
+ # If any delayed nexts/steps, do 'em.
69
+ if @delayed[:next] > 1
70
+ step_over @delayed[:next] - 1
75
71
 
76
- if @delayed[:next] > 0 # If any delayed nexts/steps, do 'em.
77
- step_over @delayed[:next]
78
- @delayed = Hash.new(0)
72
+ elsif @delayed[:step] > 1
73
+ step_into @delayed[:step] - 1
79
74
 
80
- elsif @delayed[:step] > 0
81
- step @delayed[:step]
82
- @delayed = Hash.new(0)
75
+ elsif @delayed[:finish] > 1
76
+ step_out @delayed[:finish] - 1
83
77
 
84
- elsif @delayed[:finish] > 0
85
- finish
86
- @delayed = Hash.new(0)
87
-
88
- else # Otherwise, resume the pry session at the stopped line.
78
+ # Otherwise, resume the pry session at the stopped line.
79
+ else
89
80
  resume_pry context
90
81
  end
82
+
83
+ @delayed = Hash.new(0)
91
84
  end
92
85
 
93
86
  # Called when a breakpoint is triggered. Note: `at_line`` is called
@@ -99,7 +92,7 @@ module PryByebug
99
92
  "Hit #{breakpoint.hit_count} times." )
100
93
  if (expr = breakpoint.expr)
101
94
  @pry.output.print Pry::Helpers::Text.bold("Condition: ")
102
- @pry.output.puts expr
95
+ @pry.output.puts expr
103
96
  end
104
97
  end
105
98
 
@@ -107,42 +100,40 @@ module PryByebug
107
100
  # TODO
108
101
  end
109
102
 
103
+ private
110
104
 
111
- private
112
-
113
- # Resume an existing Pry REPL at the paused point. Binding extracted from
114
- # the Byebug::Context.
115
- def resume_pry(context)
116
- new_binding = context.frame_binding(0)
117
- Byebug.stop unless @always_enabled
105
+ # Resume an existing Pry REPL at the paused point.
106
+ # Binding extracted from Byebug::Context
107
+ def resume_pry(context)
108
+ new_binding = context.frame_binding(0)
109
+ Byebug.stop unless @always_enabled
118
110
 
119
- @pry.binding_stack.clear
120
- run(false) do
121
- @pry.repl new_binding
111
+ run(false) do
112
+ @pry.repl new_binding
113
+ end
122
114
  end
123
- end
124
115
 
125
- # Move execution forward.
126
- def step(times)
127
- Byebug.context.step_into times
128
- end
116
+ # Move execution forward.
117
+ def step_into(times)
118
+ Byebug.context.step_into times
119
+ end
129
120
 
130
- # Move execution forward a number of lines in the same frame.
131
- def step_over(lines)
132
- Byebug.context.step_over lines, 0
133
- end
121
+ # Move execution forward a number of lines in the same frame.
122
+ def step_over(lines)
123
+ Byebug.context.step_over lines, 0
124
+ end
134
125
 
135
- # Execute until specified frame returns.
136
- def finish(frame = 0)
137
- Byebug.context.step_out frame
138
- end
126
+ # Execute until specified frame returns.
127
+ def step_out(frame = 0)
128
+ Byebug.context.step_out frame
129
+ end
139
130
 
140
- # Cleanup when debugging is stopped and execution continues.
141
- def stop
142
- Byebug.stop if !@always_enabled && Byebug.started?
143
- if PryByebug.current_remote_server # Cleanup DRb remote if running
144
- PryByebug.current_remote_server.teardown
131
+ # Cleanup when debugging is stopped and execution continues.
132
+ def stop
133
+ Byebug.stop if !@always_enabled && Byebug.started?
134
+ if PryByebug.current_remote_server # Cleanup DRb remote if running
135
+ PryByebug.current_remote_server.teardown
136
+ end
145
137
  end
146
- end
147
138
  end
148
139
  end
@@ -9,7 +9,7 @@ class << Pry
9
9
  @processor ||= PryByebug::Processor.new
10
10
 
11
11
  if target.is_a?(Binding) && PryByebug.check_file_context(target)
12
- # Wrap the processer around the usual Pry.start to catch navigation
12
+ # Wrap the processor around the usual Pry.start to catch navigation
13
13
  # commands.
14
14
  @processor.run(true) do
15
15
  start_without_pry_byebug(target, options)
@@ -1,3 +1,3 @@
1
1
  module PryByebug
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.1'
3
3
  end
data/pry-byebug.gemspec CHANGED
@@ -13,15 +13,15 @@ Gem::Specification.new do |gem|
13
13
 
14
14
  gem.files = `git ls-files`.split("\n")
15
15
  gem.test_files = `git ls-files -- test/*`.split("\n")
16
+ gem.require_paths = ['lib']
16
17
 
17
18
  # Dependencies
18
19
  gem.required_ruby_version = '>= 2.0.0'
19
20
 
20
21
  gem.add_runtime_dependency 'pry', '~> 0.9.12'
21
- gem.add_runtime_dependency 'byebug', '~> 1.4.0'
22
+ gem.add_runtime_dependency 'byebug', '~> 1.5.0'
22
23
 
23
24
  gem.add_development_dependency 'bundler', '~> 1.3.5'
24
- gem.add_development_dependency 'rake', '~> 10.0.4'
25
- gem.add_development_dependency 'minitest', '~> 5.0.3'
25
+ gem.add_development_dependency 'rake', '~> 10.1.0'
26
26
  gem.add_development_dependency 'mocha', '~> 0.14.0'
27
27
  end
data/test/base_test.rb CHANGED
@@ -1,15 +1,14 @@
1
1
  require 'test_helper'
2
2
 
3
- class BaseTest < Minitest::Test
3
+ class BaseTest < MiniTest::Spec
4
4
  def test_main_file_context
5
5
  Pry.stubs eval_path: "<main>"
6
6
  assert PryByebug.check_file_context(TOPLEVEL_BINDING)
7
7
  end
8
-
8
+
9
9
  def test_other_file_context
10
10
  Pry.stubs eval_path: "something"
11
- refute PryByebug.check_file_context(TOPLEVEL_BINDING)
11
+ refute PryByebug.check_file_context(TOPLEVEL_BINDING)
12
12
  end
13
-
14
13
  end
15
14
 
@@ -1,7 +1,7 @@
1
1
  require 'test_helper'
2
2
 
3
- class BreakpointsTest < Minitest::Test
4
-
3
+ class BreakpointsTest < MiniTest::Spec
4
+
5
5
  def test_add_raises_argument_error
6
6
  Pry.stubs eval_path: "something"
7
7
  File.stubs :exist?
@@ -9,6 +9,6 @@ class BreakpointsTest < Minitest::Test
9
9
  PryByebug::Breakpoints.add("file", 1)
10
10
  end
11
11
  end
12
-
12
+
13
13
  end
14
14
 
@@ -1,6 +1,72 @@
1
1
  require 'test_helper'
2
2
 
3
- class CommandsTest < Minitest::Test
4
-
3
+ class CommandsTest < MiniTest::Spec
4
+ let(:step_file) do
5
+ (Pathname.new(__FILE__) + "../examples/stepping.rb").cleanpath.to_s
6
+ end
7
+
8
+ before do
9
+ Pry.color = false
10
+ Pry.pager = false
11
+ Pry.hooks = Pry::DEFAULT_HOOKS
12
+ @output = StringIO.new
13
+ end
14
+
15
+ describe 'Step Command' do
16
+ describe 'single step' do
17
+ before do
18
+ @input = InputTester.new('step')
19
+ redirect_pry_io(@input, @output) do
20
+ load step_file
21
+ end
22
+ end
23
+
24
+ it 'shows current line' do
25
+ @output.string.must_match /\=> 3:/
26
+ end
27
+ end
28
+
29
+ describe 'multiple step' do
30
+ before do
31
+ @input = InputTester.new('step 2')
32
+ redirect_pry_io(@input, @output) do
33
+ load step_file
34
+ end
35
+ end
36
+
37
+ it 'shows current line' do
38
+ @output.string.must_match /\=> 4:/
39
+ end
40
+ end
41
+ end
42
+
43
+ describe 'Next Command' do
44
+ describe 'single step' do
45
+ before do
46
+ @input = InputTester.new('next')
47
+ redirect_pry_io(@input, @output) do
48
+ load step_file
49
+ end
50
+ end
51
+
52
+ it 'shows current line' do
53
+ @output.string.must_match /\=> 3:/
54
+ end
55
+ end
56
+
57
+ describe 'multiple step' do
58
+ before do
59
+ @input = InputTester.new('next 2')
60
+ redirect_pry_io(@input, @output) do
61
+ load step_file
62
+ end
63
+ end
64
+
65
+ it 'shows current line' do
66
+ @output.string.must_match /\=> 20:/
67
+ end
68
+ end
69
+ end
70
+
5
71
  end
6
72
 
@@ -0,0 +1,25 @@
1
+ binding.pry
2
+
3
+ class SteppingExample
4
+ def a
5
+ z = 2
6
+ b
7
+ end
8
+
9
+ def b
10
+ v2 = 5 if 1 == 2 ; [1,2,3].map { |a| a.to_f }
11
+ c
12
+ end
13
+
14
+ def c
15
+ z = 4
16
+ 5
17
+ end
18
+ end
19
+
20
+ ex = SteppingExample.new.a
21
+ 2.times do
22
+ ex += 1
23
+ end
24
+
25
+ ex
@@ -1,10 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
- class ProcessorTest < Minitest::Test
4
-
5
- def test_new
6
- assert PryByebug::Processor.new
7
- end
8
-
3
+ class ProcessorTest < MiniTest::Spec
4
+
9
5
  end
10
6
 
data/test/pry_ext_test.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
- class PryExtTest < Minitest::Test
4
-
3
+ class PryExtTest < MiniTest::Spec
4
+
5
5
  end
6
6
 
@@ -1,6 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
- class PryRemoteExtTest < Minitest::Test
4
-
3
+ class PryRemoteExtTest < MiniTest::Spec
4
+
5
5
  end
6
6
 
data/test/test_helper.rb CHANGED
@@ -1,5 +1,34 @@
1
- require "rubygems"
2
- require "bundler/setup"
3
- require "minitest/autorun"
4
- require "mocha/setup"
5
- require "pry-byebug"
1
+ require 'pry/test/helper'
2
+ require 'minitest/autorun'
3
+ require 'pry-byebug'
4
+ require 'mocha/setup'
5
+
6
+ # Set I/O streams. Out defaults to an anonymous StringIO.
7
+ def redirect_pry_io(new_in, new_out = StringIO.new)
8
+ old_in = Pry.input
9
+ old_out = Pry.output
10
+
11
+ Pry.input = new_in
12
+ Pry.output = new_out
13
+ begin
14
+ yield
15
+ ensure
16
+ Pry.input = old_in
17
+ Pry.output = old_out
18
+ end
19
+ end
20
+
21
+ class InputTester
22
+ def initialize(*actions)
23
+ @orig_actions = actions.dup
24
+ @actions = actions
25
+ end
26
+
27
+ def readline(*)
28
+ @actions.shift
29
+ end
30
+
31
+ def rewind
32
+ @actions = @orig_actions.dup
33
+ end
34
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pry-byebug
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Rodríguez
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-06 00:00:00.000000000 Z
12
+ date: 2013-07-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pry
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - ~>
33
33
  - !ruby/object:Gem::Version
34
- version: 1.4.0
34
+ version: 1.5.0
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - ~>
40
40
  - !ruby/object:Gem::Version
41
- version: 1.4.0
41
+ version: 1.5.0
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: bundler
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -59,28 +59,14 @@ dependencies:
59
59
  requirements:
60
60
  - - ~>
61
61
  - !ruby/object:Gem::Version
62
- version: 10.0.4
62
+ version: 10.1.0
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - ~>
68
68
  - !ruby/object:Gem::Version
69
- version: 10.0.4
70
- - !ruby/object:Gem::Dependency
71
- name: minitest
72
- requirement: !ruby/object:Gem::Requirement
73
- requirements:
74
- - - ~>
75
- - !ruby/object:Gem::Version
76
- version: 5.0.3
77
- type: :development
78
- prerelease: false
79
- version_requirements: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - ~>
82
- - !ruby/object:Gem::Version
83
- version: 5.0.3
69
+ version: 10.1.0
84
70
  - !ruby/object:Gem::Dependency
85
71
  name: mocha
86
72
  requirement: !ruby/object:Gem::Requirement
@@ -105,6 +91,7 @@ extra_rdoc_files: []
105
91
  files:
106
92
  - .gitignore
107
93
  - .ruby-gemset
94
+ - .travis.yml
108
95
  - CHANGELOG.md
109
96
  - Gemfile
110
97
  - LICENSE
@@ -122,6 +109,7 @@ files:
122
109
  - test/base_test.rb
123
110
  - test/breakpoints_test.rb
124
111
  - test/commands_test.rb
112
+ - test/examples/stepping.rb
125
113
  - test/processor_test.rb
126
114
  - test/pry_ext_test.rb
127
115
  - test/pry_remote_ext_test.rb
@@ -154,8 +142,8 @@ test_files:
154
142
  - test/base_test.rb
155
143
  - test/breakpoints_test.rb
156
144
  - test/commands_test.rb
145
+ - test/examples/stepping.rb
157
146
  - test/processor_test.rb
158
147
  - test/pry_ext_test.rb
159
148
  - test/pry_remote_ext_test.rb
160
149
  - test/test_helper.rb
161
- has_rdoc: