{"size": 1422, "ext": "js", "max_stars_repo_path": "src/public/js/output/factory.js", "max_stars_repo_name": "ramitos/TermKit", "max_stars_repo_stars_event_min_datetime": "2015-09-20T14:30:13.000Z", "max_stars_repo_stars_event_max_datetime": "2015-11-05T05:59:53.000Z", "max_issues_repo_path": "src/public/js/output/factory.js", "max_issues_repo_name": "ramitos/TermKit", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/public/js/output/factory.js", "max_forks_repo_name": "ramitos/TermKit", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 29.625, "max_line_length": 87, "alphanum_fraction": 0.635021097}
console.log('REQUIRED: FACTORY');
var misc = require('../misc/misc'),
    node = require('./node');

/**
 * Constructs node objects of the right class.
 */
var factory = module.exports = function () {
  console.log('NEW OUTPUT.FACTORY');
};

factory.prototype.tree = function (objects) {
  // Construct a tree of view objects.
  var that = this;
  return misc.oneOrMany(objects).map(function (node) { return that.construct(node); });
};

factory.prototype.construct = function (properties) {
  var type = widgets[properties.type] || ov.outputNode,
      node = new type(properties),
      that = this;
  
  if (node.properties.children) {
    var nodes = node.properties.children.map(function (node) {
      return that.construct(node);
    });
    delete node.properties.children;
    node.add(nodes);
  }
  
  return node;
};

///////////////////////////////////////////////////////////////////////////////

var widgets = factory.widgets = {};

widgets.view = require('./widgets/view');
widgets.text = require('./widgets/text');
widgets.html = require('./widgets/html');
widgets.icon = require('./widgets/icon');
widgets.file = require('./widgets/file');
widgets.image = require('./widgets/image');
widgets.list = require('./widgets/list');
widgets.code = require('./widgets/code');
widgets.hex = require('./widgets/hex');
widgets.progress = require('./widgets/progress');
widgets.spinner = require('./widgets/spinner');