All files / universal.klown index.js

100% Statements 37/37
100% Branches 6/6
100% Functions 5/5
100% Lines 37/37

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102                                    1x 1x 1x   1x     1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x   1x 39x         39x                             1x 11x                           1x 3x 3x 3x 3x                 1x 3x 3x 3x       1x  
/*!
GPII Universal Personalization Framework GPII universal index
 
Copyright 2012 OCAD University
 
Licensed under the New BSD license. You may not use this file except in
compliance with this License.
 
The research leading to these results has received funding from the European Union's
Seventh Framework Programme (FP7/2007-2013) under grant agreement no. 289016.
 
You may obtain a copy of the License at
https://github.com/GPII/universal/blob/master/LICENSE.txt
*/
 
 
"use strict";
 
var fluid = require("infusion"),
    kettle = fluid.registerNamespace("kettle"),
    gpii = fluid.registerNamespace("gpii");
 
fluid.module.register("gpii-universal", __dirname, require);
 
// TODO: proper module loader will eliminate these requires (FLUID-5521)
require("./gpii/node_modules/transformer");
require("./gpii/node_modules/deviceReporter");
require("./gpii/node_modules/lifecycleManager");
require("./gpii/node_modules/lifecycleActions");
require("./gpii/node_modules/flowManager");
require("./gpii/node_modules/settingsHandlers");
require("./gpii/node_modules/preferencesServer");
require("./gpii/node_modules/rawPreferencesServer");
require("./gpii/node_modules/ontologyHandler");
require("./gpii/node_modules/matchMakerFramework");
require("./gpii/node_modules/flatMatchMaker");
require("./gpii/node_modules/canopyMatchMaker");
require("./gpii/node_modules/contextManager");
require("./gpii/node_modules/journal");
require("./gpii/node_modules/pouchManager");
require("./gpii/node_modules/eventLog");
require("./gpii/node_modules/processReporter");
require("./gpii/node_modules/userListeners");
 
gpii.loadTestingSupport = function () {
    fluid.contextAware.makeChecks({
        "gpii.contexts.test": {
            value: true
        }
    });
    require("./gpii/node_modules/testing");
};
 
/**
 * Query and fetch the array of configs for this GPII Kettle Server.
 * These are the configuration that allow to see if the current running
 * GPII is in local, cloud, development, production, or any of our
 * other useful configurations.
 *
 * Our underlying implementation of this may be changed or streamlined
 * in future Kettle releases.
 *
 * @return {Array} The array of Kettle config instances. In most situations
 *     there is only one.
 */
gpii.queryConfigs = function () {
    return fluid.queryIoCSelector(fluid.rootComponent, "kettle.config");
};
 
/**
 * Starts the GPII using the default development configuration
 * or if provided a custom config. Accepts an options block
 * that allows specifying the configuration name and directory
 * of configurations.
 *
 * @param options {Object} Accepts the following options:
 *   - configName {String} Name of a configuration to use, specified by the name
 *     of the file without the .json extension.
 *   - configPath {String} Directory of the configuration json files.
 */
gpii.start = function (options) {
    options = options || {};
    var configName = options.configName || "gpii.config.development.all.local";
    var configPath = options.configPath || __dirname + "/gpii/configs";
    kettle.config.loadConfig({
        configName: kettle.config.getConfigName(configName),
        configPath: kettle.config.getConfigPath(configPath)
    });
};
 
/**
 * Stops the GPII instance that was started with gpii.start()
 */
gpii.stop = function () {
    var configs = gpii.queryConfigs();
    fluid.each(configs, function (config) {
        config.destroy();
    });
};
 
module.exports = fluid;