# All files / src/config config.coffee

90% Statements 9/10
50% Branches 1/2
100% Functions 2/2
90% Lines 9/10

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    421x

    1x

    1x

    1x
    1x

    1x

    1x

    1x

    1x
     nconf = require("nconf")

    ###
    # Define the default constructor
    ###
    Config = ->

      # Define the variables to use
      environment = undefined

      # Get the argument-value to use
      nconf.argv().env "_"
      environment = nconf.get("NODE:ENV") or "development"

      # Load the configuration-values
      # user specified config override
      if nconf.get("conf")
        nconf.file 'customConfigOverride', nconf.get('conf')

      # environment override
      if environment
        # appRoot is a global var - set in server.cofee
        nconf.file 'environmentOverride', appRoot + '/config/' + environment + '.json'

      # load the default config file
      # appRoot is a global var - set in server.cofee
      nconf.file 'default', appRoot + '/config/default.json'

      # Return the result
      return

    ###
    # This function return the value that was set in the key-value store
    ###
    Config::get = (key) ->
      nconf.get key

    ###
    # This function constructs a new instanse of this class
    ###
    module.exports = new Config()