brollb/webgme-simple-nodes

View on GitHub
src/plugins/MinimalExample/MinimalExample.js

Summary

Maintainability
A
0 mins
Test Coverage
/*globals define*/
/*jshint node:true, browser:true*/

/**
 * Generated by PluginGenerator 1.7.0 from webgme on Fri Apr 29 2016 21:46:37 GMT-0500 (CDT).
 */

define([
    'SimpleNodes/SimpleNodes',
    'SimpleNodes/Constants',
    'text!./metadata.json'
], function (
    PluginBase,
    Constants,
    pluginMetadata
) {
    'use strict';

    pluginMetadata = JSON.parse(pluginMetadata);

    /**
     * Initializes a new instance of MinimalExample.
     * @class
     * @augments {PluginBase}
     * @classdesc This class represents the plugin MinimalExample.
     * @constructor
     */
    var MinimalExample = function () {
        // Call base class' constructor.
        PluginBase.call(this);
        this.pluginMetadata = pluginMetadata;
    };

    /**
     * Metadata associated with the plugin. Contains id, name, version, description, icon, configStructue etc.
     * This is also available at the instance at this.pluginMetadata.
     * @type {object}
     */
    MinimalExample.metadata = pluginMetadata;

    // Prototypical inheritance from PluginBase.
    MinimalExample.prototype = Object.create(PluginBase.prototype);
    MinimalExample.prototype.constructor = MinimalExample;

    /**
     * Create the output files stored in a JS Object where the 
     * key is the file name and the value is the file content.
     *
     * @param {Virtual Node} root
     * @return {Object}
     */
    MinimalExample.prototype.createOutputFiles = function(activeNode) {
        var outputFiles = {};

        // You can also create whatever output files you want
        outputFiles['output.txt'] = [
            'Current node: ' + activeNode.name,
            'Children: ' + activeNode[Constants.CHILDREN].length
        ].join('\n');
        return outputFiles;
    };

    return MinimalExample;
});