<commit_before>module.exports = function(app){
  var cmd = require('cmd-exec').init();
  var async = require("async");
  var stripAnsi = require('strip-ansi');

  app.get('/status', function(req, res) {
    res.type('application/json');
    cmd.exec('arkmanager status')
    .then(function(result){
      var returnData = [];
      var status = stripAnsi(result.message);
      status = status.trim();
      status = status.split('\n');
      status.forEach(function( property, i ){
         property = property.split(':');
         property[0] = property[0].toCamelCase();
         property.forEach(function( item, j ) {
            item = item.trim();
            property[j] = item;
         });
         var o = {};
         o[property[0]] = property[1];
         returnData.push(o);
      });
      res.send(returnData);
    })
    .fail(function(err){
      console.log(err.message);
    })
    .done(function(){
      console.log("successfully returned status to a client");
    });
  });

  String.prototype.toCamelCase = function() {
      return this
          .replace(/\s(.)/g, function($1) { return $1.toUpperCase(); })
          .replace(/\s/g, '')
          .replace(/^(.)/, function($1) { return $1.toLowerCase(); });
  };

}<commit_msg>change how status is displayed for easier consumption<commit_after>module.exports = function(app){
  var cmd = require('cmd-exec').init();
  var async = require("async");
  var stripAnsi = require('strip-ansi');

  app.get('/status', function(req, res) {
    res.type('application/json');
    cmd.exec('arkmanager status')
    .then(function(result){
      var returnData = {
          serverRunning: "",
          serverOnline: "",
          serverName: "",
          players: "",
          serverVersion: ""
      };
      var status = stripAnsi(result.message);
      status = status.trim();
      status = status.split('\n');
      status.forEach(function( property, i ){
         property = property.split(':');
         property[0] = property[0].toCamelCase();
         property.forEach(function( item, j ) {
            item = item.trim();
            property[j] = item;
         });
         returnData[property[0]] = property[1];
      });
      res.send(returnData);
    })
    .fail(function(err){
      console.log(err.message);
    })
    .done(function(){
      console.log("successfully returned status to a client");
    });
  });

  String.prototype.toCamelCase = function() {
      return this
          .replace(/\s(.)/g, function($1) { return $1.toUpperCase(); })
          .replace(/\s/g, '')
          .replace(/^(.)/, function($1) { return $1.toLowerCase(); });
  };

}
{'fraction_non_alphanumeric': 0.18102796674225247, 'fraction_numerical': 0.006046863189720333, 'mean_word_length': 2.329559748427673, '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': '4392729', 'n_tokens_mistral': 789, 'n_tokens_neox': 787, 'n_words': 147}