Class: Spurious::Server::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/spurious/server/options.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ Options

Returns a new instance of Options.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/spurious/server/options.rb', line 6

def initialize(env)
  @docker_host      = env['DOCKER_HOST'].nil? ? 'localhost' : env['DOCKER_HOST'][/\/\/([0-9a-z\.]+):/,1]
  @docker_port      = env['DOCKER_HOST'].nil? ? nil : env['DOCKER_HOST'][/:([0-9]+)/,1]
  @docker_api       = !env['DOCKER_HOST'].nil?
  @server_port      = env.fetch('SPURIOUS_SERVER_PORT', 4590)
  @server_ip        = env.fetch('SPURIOUS_SERVER_IP', '0.0.0.0')
  @write_timeout    = env.fetch('EXCON_WRITE_TIMEOUT', 30000)
  @read_timeout     = env.fetch('EXCON_READ_TIMEOUT', 30000)
  @cert_path        = env.fetch('DOCKER_CERT_PATH', nil)
  setup_ssl if @cert_path
end

Instance Attribute Details

#cert_pathObject (readonly)

Returns the value of attribute cert_path.



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

def cert_path
  @cert_path
end

#docker_apiObject (readonly)

Returns the value of attribute docker_api.



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

def docker_api
  @docker_api
end

#docker_full_pathObject (readonly)

Returns the value of attribute docker_full_path.



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

def docker_full_path
  @docker_full_path
end

#docker_hostObject (readonly)

Returns the value of attribute docker_host.



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

def docker_host
  @docker_host
end

#docker_portObject (readonly)

Returns the value of attribute docker_port.



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

def docker_port
  @docker_port
end

#read_timeoutObject (readonly)

Returns the value of attribute read_timeout.



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

def read_timeout
  @read_timeout
end

#server_ipObject (readonly)

Returns the value of attribute server_ip.



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

def server_ip
  @server_ip
end

#server_portObject (readonly)

Returns the value of attribute server_port.



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

def server_port
  @server_port
end

#write_timeoutObject (readonly)

Returns the value of attribute write_timeout.



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

def write_timeout
  @write_timeout
end

Instance Method Details

#ssl_docker_hostObject



18
19
20
# File 'lib/spurious/server/options.rb', line 18

def ssl_docker_host
  "https://#{docker_host}:#{docker_port}"
end