pry-shell 0.4.0 → 0.5.1

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: 68f90c4cdfe746f83fe8d18649b1141a901b5ba38d1a200b74556c066dd6fa6f
4
- data.tar.gz: a1849f725f15e7f639968d7145c5a48efb72b351118e745b3e804c0b0d37062d
3
+ metadata.gz: 3c2ada13df84d73e1825a12b3b6f1d48323a1ee26b259d0d621954f992b5bcba
4
+ data.tar.gz: '07290249ca6c84a110288199d5c467cb01a239066ec6ca219cac2ad6abdcda1e'
5
5
  SHA512:
6
- metadata.gz: 9e7468ba04ac804e48428f95cf9ac1ffc6301dfef9c28d1b76d83d1e9816b2159f39a512c18a139f1aba8b79ae48929cb7b14d4daf65143e5a87f645e80b1889
7
- data.tar.gz: 2f96b7544443dc1f2699d6e6da2e8165243e3d5617bbcc27493fe3d5da9d65c9d86a840f000c3aa2ef277e904aab6b0eba595e11a34f7b5396ad8e712640ccd2
6
+ metadata.gz: dfd6b5a61516dd27da717291944e550b8e6e15def4cd59ee21bd479f069f059c8d5e57047414fd6d36c51b81c8bcd691b39d8f2dc02fc595121381b6f7ad3349
7
+ data.tar.gz: 342f64a819c36580b331caf9bc67cc4407bace3531fb173c3d34f4bdfc25dab7a21cd9e8cb9803d91181a1db35652e5e48cabcb4a47c5cf74644ed39f6fbc65e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pry-shell (0.4.0)
4
+ pry-shell (0.5.1)
5
5
  pry (~> 0.13.0)
6
6
  tty-markdown
7
7
  tty-prompt
@@ -13,7 +13,7 @@ GEM
13
13
  byebug (11.1.3)
14
14
  coderay (1.1.3)
15
15
  diff-lcs (1.4.4)
16
- kramdown (2.3.1)
16
+ kramdown (2.4.0)
17
17
  rexml
18
18
  method_source (1.0.0)
19
19
  parallel (1.20.1)
@@ -31,7 +31,7 @@ GEM
31
31
  rake (13.0.3)
32
32
  regexp_parser (2.1.1)
33
33
  rexml (3.2.5)
34
- rouge (3.26.0)
34
+ rouge (3.29.0)
35
35
  rspec (3.10.0)
36
36
  rspec-core (~> 3.10.0)
37
37
  rspec-expectations (~> 3.10.0)
@@ -94,4 +94,4 @@ DEPENDENCIES
94
94
  rubocop (~> 1.7)
95
95
 
96
96
  BUNDLED WITH
97
- 2.2.16
97
+ 2.3.15
data/README.md CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
3
  Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/pry/shell`. To experiment with that code, run `bin/console` for an interactive prompt.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
5
  ## Installation
8
6
 
9
7
  Add this line to your application's Gemfile:
@@ -22,7 +20,29 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
23
+ Here's a [video showing how to use pry-shell](https://www.youtube.com/watch?v=Lzs_PL_BySo).
24
+
25
+ ### Start the shell
26
+
27
+ $ pry-shell
28
+
29
+ ### Add breakpoints
30
+
31
+ Include this snippet in the code line you are interested:
32
+
33
+ ```ruby
34
+ binding.pry_shell
35
+ ```
36
+
37
+ PryShell will enable [Byebug](https://github.com/deivid-rodriguez/byebug) by default if the `pry-byebug` gem has already been installed. In case if you want to disable byebug, you can set the `with_byebug` option as false, like so;
38
+
39
+ ```ruby
40
+ binding.pry_shell(with_byebug: false)
41
+ ```
42
+
43
+ ### Get access to the Pry session
44
+
45
+ Start the shell, add a breakpoint and make your program hit the desired code section. Afterwards, choose "Available sessions" from the shell main menu and hit "Enter". Then select your desired pry session and hit "Enter".
26
46
 
27
47
  ## Development
28
48
 
data/bin/console CHANGED
@@ -12,7 +12,7 @@ require "pry/shell"
12
12
  # Pry.start
13
13
 
14
14
  def foo1
15
- binding.pry_shell(with_byebug: true)
15
+ binding.pry_shell
16
16
 
17
17
  foo2
18
18
  end
data/lib/pry/shell/cli.rb CHANGED
@@ -29,8 +29,8 @@ class Pry
29
29
  Shell.configuration.port = arg
30
30
  end
31
31
 
32
- o.on "-a", "--auto-connect", "Connect automatically to the first Pry session" do
33
- Shell.configuration.auto_connect = true
32
+ o.on "--disable-auto-connect", "Disable auto connect feature" do
33
+ Shell.configuration.auto_connect = false
34
34
  end
35
35
 
36
36
  o.on "-v", "--version", "Print version and exit" do
@@ -6,7 +6,7 @@ class Pry
6
6
  CONFIG_KEYS = {
7
7
  host: "localhost",
8
8
  port: "1881",
9
- auto_connect: false
9
+ auto_connect: true
10
10
  }.freeze
11
11
 
12
12
  CONFIG_KEYS.each do |config_key, default_value|
@@ -7,11 +7,21 @@ class Pry
7
7
  module IO
8
8
  class Input < Base
9
9
  def readline(prompt)
10
+ drb_thread
11
+
10
12
  wait_until_current
11
13
 
12
14
  string = object.readline(prompt, true)
13
15
 
14
16
  Command.execute(client, string)
17
+ rescue
18
+ drb_thread.kill
19
+
20
+ nil
21
+ end
22
+
23
+ def drb_thread
24
+ @drb_thread ||= Thread.current
15
25
  end
16
26
 
17
27
  # Assigns the `completion_proc` given by the
@@ -4,7 +4,7 @@ class Pry
4
4
  class Shell
5
5
  module Patches
6
6
  module Object
7
- def pry_shell(host: DEFAULT_HOST, port: DEFAULT_PORT, with_byebug: false)
7
+ def pry_shell(host: DEFAULT_HOST, port: DEFAULT_PORT, with_byebug: true)
8
8
  Session.run(self, host: host, port: port, with_byebug: with_byebug)
9
9
  end
10
10
  end
@@ -58,18 +58,30 @@ begin
58
58
  end
59
59
 
60
60
  def start_with_pry_shell(target)
61
- if Shell.active_shell_options[:with_byebug]
61
+ if Shell.active_shell_options[:enable_byebug?]
62
62
  ::Byebug::PryShellProcessor.start
63
63
  else
64
64
  start_without_pry_byebug(target, Shell.active_shell_options)
65
65
  end
66
66
  end
67
67
  end
68
+
69
+ module PryProcessor
70
+ def start
71
+ super
72
+
73
+ # We should step out one more frame as we are
74
+ # prepending another module to the hierarchy
75
+ ::Byebug.current_context.step_out(5, true)
76
+ end
77
+ end
68
78
  end
69
79
  end
70
80
  end
71
81
 
72
82
  Pry.singleton_class.prepend(Pry::Shell::Patches::PryByebug)
73
83
  Pry.singleton_class.alias_method(:start, :start_with_pry_byebug)
84
+
85
+ Byebug::PryProcessor.singleton_class.prepend(Pry::Shell::Patches::PryProcessor)
74
86
  rescue LoadError # rubocop:disable Lint/SuppressedException
75
87
  end
@@ -44,11 +44,12 @@ class Pry
44
44
  end
45
45
 
46
46
  def remove(client)
47
- @current = nil
48
-
49
47
  @clients.delete(client.id)
50
48
 
51
- UI.restart!
49
+ if client.current?
50
+ @current = nil
51
+ UI.restart!
52
+ end
52
53
  end
53
54
  end
54
55
  end
@@ -37,7 +37,11 @@ class Pry
37
37
  # to setup the Byebug.
38
38
  # We are clearing this options in `PryShellProcessor` to ensure
39
39
  # they do not leak.
40
- Shell.clear_shell_options! unless with_byebug
40
+ unless enable_byebug?
41
+ pry_options[:remove_connection].call
42
+
43
+ Shell.clear_shell_options!
44
+ end
41
45
  end
42
46
 
43
47
  private
@@ -47,7 +51,7 @@ class Pry
47
51
  def pry_options
48
52
  {
49
53
  remove_connection: -> { registry.remove(client) },
50
- with_byebug: with_byebug,
54
+ enable_byebug?: enable_byebug?,
51
55
  driver: Pry::Shell::Repl,
52
56
  pager: false,
53
57
  input: client.input,
@@ -57,6 +61,12 @@ class Pry
57
61
  }
58
62
  end
59
63
 
64
+ # Setting the `with_byebug` option as `true` is not enough as the
65
+ # `pry-byebug` gem can be missing which we are currently depending on.
66
+ def enable_byebug?
67
+ with_byebug && defined?(::Byebug::PryShellProcessor)
68
+ end
69
+
60
70
  def client
61
71
  @client ||= registry.register(id: id, **attributes)
62
72
  end
@@ -20,6 +20,15 @@ class Pry
20
20
 
21
21
  class << self
22
22
  def draw_content
23
+ prompt.on(:keypress) do |event|
24
+ if event.value == "j"
25
+ prompt.trigger(:keydown)
26
+ end
27
+
28
+ if event.value == "k"
29
+ prompt.trigger(:keyup)
30
+ end
31
+ end
23
32
  selection = prompt.select("Select a menu item", ITEMS)
24
33
 
25
34
  switch_to(selection)
@@ -2,6 +2,6 @@
2
2
 
3
3
  class Pry
4
4
  class Shell
5
- VERSION = "0.4.0"
5
+ VERSION = "0.5.1"
6
6
  end
7
7
  end
data/lib/pry-shell.rb ADDED
@@ -0,0 +1 @@
1
+ require 'pry/shell'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pry-shell
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mehmet Emin INAC
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-16 00:00:00.000000000 Z
11
+ date: 2022-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -71,6 +71,7 @@ files:
71
71
  - bin/console
72
72
  - bin/setup
73
73
  - exe/pry-shell
74
+ - lib/pry-shell.rb
74
75
  - lib/pry/shell.rb
75
76
  - lib/pry/shell/cli.rb
76
77
  - lib/pry/shell/client.rb
@@ -121,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
122
  - !ruby/object:Gem::Version
122
123
  version: '0'
123
124
  requirements: []
124
- rubygems_version: 3.0.8
125
+ rubygems_version: 3.1.6
125
126
  signing_key:
126
127
  specification_version: 4
127
128
  summary: Provides remote pry sessions.