Class: DRb::DRbSSHProtocol

Inherits:
Object
  • Object
show all
Defined in:
lib/drbssh.rb

Class Method Summary collapse

Class Method Details

.open(uri, config) ⇒ Object

Open a client connection to the server at uri, using configuration config, and return it.

Raises:

  • (DRbServerNotFound)


20
21
22
23
24
# File 'lib/drbssh.rb', line 20

def self.open(uri, config)
	raise DRbServerNotFound, "need to run a DRbSSH server first" if @server.nil? or @server.closed?

	DRb.thread['DRbSSHLocalClient'] || DRbSSHRemoteClient.new(uri, @server)
end

.open_server(uri, config) ⇒ Object

Open a server listening at uri, using configuration config, and return it.

Raises:

  • (DRbConnError)


27
28
29
30
31
32
33
# File 'lib/drbssh.rb', line 27

def self.open_server(uri, config)
	@server = nil if !@server.nil? and @server.closed?

	raise DRbConnError, "server already running with different uri" if !@server.nil? and @server.uri != uri

	@server ||= DRbSSHServer.new(uri, config)
end

.serverObject



17
# File 'lib/drbssh.rb', line 17

def self.server; @server; end

.split_uri(uri) ⇒ Object

Split URI into component pairs



43
44
45
46
47
48
49
50
# File 'lib/drbssh.rb', line 43

def self.split_uri(uri)
	if uri.match('^drbssh://([^/?]+)?/?(?:(.+))?$')
		[ $1, $2 ]
	else
		raise DRbBadScheme,uri unless uri =~ /^drbssh:/
		raise DRbBadURI, "can't parse uri: " + uri
	end
end

.uri_option(uri, config) ⇒ Object

Parse uri into a [uri, option] pair.



36
37
38
39
40
# File 'lib/drbssh.rb', line 36

def self.uri_option(uri, config)
	host, path = split_uri(uri)
	host ||= Socket.gethostname
	[ "drbssh://#{host}/#{path}", nil ]
end