Class: Slipcover::Server

Inherits:
Struct
  • Object
show all
Defined in:
lib/slipcover/server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#keyObject

Returns the value of attribute key

Returns:

  • (Object)

    the current value of key



3
4
5
# File 'lib/slipcover/server.rb', line 3

def key
  @key
end

#pathObject

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



3
4
5
# File 'lib/slipcover/server.rb', line 3

def path
  @path
end

Instance Method Details

#configObject



8
9
10
# File 'lib/slipcover/server.rb', line 8

def config
  @config ||= server_configs[key]
end

#hostObject



23
24
25
# File 'lib/slipcover/server.rb', line 23

def host
  config['host']
end

#passwordObject



36
37
38
# File 'lib/slipcover/server.rb', line 36

def password
  config['couch_password_key'] ? "#{ENV[config['couch_password_key']]}" : ""
end

#portObject



27
28
29
# File 'lib/slipcover/server.rb', line 27

def port
  config['port'] ? ":#{config['port']}" : ''
end

#server_configsObject



4
5
6
# File 'lib/slipcover/server.rb', line 4

def server_configs
  YAML.load(File.read(path))
end

#urlObject



12
13
14
# File 'lib/slipcover/server.rb', line 12

def url
  "#{}#{host}#{port}"
end

#user_infoObject



16
17
18
19
20
21
# File 'lib/slipcover/server.rb', line 16

def 
  info = "" + username
  info << ":#{password}" unless info.empty?
  info << "@" unless info.empty?
  info
end

#usernameObject

We’re interpolating this because Ruby freezes double hash reference strings



32
33
34
# File 'lib/slipcover/server.rb', line 32

def username
  config['couch_username_key'] ? "#{ENV[config['couch_username_key']]}" : ""
end