Example #1
0
  setTimeout(function() {
    var statusTab = _.map(status.services, function(value, key) { return value; });
    status.summarize = {};
    status.summarize.lastupdate = status.lastupdate;
    status.summarize.up = _.reduce(_.select(status.services, function(data){ return data.status == 'up'; }), function(memo, num){ return memo + 1; }, 0);
    status.summarize.critical = _.reduce(_.select(status.services, function(data){ return data.status == 'critical'; }), function(memo, num){ return memo + 1; }, 0);
    status.summarize.down = _.reduce(_.select(status.services, function(data){ return data.status == 'down'; }), function(memo, num){ return memo + 1; }, 0);
    status.summarize.unknown = _.reduce(_.select(status.services, function(data){ return data.status == 'unknown'; }), function(memo, num){ return memo + 1; }, 0);

    controller.emit("refresh", status);
  }, settings.serviceDelay);
Example #2
0
  }, function(error, res, body) {
    if (!error && res.statusCode == 200) {
      var things = JSON.parse(body); // array of strings.

      //NOTE: this is using case-sensitive comparison
      if (_options.onlyInclude) {
        things = _.select(things, function(thing) {
          return _options.onlyInclude.indexOf(thing.name) > -1;
        });
      }

      //NOTE: this is using case-sensitive comparison
      if (_options.exclude) {
        things = _.reject(things, function(thing) {
          return _options.exclude.indexOf(thing.name) > -1;
        });
      }

      var sem = things.length;

      _.each(things, function(thing) {
        client[thing.name] = buildClientApi(thing);
      });

      _cb(null, client);

    } else {
      _cb && _cb("Unable to retrieve available APIs from " + _options.url + ' due to: ' + require('util').inspect(error));
    }
  });
Example #3
0
 var finalizePublish = function(err, publishResult) {
   if (err) {
     //crash with data (including stack info)
     throw new Error("Error publishing: " + err);
   } else {
     if (options.files) {
       var virtualFiles = _.select(options.files, function(file) {
         return file.virtual;
       });
       if (virtualFiles && virtualFiles.length) {
         _.each(virtualFiles, function(file) {
           $j.tmpl(options.template, {
             href: file.path
           }).appendTo($j('resources'));
         });
       }
       if (consolidate) {
         $j.tmpl(options.template, { href: publishResult.consolidatedUrl }).appendTo($j('resources'));
       } else {
         _.each(publishResult.components, function(component) {
           $j.tmpl(options.template, {
             href: component.url
           }).appendTo($j('resources'));
         });            
       }
     }
   }
   callback(err);
 };
Example #4
0
 paperboy.deliver(docRoot, req, res).otherwise(function(err) {
   var pathname = url.parse(req.url).pathname;
   var pluginDocRootSelect = _.select(pluginsDocRoot, function(data) { return pathname.toString().startsWith(data.prefix); });
   if (pluginDocRootSelect && pluginDocRootSelect[0]) {
     var pluginDocRoot = pluginDocRootSelect[0];
     req.url = pathname.toString().replace(pluginDocRoot.prefix, "");
     paperboy.deliver(pluginDocRoot.docRoot, req, res).otherwise(function(err) {
       res.writeHead(404);
       res.end('File not found.');
     });
   } else {
     res.writeHead(route.status, route.headers);
     res.end(route.body);
   }
 });
Example #5
0
    unimplemented: function(step) {
      sys.print(style.magenta('.'));
      if (++dots % 50 === 0) sys.print('\n');

      var markedAsUnimplemented =
        _.select(__peanut__.unimplemented, function(unimplemented) {
          return unimplemented.pattern === step.pattern;
        }).length > 0;

      if (!markedAsUnimplemented) {
        __peanut__.unimplemented.push(step);
        __peanut__.testCounts.unimplemented++;
      }

      addToTotals();
    }
Example #6
0
module.exports.pluginsClient = function(req, res) {
  var plugins = _.map(_.select(_.map(settings.plugins, function(num, key) { return { name:key, enable: num.enable, client: num.client } }), function(data) { return (data.enable == true && data.client == true); }), function(num, key) { return { name:num.name } });
  res.send(200, {}, JSON.stringify(plugins));
}
Example #7
0
module.exports.servicesElement = function(req, res, value) {
  res.send(200, {}, JSON.stringify(_.first(_.select(status.services, function(data){ return data.name == value; }))));
};
Example #8
0
 function isHundredPrecent() {
     return _.select(values, function(value) {
         return value > 0;
     }).length === 1;
 };