Class: Capricorn::Client
- Inherits:
-
Object
- Object
- Capricorn::Client
- Defined in:
- lib/capricorn/client.rb,
lib/capricorn/client/auth_token.rb
Defined Under Namespace
Classes: AuthToken
Class Method Summary collapse
-
.connect(token = nil) ⇒ Object
connect to the server referenced by the given token.
-
.current(token = nil) ⇒ Object
return an potentialy initialize the client to the given token.
-
.parse_uri(uri) ⇒ Object
return a DRb uri for the given Capricorn uri.
Class Method Details
.connect(token = nil) ⇒ Object
connect to the server referenced by the given token.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/capricorn/client.rb', line 25 def self.connect(token=nil) token ||= 'core.token' [Capricorn::DEFAULT_ROOT_SYSTEM_DIR, Capricorn::DEFAULT_USER_SYSTEM_DIR, File.join(Capricorn::DEFAULT_USER_SYSTEM_DIR, 'tokens'), '.'].each do |path| path = File.(File.join(path, token)) if File.file? path token = path break end end unless File.file? token raise "Unable to read the token at: #{token}" end token = Capricorn::Client::AuthToken.load_file(token) if String === token token.connect if token end |
.current(token = nil) ⇒ Object
return an potentialy initialize the client to the given token.
19 20 21 22 |
# File 'lib/capricorn/client.rb', line 19 def self.current(token=nil) @client = connect(token) unless @client @client end |
.parse_uri(uri) ⇒ Object
return a DRb uri for the given Capricorn uri.
11 12 13 14 15 16 |
# File 'lib/capricorn/client.rb', line 11 def self.parse_uri(uri) uri = URI.parse(uri) use_ssl = (uri.scheme == 'ssl+capricorn') uri.scheme = 'druby' return use_ssl, uri.to_s end |