<commit_before>
'use strict';

console.log('Launching…');

// Pseudo-constants:
require('./const.js');

var Promise = require('promise');
var Immutable = require('immutable');
var Request = require('request');

var meta = require('./package.json')
,   express = require('express')
,   compression = require('compression')
,   bodyParser = require('body-parser')
,   ejs = require('ejs')
,   spawn = require('child_process').spawn
,   exec = require('child_process').exec
,   DocumentDownloader = require("./functions.js").DocumentDownloader
,   SpecberusWrapper = require("./functions.js").SpecberusWrapper
,   ThirdPartyChecker = require("./functions.js").ThirdPartyChecker
,   TokenChecker = require("./functions.js").TokenChecker
,   path = require('path')
,   app = express()
,   requests = {}
,   argTempLocation = process.argv[2] || global.DEFAULT_TEMP_LOCATION
,   argHttpLocation  = process.argv[3] || global.DEFAULT_HTTP_LOCATION
,   port = process.argv[4] || global.DEFAULT_PORT
;

app.use(compression());
app.use(bodyParser.urlencoded({ extended: false }));

app.set('view engine', 'ejs');
app.engine('.html', ejs.renderFile);

if (process.env.NODE_ENV === 'production') {
  app.set('views', __dirname + '/dist/views');
  app.use(express.static(__dirname + '/dist/assets'));
} else {
  app.set('views', __dirname + '/views');
  app.use(express.static(__dirname + '/assets'));
}

// Index Page
app.get('/', function(request, response, next) {
  response.render('index.html');
});

// API methods

app.get('/api/version', function(req, res) {
  res.send(meta.name +
    ' version ' + meta.version +
    ' running on ' + process.platform +
    ' and listening on port ' + port +
    '. The server time is ' + new Date().toLocaleTimeString() + '.');
});

app.get('/api/status', function(req, res) {
  var result
  ,   url = req.query ? req.query.url : null
  ,   entry
  ;
  if (url) {
    if (requests[url]) {
      res.json({ 'request': requests[url] });
    }
    else {
      res.status(500).send({ error: 'Request of URL ' + url + ' does not exist.' });
    }
  }
  else {
    res.json({ 'requests': requests });
  }
});

app.post('/api/request', function(req, res) {
  var url = req.body ? req.body.url : null
  ,   decision = req.body ? req.body.decision : null
  ,   isManifest = req.body ? req.body.isManifest === 'true' : false
  ;
  if (!url || !decision) {
    res.status(500).send({error: 'Missing parameters {url, decision}.'});
  }
  else {
    if (requests[url]) {
      res.send('Spec at ' + url + ' is yet pending validation OR has been already submitted. Check “/api/status”.');
    }
    else {
      requests[url] = {
        'url': url,
        'decision': decision,
        'isManifest': isManifest,
        'jobs': {},
        'history': new History()
      };
      orchestrate(requests[url], isManifest).then(function () {
        console.log('Spec at ' + url + ' (decision: ' + decision + ') has FINISHED.');
      }, function (err) {
        console.log('Spec at ' + url + ' (decision: ' + decision + ') has FAILED.');
      });
      res.send('Spec at ' + url + ' (decision: ' + decision + ') added to the queue.');
    }
  }
});

function trInstaller(source, dest) {
  return new Promise(function (resolve, reject) {
    var cmd = global.TR_INSTALL_CMD + ' ' + source + ' ' + dest;
    exec(cmd, function (err, stdout, stderr) {
      if (err) reject(err);
      else resolve();
    });
  });
}

function updateTrShortlink(uri) {
  return new Promise(function (resolve, reject) {
    var cmd = global.UPDATE_TR_SHORTLINK_CMD + ' ' + uri;
    exec(cmd, function (err, stdout, stderr) {
      if (err) reject(err);
      else resolve();
    });
  });
}

function publish(metadata) {
  return new Promise(function (resolve, reject) {
    Request.post({
      url: global.W3C_PUBSYSTEM_URL,
      form: {
        specversion: {
          uri: metadata.get('thisVersion'),
          latestVersionUri: metadata.get('latestVersion'),
          // old: [{
          //   uri: metadata.get('previousVersion'),
          //   wgid: 0, // FIXME metadata.wgId
          // }],
          date: metadata.get('docDate'),
          title: metadata.get('title'),
          // wgid: 0, // FIXME metadata.wgId
          reportEditors: metadata.get('editorIds'),
          informative: false, // FIXME Not always true
          editorDraft: metadata.get('editorsDraft'),
          processRules: metadata.get('processRules')
        }
      }
    }, function(/*err, httpResponse, body*/){
      // console.log(err);
      // console.log(httpResponse);
      // console.log(body);
      resolve();
    });
  });
}

function Job() {
  if (typeof this !== 'object') throw new TypeError('Jobs must be constructed via new');

  this.status = '';
  this.errors = [];
}
<commit_msg>specberus returns 'process' and not 'processRules'<commit_after>
'use strict';

console.log('Launching…');

// Pseudo-constants:
require('./const.js');

var Promise = require('promise');
var Immutable = require('immutable');
var Request = require('request');

var meta = require('./package.json')
,   express = require('express')
,   compression = require('compression')
,   bodyParser = require('body-parser')
,   ejs = require('ejs')
,   spawn = require('child_process').spawn
,   exec = require('child_process').exec
,   DocumentDownloader = require("./functions.js").DocumentDownloader
,   SpecberusWrapper = require("./functions.js").SpecberusWrapper
,   ThirdPartyChecker = require("./functions.js").ThirdPartyChecker
,   TokenChecker = require("./functions.js").TokenChecker
,   path = require('path')
,   app = express()
,   requests = {}
,   argTempLocation = process.argv[2] || global.DEFAULT_TEMP_LOCATION
,   argHttpLocation  = process.argv[3] || global.DEFAULT_HTTP_LOCATION
,   port = process.argv[4] || global.DEFAULT_PORT
;

app.use(compression());
app.use(bodyParser.urlencoded({ extended: false }));

app.set('view engine', 'ejs');
app.engine('.html', ejs.renderFile);

if (process.env.NODE_ENV === 'production') {
  app.set('views', __dirname + '/dist/views');
  app.use(express.static(__dirname + '/dist/assets'));
} else {
  app.set('views', __dirname + '/views');
  app.use(express.static(__dirname + '/assets'));
}

// Index Page
app.get('/', function(request, response, next) {
  response.render('index.html');
});

// API methods

app.get('/api/version', function(req, res) {
  res.send(meta.name +
    ' version ' + meta.version +
    ' running on ' + process.platform +
    ' and listening on port ' + port +
    '. The server time is ' + new Date().toLocaleTimeString() + '.');
});

app.get('/api/status', function(req, res) {
  var result
  ,   url = req.query ? req.query.url : null
  ,   entry
  ;
  if (url) {
    if (requests[url]) {
      res.json({ 'request': requests[url] });
    }
    else {
      res.status(500).send({ error: 'Request of URL ' + url + ' does not exist.' });
    }
  }
  else {
    res.json({ 'requests': requests });
  }
});

app.post('/api/request', function(req, res) {
  var url = req.body ? req.body.url : null
  ,   decision = req.body ? req.body.decision : null
  ,   isManifest = req.body ? req.body.isManifest === 'true' : false
  ;
  if (!url || !decision) {
    res.status(500).send({error: 'Missing parameters {url, decision}.'});
  }
  else {
    if (requests[url]) {
      res.send('Spec at ' + url + ' is yet pending validation OR has been already submitted. Check “/api/status”.');
    }
    else {
      requests[url] = {
        'url': url,
        'decision': decision,
        'isManifest': isManifest,
        'jobs': {},
        'history': new History()
      };
      orchestrate(requests[url], isManifest).then(function () {
        console.log('Spec at ' + url + ' (decision: ' + decision + ') has FINISHED.');
      }, function (err) {
        console.log('Spec at ' + url + ' (decision: ' + decision + ') has FAILED.');
      });
      res.send('Spec at ' + url + ' (decision: ' + decision + ') added to the queue.');
    }
  }
});

function trInstaller(source, dest) {
  return new Promise(function (resolve, reject) {
    var cmd = global.TR_INSTALL_CMD + ' ' + source + ' ' + dest;
    exec(cmd, function (err, stdout, stderr) {
      if (err) reject(err);
      else resolve();
    });
  });
}

function updateTrShortlink(uri) {
  return new Promise(function (resolve, reject) {
    var cmd = global.UPDATE_TR_SHORTLINK_CMD + ' ' + uri;
    exec(cmd, function (err, stdout, stderr) {
      if (err) reject(err);
      else resolve();
    });
  });
}

function publish(metadata) {
  return new Promise(function (resolve, reject) {
    Request.post({
      url: global.W3C_PUBSYSTEM_URL,
      form: {
        specversion: {
          uri: metadata.get('thisVersion'),
          latestVersionUri: metadata.get('latestVersion'),
          // old: [{
          //   uri: metadata.get('previousVersion'),
          //   wgid: 0, // FIXME metadata.wgId
          // }],
          date: metadata.get('docDate'),
          title: metadata.get('title'),
          // wgid: 0, // FIXME metadata.wgId
          reportEditors: metadata.get('editorIds'),
          informative: false, // FIXME Not always true
          editorDraft: metadata.get('editorsDraft'),
          processRules: metadata.get('process')
        }
      }
    }, function(/*err, httpResponse, body*/){
      // console.log(err);
      // console.log(httpResponse);
      // console.log(body);
      resolve();
    });
  });
}

function Job() {
  if (typeof this !== 'object') throw new TypeError('Jobs must be constructed via new');

  this.status = '';
  this.errors = [];
}

{'fraction_non_alphanumeric': 0.1768254628666528, 'fraction_numerical': 0.00249635947576451, 'mean_word_length': 2.883279483037157, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7256458', 'n_tokens_mistral': 3046, 'n_tokens_neox': 3045, 'n_words': 657}