Class: PryRemote::CLI
Overview
Parses arguments and allows to start the client.
Instance Attribute Summary collapse
-
#capture ⇒ Object
(also: #capture?)
readonly
Returns the value of attribute capture.
-
#host ⇒ String
readonly
Host of the server.
-
#port ⇒ Integer
readonly
Port of the server.
Instance Method Summary collapse
-
#initialize(args = ARGV) ⇒ CLI
constructor
A new instance of CLI.
-
#run(input = Pry.config.input, output = Pry.config.output) ⇒ Object
Connects to the server.
-
#uri ⇒ String
URI for DRb.
Constructor Details
#initialize(args = ARGV) ⇒ CLI
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/pry-remote.rb', line 213 def initialize(args = ARGV) params = Slop.parse args, :help => true do "#$PROGRAM_NAME [OPTIONS]" on :s, :server=, "Host of the server (#{DefaultHost})", :argument => :optional, :default => DefaultHost on :p, :port=, "Port of the server (#{DefaultPort})", :argument => :optional, :as => Integer, :default => DefaultPort on :c, :capture, "Captures $stdout and $stderr from the server (true)", :default => true on :f, "Disables loading of .pryrc and its plugins, requires, and command history " end exit if params.help? @host = params[:server] @port = params[:port] @capture = params[:capture] Pry.initial_session_setup unless params[:f] end |
Instance Attribute Details
#capture ⇒ Object (readonly) Also known as: capture?
Returns the value of attribute capture.
247 248 249 |
# File 'lib/pry-remote.rb', line 247 def capture @capture end |
#host ⇒ String (readonly)
237 238 239 |
# File 'lib/pry-remote.rb', line 237 def host @host end |
#port ⇒ Integer (readonly)
240 241 242 |
# File 'lib/pry-remote.rb', line 240 def port @port end |
Instance Method Details
#run(input = Pry.config.input, output = Pry.config.output) ⇒ Object
Connects to the server
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
# File 'lib/pry-remote.rb', line 254 def run(input = Pry.config.input, output = Pry.config.output) DRb.start_service client = DRbObject.new(nil, uri) input = IOUndumpedProxy.new(input) output = IOUndumpedProxy.new(output) client.input = input client.output = output if capture? client.stdout = $stdout client.stderr = $stderr end client.thread = Thread.current sleep DRb.stop_service end |
#uri ⇒ String
243 244 245 |
# File 'lib/pry-remote.rb', line 243 def uri "druby://#{host}:#{port}" end |