TeensyMud - 'A ruby mud server.'

ConfigurationClass

How to use the ConfigurationClass

The Configuration class is used in a class if you want to access to the server configuration information. The 'options' method is inserted into a class by invoking the configuration method at the class level.

There are no parameters to configuration. Currently it's a singleton object. The reason I am inserting it at the class level is to provide for the future possibilty of class level configuration possibly by specifying a configuration file as a parameter.

The default file is 'config.yaml'. It can be overridden on the command line with '-c myconf.yaml'.

A sample program and output follows:

$:.unshift "lib"
require 'configuration'
require 'pp'

class A
  configuration
  def initialize
    pp options['server_port']
    pp options['server_filters']
    pp options['dbfile']
  end
end

A.new

The output:

4000
[:debugfilter, :telnetfilter, :terminalfilter, :colorfilter]
"db/world.yaml"

The 'config.yaml' file looks like this:

# 
# TeensyMud configuration file
#
# Note that command line options will override the same named option
# in this configuration file.  The default configuration is named
# 'config.yaml' and can only be overridden on the command line.
# 

###########################################################
### Storage configuration section
###########################################################

dbfile: db/world.yaml

###########################################################
### Network configuration section
###########################################################

### Main server configuration

# The port to use for the telnet interface to the game
server_port: 4000

# Type of service 
#
# Valid values are
#     :server  - run reactor as server (default)
#     :client  - run reactor as client
server_type: :server

# Service io handler
#
# Valid values are
#     :sockio  - use sockio as io handler (default)
#     :lineio  - use lineio as io handler
#     :packetio  - use packetio as io handler
server_io: :sockio

# Filters to use on this service
#
# Valid values are
#
#     :filter  - attach dummy filter
#     :debugfilter - attach debug filter (default)
#     :telnetfilter - attach telnet filter (default)
#     :colorfilter - attach color filter (default)
#     :terminalfilter - attach terminal filter
server_filters:  
  - :debugfilter
  - :telnetfilter
  - :terminalfilter
  - :colorfilter

# Desired negotiation for the service
#
# Valid values are
#
#     :sga - suppress go ahead
#     :echo - server will do echoing
#     :naws - negotiate about window size
#     :ttype - negotiate terminal type
#     :zmp - negotiate zmp protocol
#     :binary - binary stream
server_negotiation:
  - :sga
  - :echo
  - :naws
  - :ttype
  - :zmp

###########################################################
### Engine configuration section
###########################################################

# not used - should set $VERBOSE?
verbose: false

# tracing on - sllooooow
trace: false

# starting location for players
home: 1

###########################################################
### Utility configuration section
###########################################################

logfile: logs/server.log


###########################################################