<commit_before>/*
 * grunt-connector
 * https://github.com/trevorsheridan/connector
 *
 * Copyright (c) 2013 <NAME>
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function(grunt) {
  var utility = require('../lib/utility');
  
  grunt.registerTask('connector', 'Prototyping server for the modern man.', function() {
    var express = require('express');
    var engines = require('consolidate');
    var application = express();
    
    var options = this.options({
      assets: process.cwd() + '/public',
      port: process.env.PORT || 3000,
      templates: process.cwd() + '/source/templates',
      templateEngine: 'hogan',
    });
    
    this.async();
    
    // Set the templating engine configuration.
    application.set('views', options.templates);
    application.set('view engine', 'html');
    application.engine('html', engines[options.templateEngine]);
    
    // Serve static assets from the public directory (falls back to this if development is on and recompiling less).
    application.use(express.static(options.assets));
    
    // Catch all other requests and route to the appropriate template.
    application.use(function(request, response) {
      var path = request._parsedUrl.pathname;
      var files = utility.listing(application.get('views'));
      var template = utility.find(files, path.split('/'), 'index') || 404;
      
      grunt.log.ok("Responding to " + path + " with template " + template + "".green);
      response.status(typeof template === 'number' ? template : 200).render(template);
    });
    
    application.listen(options.port);
    grunt.log.ok("Server listening for incoming connections on port " + options.port + "".green);
  });
};<commit_msg>Moving process.cwd() outside of default options (need a better way to do this)<commit_after>/*
 * grunt-connector
 * https://github.com/trevorsheridan/connector
 *
 * Copyright (c) 2013 <NAME>
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function(grunt) {
  var utility = require('../lib/utility');
  
  grunt.registerTask('connector', 'Prototyping server for the modern man.', function() {
    var express = require('express');
    var engines = require('consolidate');
    var application = express();
    
    var options = this.options({
      assets: '/public',
      port: process.env.PORT || 3000,
      templates: '/source/templates',
      templateEngine: 'hogan'
    });
    
    this.async();
    
    // Set the templating engine configuration.
    application.set('views', process.cwd() + '/' + options.templates);
    application.set('view engine', 'html');
    application.engine('html', engines[options.templateEngine]);
    
    // Serve static assets from the public directory (falls back to this if development is on and recompiling less).
    application.use(express.static(process.cwd() + '/' + options.assets));
    
    // Catch all other requests and route to the appropriate template.
    application.use(function(request, response) {
      var path = request._parsedUrl.pathname;
      var template = utility.find(utility.listing(application.get('views')), path.split('/'), 'index') || 404;
      
      grunt.log.ok("Responding to " + path + " with template " + template + "".green);
      response.status(typeof template === 'number' ? template : 200).render(template);
    });
    
    application.listen(options.port);
    grunt.log.ok("Server listening for incoming connections on port " + options.port + "".green);
  });
};
{'fraction_non_alphanumeric': 0.14460575007116425, 'fraction_numerical': 0.007970395673213778, 'mean_word_length': 3.274939172749392, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '7443124', 'n_tokens_mistral': 1005, 'n_tokens_neox': 968, 'n_words': 265}