pry-shell 0.2.1 → 0.3.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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/pry/shell.rb +19 -24
- data/lib/pry/shell/cli.rb +4 -12
- data/lib/pry/shell/configuration.rb +23 -0
- data/lib/pry/shell/registry.rb +3 -4
- data/lib/pry/shell/server.rb +9 -15
- data/lib/pry/shell/ui.rb +1 -0
- data/lib/pry/shell/ui/base.rb +1 -7
- data/lib/pry/shell/ui/configuration.rb +29 -0
- data/lib/pry/shell/ui/configuration/auto_connect.rb +32 -0
- data/lib/pry/shell/ui/menu.rb +7 -2
- data/lib/pry/shell/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 339b96b3477c3abfe68e09e2112a2c4d59a533466d2d800174fe1d255530e84f
|
4
|
+
data.tar.gz: 47cede13047e2c16cc427f75fe9333600620a6a7703f259fb8e0c378a77b183e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9e426725066c6653d8a5c14e5ff2df0ecfb56fcfa0368e96ea6ca7b1fccab3ba42be1b07cb67b4e705f26275e59af59c74a52e0fbf74b2bde6aec895fe4cec8
|
7
|
+
data.tar.gz: 46ec623b15d359d3d108c94697a088cb094bf27ae9885be6177f390baad36f5cd09c9be87561002e78ce43f05563c5aeee210bec24fa03cc044628682677f675
|
data/Gemfile.lock
CHANGED
data/lib/pry/shell.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require_relative "shell/version"
|
4
4
|
require_relative "shell/client"
|
5
5
|
require_relative "shell/command"
|
6
|
+
require_relative "shell/configuration"
|
6
7
|
require_relative "shell/logger"
|
7
8
|
require_relative "shell/registry"
|
8
9
|
require_relative "shell/server"
|
@@ -15,6 +16,8 @@ require_relative "shell/io/pager"
|
|
15
16
|
require_relative "shell/ui"
|
16
17
|
require_relative "shell/ui/base"
|
17
18
|
require_relative "shell/ui/about"
|
19
|
+
require_relative "shell/ui/configuration"
|
20
|
+
require_relative "shell/ui/configuration/auto_connect"
|
18
21
|
require_relative "shell/ui/list"
|
19
22
|
require_relative "shell/ui/menu"
|
20
23
|
require_relative "shell/ui/session"
|
@@ -25,12 +28,9 @@ class Pry
|
|
25
28
|
DEFAULT_PORT = "1881"
|
26
29
|
|
27
30
|
class << self
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
@registry = Registry.new(auto_connect)
|
32
|
-
|
33
|
-
new(host, port, registry).run
|
31
|
+
def run
|
32
|
+
run_server
|
33
|
+
draw_ui
|
34
34
|
end
|
35
35
|
|
36
36
|
def active_shell_options(thread: Thread.current)
|
@@ -40,29 +40,24 @@ class Pry
|
|
40
40
|
def active_shell_options=(value)
|
41
41
|
Thread.current[:active_shell_options] = value
|
42
42
|
end
|
43
|
-
end
|
44
43
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
@registry = registry
|
49
|
-
end
|
50
|
-
|
51
|
-
def run
|
52
|
-
run_server
|
53
|
-
draw_ui
|
54
|
-
end
|
44
|
+
def configuration
|
45
|
+
@configuration ||= Configuration.new
|
46
|
+
end
|
55
47
|
|
56
|
-
|
48
|
+
def registry
|
49
|
+
@registry ||= Registry.new
|
50
|
+
end
|
57
51
|
|
58
|
-
|
52
|
+
private
|
59
53
|
|
60
|
-
|
61
|
-
|
62
|
-
|
54
|
+
def run_server
|
55
|
+
Server.run
|
56
|
+
end
|
63
57
|
|
64
|
-
|
65
|
-
|
58
|
+
def draw_ui
|
59
|
+
UI.draw!
|
60
|
+
end
|
66
61
|
end
|
67
62
|
end
|
68
63
|
end
|
data/lib/pry/shell/cli.rb
CHANGED
@@ -10,35 +10,27 @@ class Pry
|
|
10
10
|
def run
|
11
11
|
options.parse!
|
12
12
|
|
13
|
-
Shell.run
|
13
|
+
Shell.run
|
14
14
|
|
15
15
|
join_drb_thread
|
16
16
|
end
|
17
17
|
|
18
18
|
private
|
19
19
|
|
20
|
-
def config
|
21
|
-
@config ||= {
|
22
|
-
host: DEFAULT_HOST,
|
23
|
-
port: DEFAULT_PORT,
|
24
|
-
auto_connect: false
|
25
|
-
}
|
26
|
-
end
|
27
|
-
|
28
20
|
def options # rubocop:disable Metrics/MethodLength
|
29
21
|
@parser = OptionParser.new do |o|
|
30
22
|
o.banner = "Usage: bundle exec pry-shell [options]"
|
31
23
|
|
32
24
|
o.on "-h", "--host HOST", "Host name" do |arg|
|
33
|
-
|
25
|
+
Shell.configuration.host = arg
|
34
26
|
end
|
35
27
|
|
36
28
|
o.on "-p", "--post PORT", "Port of the shell application" do |arg|
|
37
|
-
|
29
|
+
Shell.configuration.port = arg
|
38
30
|
end
|
39
31
|
|
40
32
|
o.on "-a", "--auto-connect", "Connect automatically to the first Pry session" do
|
41
|
-
|
33
|
+
Shell.configuration.auto_connect = true
|
42
34
|
end
|
43
35
|
|
44
36
|
o.on "-v", "--version", "Print version and exit" do
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Pry
|
4
|
+
class Shell
|
5
|
+
class Configuration
|
6
|
+
CONFIG_KEYS = {
|
7
|
+
host: "localhost",
|
8
|
+
port: "1881",
|
9
|
+
auto_connect: false
|
10
|
+
}.freeze
|
11
|
+
|
12
|
+
CONFIG_KEYS.each do |config_key, default_value|
|
13
|
+
attr_writer config_key
|
14
|
+
|
15
|
+
define_method(config_key) do
|
16
|
+
return default_value unless instance_variable_defined?("@#{config_key}")
|
17
|
+
|
18
|
+
instance_variable_get("@#{config_key}")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/pry/shell/registry.rb
CHANGED
@@ -7,10 +7,9 @@ class Pry
|
|
7
7
|
class Registry
|
8
8
|
include DRb::DRbUndumped
|
9
9
|
|
10
|
-
attr_reader :
|
10
|
+
attr_reader :clients, :current, :mutex
|
11
11
|
|
12
|
-
def initialize
|
13
|
-
@auto_connect = auto_connect
|
12
|
+
def initialize
|
14
13
|
@clients = {}
|
15
14
|
@mutex = Mutex.new
|
16
15
|
end
|
@@ -20,7 +19,7 @@ class Pry
|
|
20
19
|
Logger.debug("New client connected - #{client}")
|
21
20
|
|
22
21
|
@clients[id] = client
|
23
|
-
connect_to(client) if auto_connect
|
22
|
+
connect_to(client) if Shell.configuration.auto_connect
|
24
23
|
end
|
25
24
|
end
|
26
25
|
|
data/lib/pry/shell/server.rb
CHANGED
@@ -5,24 +5,18 @@ require "drb"
|
|
5
5
|
class Pry
|
6
6
|
class Shell
|
7
7
|
class Server
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
@registry = registry
|
12
|
-
end
|
13
|
-
|
14
|
-
def run
|
15
|
-
Logger.info("Running Drb server on '#{uri}'")
|
16
|
-
|
17
|
-
DRb.start_service(uri, registry)
|
18
|
-
end
|
8
|
+
class << self
|
9
|
+
def run
|
10
|
+
Logger.info("Running Drb server on '#{uri}'")
|
19
11
|
|
20
|
-
|
12
|
+
DRb.start_service(uri, Shell.registry)
|
13
|
+
end
|
21
14
|
|
22
|
-
|
15
|
+
private
|
23
16
|
|
24
|
-
|
25
|
-
|
17
|
+
def uri
|
18
|
+
"druby://#{Shell.configuration.host}:#{Shell.configuration.port}"
|
19
|
+
end
|
26
20
|
end
|
27
21
|
end
|
28
22
|
end
|
data/lib/pry/shell/ui.rb
CHANGED
data/lib/pry/shell/ui/base.rb
CHANGED
@@ -42,7 +42,7 @@ class Pry
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def draw_footer
|
45
|
-
|
45
|
+
prompt.keypress("Press any key to return to the menu...")
|
46
46
|
end
|
47
47
|
|
48
48
|
def header
|
@@ -60,12 +60,6 @@ class Pry
|
|
60
60
|
def print_markdown(text)
|
61
61
|
puts TTY::Markdown.parse(text)
|
62
62
|
end
|
63
|
-
|
64
|
-
def return_menu_prompt
|
65
|
-
prompt.keypress("Press any key to return to the menu...")
|
66
|
-
|
67
|
-
Menu.draw!
|
68
|
-
end
|
69
63
|
end
|
70
64
|
end
|
71
65
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Pry
|
4
|
+
class Shell
|
5
|
+
class UI
|
6
|
+
class Configuration < Base
|
7
|
+
HEADER = "PRY-SHELL Configuration"
|
8
|
+
ITEMS = [
|
9
|
+
{ name: "Auto-connect", value: "auto_connect" },
|
10
|
+
{ name: "Go back to menu", value: "menu" }
|
11
|
+
].freeze
|
12
|
+
ACTIONS = {
|
13
|
+
"auto_connect" => -> { AutoConnect.draw! & draw! },
|
14
|
+
"menu" => -> {}
|
15
|
+
}.freeze
|
16
|
+
|
17
|
+
class << self
|
18
|
+
def draw_content
|
19
|
+
selection = prompt.select("Select a configuration item to change it's value", ITEMS)
|
20
|
+
|
21
|
+
ACTIONS[selection].call
|
22
|
+
end
|
23
|
+
|
24
|
+
def draw_footer; end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Pry
|
4
|
+
class Shell
|
5
|
+
class UI
|
6
|
+
class Configuration
|
7
|
+
class AutoConnect < Base
|
8
|
+
class << self
|
9
|
+
def draw!
|
10
|
+
Shell.configuration.auto_connect = show_prompt
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def show_prompt
|
16
|
+
prompt.select("Accept connections automatically?", cycle: true) do |config|
|
17
|
+
config.default default_value
|
18
|
+
|
19
|
+
config.choice "yes", true
|
20
|
+
config.choice "no", false
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def default_value
|
25
|
+
Shell.configuration.auto_connect ? "yes" : "no"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/pry/shell/ui/menu.rb
CHANGED
@@ -7,11 +7,13 @@ class Pry
|
|
7
7
|
HEADER = "PRY-SHELL Main Menu"
|
8
8
|
ITEMS = [
|
9
9
|
{ name: "1) Available sessions", value: "list" },
|
10
|
-
{ name: "2)
|
11
|
-
{ name: "3)
|
10
|
+
{ name: "2) Configuration", value: "configuration" },
|
11
|
+
{ name: "3) About pry-shell", value: "about" },
|
12
|
+
{ name: "4) Quit", value: "quit" }
|
12
13
|
].freeze
|
13
14
|
MENU_ACTIONS = {
|
14
15
|
"list" => -> { List.draw! },
|
16
|
+
"configuration" => -> { Configuration.draw! },
|
15
17
|
"about" => -> { About.draw! },
|
16
18
|
"quit" => -> { clear! && exit(0) }
|
17
19
|
}.freeze
|
@@ -23,6 +25,9 @@ class Pry
|
|
23
25
|
switch_to(selection)
|
24
26
|
end
|
25
27
|
|
28
|
+
# Override this to remove "press any key" prompt
|
29
|
+
def draw_footer; end
|
30
|
+
|
26
31
|
def switch_to(selected_ui)
|
27
32
|
MENU_ACTIONS[selected_ui].call
|
28
33
|
end
|
data/lib/pry/shell/version.rb
CHANGED
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
|
+
version: 0.3.0
|
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-
|
11
|
+
date: 2021-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -75,6 +75,7 @@ files:
|
|
75
75
|
- lib/pry/shell/cli.rb
|
76
76
|
- lib/pry/shell/client.rb
|
77
77
|
- lib/pry/shell/command.rb
|
78
|
+
- lib/pry/shell/configuration.rb
|
78
79
|
- lib/pry/shell/io/base.rb
|
79
80
|
- lib/pry/shell/io/editor.rb
|
80
81
|
- lib/pry/shell/io/input.rb
|
@@ -92,6 +93,8 @@ files:
|
|
92
93
|
- lib/pry/shell/ui.rb
|
93
94
|
- lib/pry/shell/ui/about.rb
|
94
95
|
- lib/pry/shell/ui/base.rb
|
96
|
+
- lib/pry/shell/ui/configuration.rb
|
97
|
+
- lib/pry/shell/ui/configuration/auto_connect.rb
|
95
98
|
- lib/pry/shell/ui/list.rb
|
96
99
|
- lib/pry/shell/ui/menu.rb
|
97
100
|
- lib/pry/shell/ui/session.rb
|