All files / universal/gpii/node_modules/processReporter/src ProcessReporter.js

46.67% Statements 7/15
33.33% Branches 2/6
0% Functions 0/3
46.67% Lines 7/15
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                            1x 1x   1x                               1x                         1x         1x               1x                        
/**
 * GPII Process Reporter
 *
 * Copyright 2015-2017 OCAD University
 *
 * Licensed under the New BSD license. You may not use this file except in
 * compliance with this License.
 *
 * You may obtain a copy of the License at
 * https://github.com/GPII/universal/blob/master/LICENSE.txt
 */
 
"use strict";
 
var fluid = fluid || require("infusion"),
    gpii = fluid.registerNamespace("gpii");
 
fluid.defaults("gpii.processReporter", {
    gradeNames: ["fluid.component"],
    components: {
        nameResolver: {
            type: "gpii.processReporter.nameResolver"
        }
    },
    invokers: {
        handleIsRunning: {
            funcName: "gpii.processReporter.handleIsRunning",
            args: ["{arguments}.0"]
                   // entry
        }
    }
});
 
fluid.defaults("gpii.processReporter.nameResolver", {
    gradeNames: ["fluid.component"],
    invokers: {
        resolveName: {
            funcName: "fluid.identity"
        }
    }
});
 
/* Marker function for use in isRunning sections of a launch handler
 * to identify in a meaningful way that the solutions start block should always
 * be run.
 */
fluid.defaults("gpii.processReporter.neverRunning", {
    gradeNames: "fluid.function",
    argumentMap: {}
});
 
gpii.processReporter.neverRunning = function () {
    return false;
};
 
/**
 * Runs the 'isRunning' entries of the 'entry' argument. If no 'isRunning' block is not present
 * undefined is returned
 */
gpii.processReporter.handleIsRunning = function (entry) {
    var running = undefined;
    if (!!entry.isRunning) {
        running = true;
 
        fluid.each (fluid.makeArray(entry.isRunning), function (aMember) {
            var partial = fluid.invokeGradedFunction(aMember.type, aMember);
            running = running && partial;
        });
    }
    return running;
};