break 0.20.0 → 0.40.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8847ce453f4b00d664fec2f77e2f553f1a25d95847fad8e44aeb849bcc696dd6
4
- data.tar.gz: 3d0f52bba812f6dac645936822721ad60246ad79c379f1475154d9c53c45cbc2
3
+ metadata.gz: fdf6c48bd31f4c1f5429be6e033e16c6a4b8f00338f4b7e06b0b4dfa667bb8fd
4
+ data.tar.gz: 251bf10ffd1cf68afcd65563b0217c92fb19993eb97c0a7d27c5b17bdc9aba43
5
5
  SHA512:
6
- metadata.gz: f52722f40b4ce06b009bfa2a18dd53c547c3e93d4735bd53dcc38318fbcac65449f87a4672f0dbff6f25473a41f2ff5a81e27e99b60872a5ca2b365da49c1f0d
7
- data.tar.gz: e3fe4853aa0c51e7d33368b176e101ffaaaa9309dcf3c23577720e71877278636f98476dc974e7b321c75fa62355b4ad303ba1d5cf9c53dc02c3baca5d2cffdf
6
+ metadata.gz: f3b7249a8df78892931d60a88198b577185bce8937500c0e90d77104489e915b78bfc9650eb961394c478e60c62643adb496f9106557cac2f751a152ef818de5
7
+ data.tar.gz: 28fad7cbe70a6eb09094761cc776889b9243cb694f04c422d2abe946d8e575ace9dae0edea1635648f6904328423eed103058ae0224340d0fe6ac97f97e9d6b7
data/CHANGELOG.md ADDED
@@ -0,0 +1,35 @@
1
+ # Changelog
2
+
3
+ ## 0.40.0 (2022-05-06)
4
+ ### Changed
5
+ - Remote integration (`pry-remote`) needs to be manually activated by requiring `break/remote` ([@gsamokovarov][])
6
+
7
+ ## 0.30.0 (2021-06-20)
8
+ ### Added
9
+ - Officially Ruby 3.0 support. ([@gsamokovarov][])
10
+ ### Fixed
11
+ - Fix broken `next` command for Ruby 2.7+. ([@gsamokovarov][])
12
+ - Fix circular require for `pry` integrations. ([@gsamokovarov][])
13
+
14
+ ## 0.21.0 (2020-08-19)
15
+ ### Fixed
16
+ - Fix broken `pry` commands like `ls`. ([@jamesfischer8][])
17
+
18
+ ## 0.20.0 (2020-07-30)
19
+ ### Added
20
+ - Support for `pry-remote`. ([@gsamokovarov][])
21
+ ### Fixed
22
+ - Fix `up` and `down` commands in `pry`. ([@gsamokovarov][])
23
+
24
+ ## 0.12.0 (2020-07-17)
25
+ ### Added
26
+ - Support for `pry` version `0.13` and above. ([@gsamokovarov][])
27
+ ### Fixed
28
+ - Fix a crash in multi-threaded environments. ([@gsamokovarov][])
29
+
30
+ ## 0.11.0 (2020-02-08)
31
+ ### Changed
32
+ - Requiring `pry` before `break` is no longer a prerequisite for automatic Pry integration. ([@gsamokovarov][])
33
+
34
+ [@gsamokovarov]: https://github.com/gsamokovarov
35
+ [@jamesfischer8]: https://github.com/jamesfischer8
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Genadi Samokovarov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,93 @@
1
+ # Break
2
+
3
+ Break is a lightweight debugger for Ruby. It's written in plain Ruby and
4
+ doesn't have its own frontend. Once you put `gem "break"` in your `Gemfile`, it
5
+ integrates seamlessly with IRB or [Pry]. You have navigational commands like
6
+ `next` and `step` straight in your REPL session. You don't need to remember to
7
+ start your debugger or change your development flow. Break embraces your flow,
8
+ instead of forcing you to abide to yet another tool.
9
+
10
+ ## Features
11
+
12
+ - Control flow executing control.
13
+ - No runtime cost. The tracing instructions kick in only when navigating.
14
+ - Automatic integration with IRB and [Pry].
15
+ - Rails 6 constant auto loading support (not available in other Ruby debuggers).
16
+
17
+ ## Installation
18
+
19
+ Put `gem "break"` in your `Gemfile`. Then run `bundle install` and
20
+ `binding.irb` (or `binding.pry`) to your heart's desire.
21
+
22
+ ## Commands
23
+
24
+ The following commands are available in both IRB and [Pry].
25
+
26
+ Command | Description
27
+ ---------- | -----------
28
+ `next` | Continue to next line.
29
+ `step` | Step into method invocation.
30
+ `up` | Go up the stack.
31
+ `down` | Go down the stack.
32
+ `whereami` | Show the code surrounding the current debugged line.
33
+ `exit` | Disconnect the debugger and continue to run the program.
34
+
35
+ ## Usage
36
+
37
+ Add `break` in your application `Gemfile` and make sure to `require "break"`
38
+ early in your program setup. In a Rails application, `break` will be required
39
+ automatically and you don't need to worry about that.
40
+
41
+ ```ruby
42
+ gem "break"
43
+ ```
44
+
45
+ Break automatically injects its commands into `binding.irb` and `binding.pry`
46
+ (if available).
47
+
48
+ If you need to debug your program, type a `next` to go to the next line of
49
+ program execution or `step` to step into a method, block, or class/module
50
+ opening call. All of this, in the comfort of IRB or [Pry]. Simple!
51
+
52
+ ## Remote usage
53
+
54
+ Break can integrate with `pry-remote` for remote process debugging. You have to
55
+ require `break/remote` for Break's integration to kick in.
56
+
57
+ You can declare `break` in your `Gemfile` with a custom `require` to get the
58
+ remote integration loaded automatically by Bundler:
59
+
60
+ ```ruby
61
+ gem "break", require: "break/remote"
62
+ ```
63
+
64
+ ## Why we need a debugger in Ruby?
65
+
66
+ We had our fair share of abandoned Ruby debuggers written in C. During Ruby 1.8
67
+ and Ruby 1.9 days, the interpreter itself changed often and didn't provide a
68
+ stable API to aid the writing of development tools. This means that
69
+ [ruby-debug], a debugger written for Ruby 1.8 had to be rewritten for 1.9 (as a
70
+ different gem: [ruby-debug-base19]) and then again for Ruby 2.0. At this point
71
+ the development was halted as maintaining 3 different implementations is hard.
72
+
73
+ If we get better APIs in Ruby-land we won't run into the problems [ruby-debug]
74
+ did. Even better, the debuggers can be thin layers on top of the heavy-lifting
75
+ debugging instrumentation APIs that live in the interpreter themselves. This
76
+ way the interpreter internals can change as much as they want but if they
77
+ provide the same APIs, all of the debugging tools will still work. On top of
78
+ that, our debuggers will work on JRuby, TruffleRuby or whatever alternative
79
+ Ruby implementation is under active development at the time.
80
+
81
+ Break exists to implement a functional debugger in pure Ruby using the
82
+ [TracePoint API]. It also wants to serve as a catalyst for other Ruby-land
83
+ available APIs that are useful for implementing debugging tools.
84
+
85
+ Learn more from this [Ruby Russia talk]. ⚡️
86
+
87
+ [TracePoint API]: https://ruby-doc.org/core-2.6.2/TracePoint.html
88
+ [Pry]: https://github.com/pry/pry
89
+
90
+ [ruby-debug]: https://github.com/ruby-debug/ruby-debug
91
+ [ruby-debug-base19]: https://github.com/ruby-debug/ruby-debug-base19
92
+
93
+ [Ruby Russia talk]: https://www.youtube.com/watch?v=3QADeUVwJtA
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require "rake/testtask"
2
+
3
+ Bundler::GemHelper.install_tasks name: ENV.fetch("GEM_NAME", "break")
4
+
5
+ Rake::TestTask.new(:test) do |t|
6
+ t.libs << "test"
7
+ t.libs << "lib"
8
+ t.test_files = FileList["test/**/*_test.rb"]
9
+ end
10
+
11
+ task default: :test
@@ -10,13 +10,7 @@ module Break::IRB
10
10
 
11
11
  def attach(session)
12
12
  @workspace = IRB::WorkSpace.new(session.context.binding)
13
-
14
- begin
15
- @irb = IRB::Irb.new(@workspace)
16
- @irb.context.main.extend Commands.new(session)
17
- rescue TypeError
18
- return
19
- end
13
+ @irb = safely_build_irb_instance(session, @workspace)
20
14
 
21
15
  where
22
16
 
@@ -50,5 +44,24 @@ module Break::IRB
50
44
 
51
45
  irb_context
52
46
  end
47
+
48
+ # Trying to instantiate an `IRB:Irb` object with a workspace having a
49
+ # binding coming from `BasicObject`.
50
+ def safely_build_irb_instance(session, workspace)
51
+ irb = IRB::Irb.allocate
52
+ irb.instance_variable_set :@context, IRB::Context.new(irb, workspace, nil)
53
+ irb.instance_variable_set :@signal_status, :IN_IRB
54
+ irb.instance_variable_set :@scanner, RubyLex.new
55
+
56
+ begin
57
+ irb.context.main.extend IRB::ExtendCommandBundle
58
+ rescue NameError, TypeError
59
+ # Potential `NameError`: undefined method `irb_print_working_workspace' for class `#<Class:#420>'.
60
+ # Ignore it.
61
+ end
62
+
63
+ irb.context.main.extend Commands.new(session)
64
+ irb
65
+ end
53
66
  end
54
67
  end
@@ -4,7 +4,7 @@ module Break::Pry
4
4
  module PryExtensions
5
5
  attr_accessor :__break_session__
6
6
 
7
- def initialize(options)
7
+ def initialize(options = {})
8
8
  super(options)
9
9
 
10
10
  @__break_session__ = options[:__break_session__]
@@ -13,40 +13,3 @@ module Break::Pry
13
13
  end
14
14
 
15
15
  Pry.prepend Break::Pry::PryExtensions
16
-
17
- begin
18
- require "pry-remote"
19
-
20
- module Break::Pry
21
- class << self
22
- attr_accessor :current_remote_server
23
- end
24
-
25
- module PryRemoteServerExtensions
26
- def initialize(*)
27
- Break::Pry.current_remote_server&.teardown
28
-
29
- super
30
- end
31
-
32
- def run
33
- return if Break::Pry.current_remote_server
34
- Break::Pry.current_remote_server = self
35
-
36
- setup
37
-
38
- Pry.start @object, @options.merge(input: client.input_proxy, output: client.output)
39
- end
40
-
41
- def teardown
42
- super
43
- ensure
44
- Break::Pry.current_remote_server = nil
45
- end
46
- end
47
- end
48
-
49
- PryRemote::Server.prepend Break::Pry::PryRemoteServerExtensions
50
- rescue LoadError
51
- # Do nothing if we cannot require pry-remote.
52
- end
@@ -0,0 +1,43 @@
1
+ begin
2
+ require "pry-remote"
3
+
4
+ module Break::Pry
5
+ class << self
6
+ attr_accessor :current_remote_server
7
+ end
8
+
9
+ module PryRemoteServerExtensions
10
+ def initialize(*)
11
+ Break::Pry.current_remote_server&.teardown
12
+
13
+ super
14
+ end
15
+
16
+ def run
17
+ return if Break::Pry.current_remote_server
18
+ Break::Pry.current_remote_server = self
19
+
20
+ setup
21
+
22
+ Pry.start @object, @options.merge(input: client.input_proxy, output: client.output)
23
+ end
24
+
25
+ def teardown
26
+ super
27
+ ensure
28
+ Break::Pry.current_remote_server = nil
29
+ end
30
+ end
31
+ end
32
+
33
+ PryRemote::Server.prepend Break::Pry::PryRemoteServerExtensions
34
+
35
+ Break::Filter.register_internal binding.method(:remote_pry).source_location.first.chomp('.rb')
36
+ Break::Filter.register_internal DRb.method(:start_service).source_location.first.chomp('/drb.rb')
37
+
38
+ at_exit do
39
+ Break::Pry.current_remote_server&.teardown
40
+ end
41
+ rescue LoadError
42
+ # Do nothing if we cannot require pry-remote.
43
+ end
data/lib/break/pry.rb CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  begin
4
4
  require "pry"
5
- require "break"
6
5
 
7
6
  require_relative "pry/frontend"
8
7
  require_relative "pry/commands"
@@ -20,19 +19,6 @@ begin
20
19
  end
21
20
 
22
21
  Pry.config.commands.import Break::Pry::Commands
23
-
24
- begin
25
- require "pry-remote"
26
-
27
- Break::Filter.register_internal binding.method(:remote_pry).source_location.first.chomp('.rb')
28
- Break::Filter.register_internal DRb.method(:start_service).source_location.first.chomp('/drb.rb')
29
-
30
- at_exit do
31
- Break::Pry.current_remote_server&.teardown
32
- end
33
- rescue LoadError
34
- # Do nothing if we cannot require pry-remote.
35
- end
36
22
  rescue LoadError
37
23
  # Do nothing if we cannot require pry.
38
24
  end
@@ -0,0 +1,2 @@
1
+ require "break"
2
+ require_relative "pry/remote"
data/lib/break/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Break
4
- VERSION = "0.20.0"
4
+ VERSION = "0.40.0"
5
5
  end
data/lib/break.rb CHANGED
@@ -12,3 +12,4 @@ require_relative "break/irb"
12
12
  require_relative "break/pry"
13
13
 
14
14
  Break::Filter.register_internal __dir__
15
+ Break::Filter.register_internal "<internal:"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: break
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.0
4
+ version: 0.40.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genadi Samokovarov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-29 00:00:00.000000000 Z
11
+ date: 2022-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -60,6 +60,10 @@ executables: []
60
60
  extensions: []
61
61
  extra_rdoc_files: []
62
62
  files:
63
+ - CHANGELOG.md
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
63
67
  - lib/break.rb
64
68
  - lib/break/binding_ext.rb
65
69
  - lib/break/command.rb
@@ -80,6 +84,8 @@ files:
80
84
  - lib/break/pry/commands.rb
81
85
  - lib/break/pry/extensions.rb
82
86
  - lib/break/pry/frontend.rb
87
+ - lib/break/pry/remote.rb
88
+ - lib/break/remote.rb
83
89
  - lib/break/session.rb
84
90
  - lib/break/testing.rb
85
91
  - lib/break/version.rb
@@ -102,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
108
  - !ruby/object:Gem::Version
103
109
  version: '0'
104
110
  requirements: []
105
- rubygems_version: 3.0.3
111
+ rubygems_version: 3.1.6
106
112
  signing_key:
107
113
  specification_version: 4
108
114
  summary: Lightweight Ruby debugger