<commit_before>/*
 * index.js: Top-level include for the drone module.
 *
 * (C) 2010, Nodejitsu Inc.
 *
 */

var fs = require('fs'),
    path = require('path'),
    async = require('async'),
    hookio = require('hook.io'),
    haibu = require('../../haibu'),
    http = require('http');

//
// ### Include Exports
// Export other components in the module
//
exports.createRouter = require('./service').createRouter;
exports.Drone        = require('./drone').Drone;
exports.Client       = require('./client').Client;
exports.started      = false;

//
// ### function createServer (options)
// #### @options {Object} Options to use when creating this server
//
// Creates a server for the haibu `drone` webservice.
//

//
// (dominictarr) i've added a streaming interface for push commits.
// see lib/haibu/deploy
//
exports.createServer = function (options) {
  var drone = new haibu.drone.Drone(options),
      router = haibu.drone.createRouter(drone),
      contentTypes = { 'application/json': router },
      handler = haibu.utils.handler({ contentTypes: contentTypes, port: options.port }),
      deploy = require('../core/deploy').handler(drone, options)

    var server = http.createServer(function (req, res) {
      if (/^\/(deploy|info)/.test(req.url)) {
        deploystreaming(req, res) //streaming interface.
      }
      else {
        handler(req, res) //buffering interface.
      }
    })

  // this breaks the nodejs idiom of createServer.
  // createServer should not return a server that is already listening.
  // if it does this it should be called startServer

  if (options.port) {
    server.listen(options.port);
  }

  server.drone = drone;
  return server;
};

//
// ### function startHook (options, callback)
// #### @options {Object} Options for the `hookio.Hook` instance.
// #### @callback {function} Continuation to respond to when complete.
// Starts a new `hookio.Hook` for this `haibu` process.
//<commit_msg>[fix] Update bad variable reference<commit_after>/*
 * index.js: Top-level include for the drone module.
 *
 * (C) 2010, Nodejitsu Inc.
 *
 */

var fs = require('fs'),
    path = require('path'),
    async = require('async'),
    hookio = require('hook.io'),
    haibu = require('../../haibu'),
    http = require('http');

//
// ### Include Exports
// Export other components in the module
//
exports.createRouter = require('./service').createRouter;
exports.Drone        = require('./drone').Drone;
exports.Client       = require('./client').Client;
exports.started      = false;

//
// ### function createServer (options)
// #### @options {Object} Options to use when creating this server
//
// Creates a server for the haibu `drone` webservice.
//

//
// (dominictarr) i've added a streaming interface for push commits.
// see lib/haibu/deploy
//
exports.createServer = function (options) {
  var drone = new haibu.drone.Drone(options),
      router = haibu.drone.createRouter(drone),
      contentTypes = { 'application/json': router },
      handler = haibu.utils.handler({ contentTypes: contentTypes, port: options.port }),
      deploy = require('../core/deploy').handler(drone, options)

    var server = http.createServer(function (req, res) {
      if (/^\/(deploy|info)/.test(req.url)) {
        deploy(req, res) //streaming interface.
      }
      else {
        handler(req, res) //buffering interface.
      }
    })

  // this breaks the nodejs idiom of createServer.
  // createServer should not return a server that is already listening.
  // if it does this it should be called startServer

  if (options.port) {
    server.listen(options.port);
  }

  server.drone = drone;
  return server;
};

//
// ### function startHook (options, callback)
// #### @options {Object} Options for the `hookio.Hook` instance.
// #### @callback {function} Continuation to respond to when complete.
// Starts a new `hookio.Hook` for this `haibu` process.
//
{'fraction_non_alphanumeric': 0.15561812132070643, 'fraction_numerical': 0.002047606859482979, 'mean_word_length': 2.9594731509625127, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4086873', 'n_tokens_mistral': 1199, 'n_tokens_neox': 1167, 'n_words': 342}