Class: Aurora::Server::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/aurora/server/base.rb

Constant Summary collapse

DEFAULTS =

– Constants and Attributes ++

{
  :log_file => '/var/log/aurora.server.log',
  :log_level => Logger::ERROR
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri, options = {}) {|_self, @uri, @logger| ... } ⇒ Base

Starts the server listening on the port specified

Yields:

Yield Parameters:



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/aurora/server/base.rb', line 21

def initialize(uri, options = {})
  # setup options
  @options = DEFAULTS.merge(options)
  @uri = URI.parse(uri)
  @logger = Logger.new(@options[:log_file])
  @logger.level = @options[:log_level]
  
  @logger.info 'Starting Aurora Authentication Server...'
  
  # setup authentication handlers
  @logger.info 'Loading processes...'
  yield self, @uri, @logger
  @logger.info 'done.'
  
  # setup server
  @logger.info 'Starting HTTP Server and setting up HTTP Handler...'
  serv = Aurora::Server::Server.new(@uri.host, @uri.port)
  serv.register('/', Aurora::Server::Handler.new(self))
  @logger.info 'done. Running now.'
  serv.run.join
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



55
56
57
# File 'lib/aurora/server/base.rb', line 55

def method_missing(name, *args, &block)
  add_process(name, block)
end

Instance Attribute Details

#loggerObject

Returns the value of attribute logger.



14
15
16
# File 'lib/aurora/server/base.rb', line 14

def logger
  @logger
end

#optionsObject

Returns the value of attribute options.



14
15
16
# File 'lib/aurora/server/base.rb', line 14

def options
  @options
end

#processesObject

Returns the value of attribute processes.



14
15
16
# File 'lib/aurora/server/base.rb', line 14

def processes
  @processes
end

#uriObject

Returns the value of attribute uri.



14
15
16
# File 'lib/aurora/server/base.rb', line 14

def uri
  @uri
end

Instance Method Details

#authenticate(&block) ⇒ Object



51
52
53
# File 'lib/aurora/server/base.rb', line 51

def authenticate(&block)
  add_process(:authenticate, block)
end

#parse_credentials(body) ⇒ Object

– Instance Methods ++



47
48
49
# File 'lib/aurora/server/base.rb', line 47

def parse_credentials(body)
  ['mtodd', 'test']
end