pry-byebug 3.1.0 → 3.2.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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +17 -1
  3. data/README.md +7 -6
  4. data/lib/byebug/processors/pry_processor.rb +3 -5
  5. data/lib/pry-byebug.rb +1 -3
  6. data/lib/pry-byebug/cli.rb +1 -2
  7. data/lib/pry-byebug/commands.rb +8 -0
  8. data/lib/pry-byebug/commands/breakpoint.rb +135 -0
  9. data/lib/pry-byebug/commands/continue.rb +37 -0
  10. data/lib/pry-byebug/commands/down.rb +33 -0
  11. data/lib/pry-byebug/commands/finish.rb +26 -0
  12. data/lib/pry-byebug/commands/frame.rb +33 -0
  13. data/lib/pry-byebug/commands/next.rb +37 -0
  14. data/lib/pry-byebug/commands/step.rb +32 -0
  15. data/lib/pry-byebug/commands/up.rb +33 -0
  16. data/lib/pry-byebug/helpers/breakpoints.rb +84 -0
  17. data/lib/pry-byebug/helpers/multiline.rb +21 -0
  18. data/lib/pry-byebug/helpers/navigation.rb +17 -0
  19. data/lib/pry-byebug/version.rb +1 -1
  20. data/lib/pry/byebug/breakpoints.rb +4 -0
  21. metadata +23 -45
  22. data/.gitignore +0 -18
  23. data/.rubocop.yml +0 -14
  24. data/.rubocop_todo.yml +0 -20
  25. data/.travis.yml +0 -9
  26. data/Gemfile +0 -14
  27. data/Rakefile +0 -17
  28. data/lib/pry/commands/breakpoint.rb +0 -216
  29. data/lib/pry/commands/frames.rb +0 -79
  30. data/lib/pry/commands/stepping.rb +0 -88
  31. data/pry-byebug.gemspec +0 -23
  32. data/test/base_test.rb +0 -16
  33. data/test/breakpoints_test.rb +0 -146
  34. data/test/examples/break1.rb +0 -23
  35. data/test/examples/break2.rb +0 -21
  36. data/test/examples/deep_stepping.rb +0 -9
  37. data/test/examples/frames.rb +0 -14
  38. data/test/examples/stepping.rb +0 -29
  39. data/test/frames_test.rb +0 -58
  40. data/test/processor_test.rb +0 -40
  41. data/test/pry_ext_test.rb +0 -4
  42. data/test/pry_remote_ext_test.rb +0 -4
  43. data/test/stepping_test.rb +0 -78
  44. data/test/test_helper.rb +0 -35
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d5b8fdd92c518cf1c6800d1c1d1c481c5c0154f4
4
- data.tar.gz: 92484d0776f36921b38ff4f89f8a3c867c076544
3
+ metadata.gz: 3769aa2736d9bf6a9ebab95ddf421e9ae696f3c9
4
+ data.tar.gz: ac34175906a7f0a79724558cedf23c3e073a77a3
5
5
  SHA512:
6
- metadata.gz: ac47acea5c530840ecaac8e51dffaf0c0d88ff45f78c1aebbd2ffba67e89461cf0cf9ef400cfdfc7b53b6c1e24ebd9405d24eca1ab90ed70dd37034ffd4d2b8b
7
- data.tar.gz: a0f259126736dea8c91727c1a506fc87a4ff94626ae609892cc83e3c68e33eda8ed5767511a027189e8a7c2db4495010f1643f8915b1df95b0c02103ce36f8fe
6
+ metadata.gz: 40e82bbce5bb4a06fda3e35012ebbd5ada29dba254227f52a0d8eeaf5a31f5caa045aae9812925dda5db1e9060752d0110369e875f1df8f834580db9ab48aaad
7
+ data.tar.gz: e1b28d266d1ec106afd76d33325cbe8f1229ee93b7adbdf4cae6faaf7224e0e9cdc7919c97ff6dc7d3ef7695956226349669eb25c397ca79a582207c7f130a3b
@@ -1,8 +1,24 @@
1
+ ## 3.2.0 (2015-07-18)
2
+
3
+ - Improvements:
4
+ * Allow continue to receive a line number argument (#56).
5
+ * Refactorings + RuboCop.
6
+ * Up to date dependencies.
7
+
8
+ - Bugfixes:
9
+ * Don't conflict with `break` and `next` Ruby keywords inside multiline
10
+ statements (#44).
11
+
12
+ - Removals:
13
+ * `breaks` command. It was broken anyways (#47).
14
+
15
+
1
16
  ## 3.1.0 (2015-04-14)
2
17
 
3
18
  - Improvements:
4
19
  * Add frame nav commands up, down and frame.
5
20
 
21
+
6
22
  ## 3.0.1 (2015-04-02)
7
23
 
8
24
  - Improvements:
@@ -77,7 +93,7 @@ level releases.
77
93
 
78
94
 
79
95
  ## 1.1.0 (2013-06-06)
80
-
96
+
81
97
  * Adds a test suite (thanks @teeparham!)
82
98
  * Uses byebug ~> 1.4.0
83
99
  * Uses s, n, f and c aliases by default (thanks @jgakos!)
data/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # pry-byebug
2
2
  [![Version][VersionBadge]][VersionURL]
3
3
  [![Build][TravisBadge]][TravisURL]
4
- [![Inline docs][InchCIBadge]](InchCIURL)
4
+ [![Inline docs][InchCIBadge]][InchCIURL]
5
5
  [![Gittip][GittipBadge]][GittipURL]
6
+ [![Coverage][CoverageBadge]][CoverageURL]
6
7
 
7
8
  _Fast execution control in Pry_
8
9
 
@@ -92,7 +93,7 @@ end
92
93
  ## Breakpoints
93
94
 
94
95
  You can set and adjust breakpoints directly from a Pry session using the
95
- following commands:
96
+ `break` command:
96
97
 
97
98
  **break:** Set a new breakpoint from a line number in the current file, a file
98
99
  and line number, or a method. Pass an optional expression to create a
@@ -112,15 +113,12 @@ break --condition 3 # Remove the condition on breakpoint #3.
112
113
  break --delete 5 # Delete breakpoint #5.
113
114
  break --disable-all # Disable all breakpoints.
114
115
 
115
- breaks # List all breakpoints. (Same as `breakpoints`)
116
+ break # List all breakpoints.
116
117
  break --show 2 # Show details about breakpoint #2.
117
118
  ```
118
119
 
119
120
  Type `break --help` from a Pry session to see all available options.
120
121
 
121
- **breakpoints**: List all defined breakpoints. Pass `-v` or `--verbose` to see
122
- the source code around each breakpoint.
123
-
124
122
 
125
123
  ## Caveats
126
124
 
@@ -141,6 +139,7 @@ Patches and bug reports are welcome.
141
139
  [byebug]: https://github.com/deivid-rodriguez/byebug
142
140
  [pry-debugger]: https://github.com/nixme/pry-debugger
143
141
  [pry-stack_explorer]: https://github.com/pry/pry-stack_explorer
142
+
144
143
  [VersionBadge]: https://badge.fury.io/rb/pry-byebug.svg
145
144
  [VersionURL]: http://badge.fury.io/rb/pry-byebug
146
145
  [TravisBadge]: https://secure.travis-ci.org/deivid-rodriguez/pry-byebug.svg
@@ -149,3 +148,5 @@ Patches and bug reports are welcome.
149
148
  [InchCIURL]: http://inch-ci.org/github/deivid-rodriguez/pry-byebug
150
149
  [GittipBadge]: http://img.shields.io/gittip/deivid-rodriguez.svg
151
150
  [GittipURL]: https://www.gittip.com/deivid-rodriguez
151
+ [CoverageBadge]: https://img.shields.io/codeclimate/coverage/github/deivid-rodriguez/pry-byebug.svg
152
+ [CoverageURL]: https://codeclimate.com/github/deivid-rodriguez/pry-byebug
@@ -38,9 +38,9 @@ module Byebug
38
38
 
39
39
  return_value = nil
40
40
 
41
- command = catch(:breakout_nav) do # Throws from PryByebug::Commands
41
+ command = catch(:breakout_nav) do # Throws from PryByebug::Commands
42
42
  return_value = yield
43
- {} # Nothing thrown == no navigational command
43
+ {} # Nothing thrown == no navigational command
44
44
  end
45
45
 
46
46
  # Pry instance to resume after stepping
@@ -55,9 +55,7 @@ module Byebug
55
55
  # Set up a number of navigational commands to be performed by Byebug.
56
56
  #
57
57
  def perform(action, options = {})
58
- return unless [
59
- :next, :step, :finish, :up, :down, :frame
60
- ].include?(action)
58
+ return unless %i(next step finish up down frame).include?(action)
61
59
 
62
60
  send("perform_#{action}", options)
63
61
  end
@@ -1,6 +1,4 @@
1
1
  require 'pry'
2
2
  require 'pry-byebug/base'
3
3
  require 'pry-byebug/pry_ext'
4
- require 'pry/commands/stepping'
5
- require 'pry/commands/frames'
6
- require 'pry/commands/breakpoint'
4
+ require 'pry-byebug/commands'
@@ -1,4 +1,3 @@
1
1
  require 'pry-byebug/base'
2
2
  require 'pry-byebug/pry_ext'
3
- require 'pry/commands/stepping'
4
- require 'pry/commands/breakpoint'
3
+ require 'pry-byebug/commands'
@@ -0,0 +1,8 @@
1
+ require 'pry-byebug/commands/next'
2
+ require 'pry-byebug/commands/step'
3
+ require 'pry-byebug/commands/continue'
4
+ require 'pry-byebug/commands/finish'
5
+ require 'pry-byebug/commands/up'
6
+ require 'pry-byebug/commands/down'
7
+ require 'pry-byebug/commands/frame'
8
+ require 'pry-byebug/commands/breakpoint'
@@ -0,0 +1,135 @@
1
+ require 'pry/byebug/breakpoints'
2
+ require 'pry-byebug/helpers/breakpoints'
3
+ require 'pry-byebug/helpers/multiline'
4
+
5
+ module PryByebug
6
+ #
7
+ # Add, show and remove breakpoints
8
+ #
9
+ class BreakCommand < Pry::ClassCommand
10
+ include Helpers::Breakpoints
11
+ include Helpers::Multiline
12
+
13
+ match 'break'
14
+ group 'Byebug'
15
+ description 'Set or edit a breakpoint.'
16
+
17
+ banner <<-BANNER
18
+ Usage: break <METHOD | FILE:LINE | LINE> [if CONDITION]
19
+ break --condition N [CONDITION]
20
+ break [--show | --delete | --enable | --disable] N
21
+ break [--delete-all | --disable-all]
22
+ break
23
+ Aliases: breakpoint
24
+
25
+ Set a breakpoint. Accepts a line number in the current file, a file and
26
+ line number, or a method, and an optional condition.
27
+
28
+ Pass appropriate flags to manipulate existing breakpoints.
29
+
30
+ Examples:
31
+
32
+ break SomeClass#run Break at the start of `SomeClass#run`.
33
+ break Foo#bar if baz? Break at `Foo#bar` only if `baz?`.
34
+ break app/models/user.rb:15 Break at line 15 in user.rb.
35
+ break 14 Break at line 14 in the current file.
36
+
37
+ break --condition 4 x > 2 Add/change condition on breakpoint #4.
38
+ break --condition 3 Remove the condition on breakpoint #3.
39
+
40
+ break --delete 5 Delete breakpoint #5.
41
+ break --disable-all Disable all breakpoints.
42
+
43
+ break --show 2 Show details about breakpoint #2.
44
+ break List all breakpoints.
45
+ BANNER
46
+
47
+ def options(opt)
48
+ defaults = { argument: true, as: Integer }
49
+
50
+ opt.on :c, :condition, 'Change condition of a breakpoint.', defaults
51
+ opt.on :s, :show, 'Show breakpoint details and source.', defaults
52
+ opt.on :D, :delete, 'Delete a breakpoint.', defaults
53
+ opt.on :d, :disable, 'Disable a breakpoint.', defaults
54
+ opt.on :e, :enable, 'Enable a disabled breakpoint.', defaults
55
+ opt.on :'disable-all', 'Disable all breakpoints.'
56
+ opt.on :'delete-all', 'Delete all breakpoints.'
57
+ end
58
+
59
+ def process
60
+ return if check_multiline_context
61
+
62
+ PryByebug.check_file_context(target)
63
+
64
+ option, = opts.to_hash.find { |key, _value| opts.present?(key) }
65
+ return send(option_to_method(option)) if option
66
+
67
+ return new_breakpoint unless args.empty?
68
+
69
+ print_all
70
+ end
71
+
72
+ private
73
+
74
+ %w(delete disable enable disable_all delete_all).each do |command|
75
+ define_method(:"process_#{command}") do
76
+ breakpoints.send(*[command, opts[command]].compact)
77
+ print_all
78
+ end
79
+ end
80
+
81
+ def process_show
82
+ print_full_breakpoint(breakpoints.find_by_id(opts[:show]))
83
+ end
84
+
85
+ def process_condition
86
+ expr = args.empty? ? nil : args.join(' ')
87
+ breakpoints.change(opts[:condition], expr)
88
+ end
89
+
90
+ def new_breakpoint
91
+ place = args.shift
92
+ condition = args.join(' ') if 'if' == args.shift
93
+
94
+ bp = add_breakpoint(place, condition)
95
+
96
+ print_full_breakpoint(bp)
97
+ end
98
+
99
+ def option_to_method(option)
100
+ "process_#{option.to_s.gsub('-', '_')}"
101
+ end
102
+
103
+ def print_all
104
+ print_breakpoints_header
105
+ breakpoints.each { |b| print_short_breakpoint(b) }
106
+ end
107
+
108
+ def add_breakpoint(place, condition)
109
+ case place
110
+ when /^(\d+)$/
111
+ errmsg = 'Line number declaration valid only in a file context.'
112
+ PryByebug.check_file_context(target, errmsg)
113
+
114
+ lineno = Regexp.last_match[1].to_i
115
+ breakpoints.add_file(current_file, lineno, condition)
116
+ when /^(.+):(\d+)$/
117
+ file = Regexp.last_match[1]
118
+ lineno = Regexp.last_match[2].to_i
119
+ breakpoints.add_file(file, lineno, condition)
120
+ when /^(.*)[.#].+$/ # Method or class name
121
+ if Regexp.last_match[1].strip.empty?
122
+ errmsg = 'Method name declaration valid only in a file context.'
123
+ PryByebug.check_file_context(target, errmsg)
124
+ place = target.eval('self.class.to_s') + place
125
+ end
126
+ breakpoints.add_method(place, condition)
127
+ else
128
+ fail(ArgumentError, 'Cannot identify arguments as breakpoint')
129
+ end
130
+ end
131
+ end
132
+ end
133
+
134
+ Pry::Commands.add_command(PryByebug::BreakCommand)
135
+ Pry::Commands.alias_command 'breakpoint', 'break'
@@ -0,0 +1,37 @@
1
+ require 'pry-byebug/helpers/navigation'
2
+ require 'pry-byebug/helpers/breakpoints'
3
+
4
+ module PryByebug
5
+ #
6
+ # Continue program execution until the next breakpoint
7
+ #
8
+ class ContinueCommand < Pry::ClassCommand
9
+ include Helpers::Navigation
10
+ include Helpers::Breakpoints
11
+
12
+ match 'continue'
13
+ group 'Byebug'
14
+ description 'Continue program execution and end the Pry session.'
15
+
16
+ banner <<-BANNER
17
+ Usage: continue [LINE]
18
+
19
+ Continue program execution until the next breakpoint, or the program
20
+ ends. Optionally continue to the specified line number.
21
+
22
+ Examples:
23
+ continue #=> Continue until the next breakpoint.
24
+ continue 4 #=> Continue to line number 4.
25
+ BANNER
26
+
27
+ def process
28
+ PryByebug.check_file_context(target)
29
+
30
+ breakpoints.add_file(current_file, args.first.to_i) if args.first
31
+
32
+ breakout_navigation :continue
33
+ end
34
+ end
35
+ end
36
+
37
+ Pry::Commands.add_command(PryByebug::ContinueCommand)
@@ -0,0 +1,33 @@
1
+ require 'pry-byebug/helpers/navigation'
2
+
3
+ module PryByebug
4
+ #
5
+ # Travel down the frame stack
6
+ #
7
+ class DownCommand < Pry::ClassCommand
8
+ include Helpers::Navigation
9
+
10
+ match 'down'
11
+ group 'Byebug'
12
+
13
+ description 'Move current frame down.'
14
+
15
+ banner <<-BANNER
16
+ Usage: down [TIMES]
17
+
18
+ Move current frame down. By default, moves by 1 frame.
19
+
20
+ Examples:
21
+ down #=> Move down 1 frame.
22
+ down 5 #=> Move down 5 frames.
23
+ BANNER
24
+
25
+ def process
26
+ PryByebug.check_file_context(target)
27
+
28
+ breakout_navigation :down, times: args.first
29
+ end
30
+ end
31
+ end
32
+
33
+ Pry::Commands.add_command(PryByebug::DownCommand)
@@ -0,0 +1,26 @@
1
+ require 'pry-byebug/helpers/navigation'
2
+
3
+ module PryByebug
4
+ #
5
+ # Run until the end of current frame
6
+ #
7
+ class FinishCommand < Pry::ClassCommand
8
+ include PryByebug::Helpers::Navigation
9
+
10
+ match 'finish'
11
+ group 'Byebug'
12
+ description 'Execute until current stack frame returns.'
13
+
14
+ banner <<-BANNER
15
+ Usage: finish
16
+ BANNER
17
+
18
+ def process
19
+ PryByebug.check_file_context(target)
20
+
21
+ breakout_navigation :finish
22
+ end
23
+ end
24
+ end
25
+
26
+ Pry::Commands.add_command(PryByebug::FinishCommand)
@@ -0,0 +1,33 @@
1
+ require 'pry-byebug/helpers/navigation'
2
+
3
+ module PryByebug
4
+ #
5
+ # Move to a specific frame in the callstack
6
+ #
7
+ class FrameCommand < Pry::ClassCommand
8
+ include Helpers::Navigation
9
+
10
+ match 'frame'
11
+ group 'Byebug'
12
+
13
+ description 'Move to specified frame #.'
14
+
15
+ banner <<-BANNER
16
+ Usage: frame [TIMES]
17
+
18
+ Move to specified frame #.
19
+
20
+ Examples:
21
+ frame #=> Show current frame #.
22
+ frame 5 #=> Move to frame 5.
23
+ BANNER
24
+
25
+ def process
26
+ PryByebug.check_file_context(target)
27
+
28
+ breakout_navigation :frame, index: args.first
29
+ end
30
+ end
31
+ end
32
+
33
+ Pry::Commands.add_command(PryByebug::FrameCommand)
@@ -0,0 +1,37 @@
1
+ require 'pry-byebug/helpers/navigation'
2
+ require 'pry-byebug/helpers/multiline'
3
+
4
+ module PryByebug
5
+ #
6
+ # Run a number of lines and then stop again
7
+ #
8
+ class NextCommand < Pry::ClassCommand
9
+ include Helpers::Navigation
10
+ include Helpers::Multiline
11
+
12
+ match 'next'
13
+ group 'Byebug'
14
+ description 'Execute the next line within the current stack frame.'
15
+
16
+ banner <<-BANNER
17
+ Usage: next [LINES]
18
+
19
+ Step over within the same frame. By default, moves forward a single
20
+ line.
21
+
22
+ Examples:
23
+ next #=> Move a single line forward.
24
+ next 4 #=> Execute the next 4 lines.
25
+ BANNER
26
+
27
+ def process
28
+ return if check_multiline_context
29
+
30
+ PryByebug.check_file_context(target)
31
+
32
+ breakout_navigation :next, lines: args.first
33
+ end
34
+ end
35
+ end
36
+
37
+ Pry::Commands.add_command(PryByebug::NextCommand)