break 0.12.0 → 0.20.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: 74677fbc2dbffd1d87e55b91d3b49b2cd2956fa32c6906ef8f0324c892b82498
4
- data.tar.gz: 045e95de9db1b7422246d2ddd93f74bd488c6ce51e11ded7975ccec8d6040720
3
+ metadata.gz: 8847ce453f4b00d664fec2f77e2f553f1a25d95847fad8e44aeb849bcc696dd6
4
+ data.tar.gz: 3d0f52bba812f6dac645936822721ad60246ad79c379f1475154d9c53c45cbc2
5
5
  SHA512:
6
- metadata.gz: 4720cd3ea21f160b5dfbbc353b1d4322bc20c5bb1fcc2646f796ca10a2916414ba34f5dbaec4bed436a9ae58b86fbde1de6082c9093d65c396110cf08c1e453d
7
- data.tar.gz: 014d460c176e3499193d11874a5f49769f64b8005812387a602de3065cf15cb9b3b04ad6b6a117d8175e5e7f2912f66a5abc9bc385101cf77e8db9805c7d454e
6
+ metadata.gz: f52722f40b4ce06b009bfa2a18dd53c547c3e93d4735bd53dcc38318fbcac65449f87a4672f0dbff6f25473a41f2ff5a81e27e99b60872a5ca2b365da49c1f0d
7
+ data.tar.gz: e3fe4853aa0c51e7d33368b176e101ffaaaa9309dcf3c23577720e71877278636f98476dc974e7b321c75fa62355b4ad303ba1d5cf9c53dc02c3baca5d2cffdf
@@ -6,6 +6,7 @@ begin
6
6
 
7
7
  require_relative "pry/frontend"
8
8
  require_relative "pry/commands"
9
+ require_relative "pry/extensions"
9
10
 
10
11
  Break::Filter.register_internal MethodSource.method(:source_helper).source_location.first.chomp(".rb")
11
12
  Break::Filter.register_internal CodeRay.method(:scan).source_location.first.chomp(".rb")
@@ -14,7 +15,24 @@ begin
14
15
  Break::Filter.register_internal "(pry)"
15
16
  Break::Filter.register_internal __dir__
16
17
 
18
+ Pry.config.hooks.add_hook :before_session, :start_initial_break_session do |_, _, pry|
19
+ pry.__break_session__ ||= Break::Session.new(pry.current_binding, frontend: Break::Pry::Frontend.new)
20
+ end
21
+
17
22
  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
18
36
  rescue LoadError
19
37
  # Do nothing if we cannot require pry.
20
38
  end
@@ -16,9 +16,10 @@ module Break::Pry
16
16
 
17
17
  def process
18
18
  pry = defined?(pry_instance) ? pry_instance : _pry_
19
- session = Break::Session.new(pry.binding_stack.first, frontend: Frontend.new(pry))
19
+ pry.__break_session__[:pry_instance] = pry
20
20
 
21
- command = Break::NextCommand.new(session)
21
+
22
+ command = Break::NextCommand.new(pry.__break_session__)
22
23
  command.execute
23
24
  end
24
25
  end
@@ -37,9 +38,9 @@ module Break::Pry
37
38
 
38
39
  def process
39
40
  pry = defined?(pry_instance) ? pry_instance : _pry_
40
- session = Break::Session.new(pry.binding_stack.first, frontend: Frontend.new(pry))
41
+ pry.__break_session__[:pry_instance] = pry
41
42
 
42
- command = Break::StepCommand.new(session)
43
+ command = Break::StepCommand.new(pry.__break_session__)
43
44
  command.execute
44
45
  end
45
46
  end
@@ -59,9 +60,9 @@ module Break::Pry
59
60
 
60
61
  def process
61
62
  pry = defined?(pry_instance) ? pry_instance : _pry_
62
- session = Break::Session.new(pry.binding_stack.first, frontend: Frontend.new(pry))
63
+ pry.__break_session__[:pry_instance] = pry
63
64
 
64
- command = Break::UpCommand.new(session)
65
+ command = Break::UpCommand.new(pry.__break_session__)
65
66
  command.execute
66
67
  end
67
68
  end
@@ -81,9 +82,9 @@ module Break::Pry
81
82
 
82
83
  def process
83
84
  pry = defined?(pry_instance) ? pry_instance : _pry_
84
- session = Break::Session.new(pry.binding_stack.first, frontend: Frontend.new(pry))
85
+ pry.__break_session__[:pry_instance] = pry
85
86
 
86
- command = Break::DownCommand.new(session)
87
+ command = Break::DownCommand.new(pry.__break_session__)
87
88
  command.execute
88
89
  end
89
90
  end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Break::Pry
4
+ module PryExtensions
5
+ attr_accessor :__break_session__
6
+
7
+ def initialize(options)
8
+ super(options)
9
+
10
+ @__break_session__ = options[:__break_session__]
11
+ end
12
+ end
13
+ end
14
+
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
@@ -2,12 +2,12 @@
2
2
 
3
3
  module Break::Pry
4
4
  class Frontend
5
- def initialize(pry)
6
- @pry = pry
7
- end
8
-
9
5
  def attach(session)
10
- @pry = Pry.start(session.context.binding)
6
+ previous_pry = session[:pry_instance]
7
+
8
+ @pry = Pry.start session.context.binding, __break_session__: session,
9
+ input: previous_pry.input,
10
+ output: previous_pry.output
11
11
  where
12
12
  end
13
13
 
@@ -8,6 +8,7 @@ module Break
8
8
  def initialize(binding, frontend:)
9
9
  @contexts = [Context.new(binding)]
10
10
  @frontend = frontend
11
+ @metadata = {}
11
12
  end
12
13
 
13
14
  def enter
@@ -26,5 +27,13 @@ module Break
26
27
  contexts << Context.new(*bindings, depth: depth)
27
28
  enter
28
29
  end
30
+
31
+ def [](key)
32
+ @metadata[key]
33
+ end
34
+
35
+ def []=(key, value)
36
+ @metadata[key] = value
37
+ end
29
38
  end
30
39
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Break
4
- VERSION = "0.12.0"
4
+ VERSION = "0.20.0"
5
5
  end
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.12.0
4
+ version: 0.20.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-18 00:00:00.000000000 Z
11
+ date: 2020-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -78,6 +78,7 @@ files:
78
78
  - lib/break/irb/overrides.rb
79
79
  - lib/break/pry.rb
80
80
  - lib/break/pry/commands.rb
81
+ - lib/break/pry/extensions.rb
81
82
  - lib/break/pry/frontend.rb
82
83
  - lib/break/session.rb
83
84
  - lib/break/testing.rb