Class: PryRemote::Server
- Defined in:
- lib/pry-remote.rb,
lib/pry-nav/pry_remote_ext.rb
Instance Attribute Summary collapse
-
#client ⇒ PryServer::Client
readonly
Client connecting to the pry-remote server.
-
#host ⇒ String
readonly
Host of the server.
-
#object ⇒ Object
readonly
Object to enter into.
-
#port ⇒ Integer
readonly
Port of the server.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(object, host = DefaultHost, port = DefaultPort, options = {}) ⇒ Server
constructor
A new instance of Server.
-
#run ⇒ Object
Override the call to Pry.start to save off current Server, pass a pry_remote flag so pry-nav knows this is a remote session, and not kill the server right away.
-
#setup ⇒ Object
Code that has to be called for Pry-remote to work properly.
- #teardown_with_pry_nav ⇒ Object (also: #teardown)
-
#uri ⇒ String
URI for DRb.
Constructor Details
#initialize(object, host = DefaultHost, port = DefaultPort, options = {}) ⇒ Server
Returns a new instance of Server.
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/pry-remote.rb', line 140 def initialize(object, host = DefaultHost, port = DefaultPort, = {}) @host = host @port = port @object = object @options = @client = PryRemote::Client.new DRb.start_service uri, @client puts "[pry-remote] Waiting for client on #{uri}" @client.wait puts "[pry-remote] Client received, starting remote session" end |
Instance Attribute Details
#client ⇒ PryServer::Client (readonly)
Returns Client connecting to the pry-remote server.
217 218 219 |
# File 'lib/pry-remote.rb', line 217 def client @client end |
#host ⇒ String (readonly)
Returns Host of the server.
220 221 222 |
# File 'lib/pry-remote.rb', line 220 def host @host end |
#object ⇒ Object (readonly)
Returns Object to enter into.
214 215 216 |
# File 'lib/pry-remote.rb', line 214 def object @object end |
#port ⇒ Integer (readonly)
Returns Port of the server.
223 224 225 |
# File 'lib/pry-remote.rb', line 223 def port @port end |
Class Method Details
.run(object, host = DefaultHost, port = DefaultPort, options = {}) ⇒ Object
136 137 138 |
# File 'lib/pry-remote.rb', line 136 def self.run(object, host = DefaultHost, port = DefaultPort, = {}) new(object, host, port, ).run end |
Instance Method Details
#run ⇒ Object
Override the call to Pry.start to save off current Server, pass a pry_remote flag so pry-nav knows this is a remote session, and not kill the server right away
205 206 207 208 209 210 211 |
# File 'lib/pry-remote.rb', line 205 def run setup Pry.start(@object, @options.merge(:input => client.input_proxy, :output => client.output)) ensure teardown end |
#setup ⇒ Object
Code that has to be called for Pry-remote to work properly
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/pry-remote.rb', line 157 def setup # If client passed stdout and stderr, redirect actual messages there. @old_stdout, $stdout = if @client.stdout [$stdout, @client.stdout] else [$stdout, $stdout] end @old_stderr, $stderr = if @client.stderr [$stderr, @client.stderr] else [$stderr, $stderr] end # Before Pry starts, save the pager config. # We want to disable this because the pager won't do anything useful in # this case (it will run on the server). Pry.config.pager, @old_pager = false, Pry.config.pager # As above, but for system config Pry.config.system, @old_system = PryRemote::System, Pry.config.system end |
#teardown_with_pry_nav ⇒ Object Also known as: teardown
27 28 29 30 |
# File 'lib/pry-nav/pry_remote_ext.rb', line 27 def teardown_with_pry_nav teardown_without_pry_nav PryNav.current_remote_server = nil end |
#uri ⇒ String
Returns URI for DRb.
226 227 228 |
# File 'lib/pry-remote.rb', line 226 def uri "druby://#{host}:#{port}" end |