<commit_before>/**
 * Required packages
 */
const os = require('os');
const osName = require('os-name');
const getos = require('getos');
const humem = require('humem');
const internalIp = require('internal-ip').v4();
const publicIp = require('public-ip').v4();
const netmask = require('ipmask')();

/**
 *  Abstract module with all methods
 */
module.exports = {

    /**
     * Advanced data method. Gathers all advanced data
     * and returns is as an object. The data param is optional.
     * @param  {Object} data
     */
    gatherAdvancedData(data = {}) {
        return {
            platform     : this.getPlatform(),
            release      : this.getRelease(),
            processor    : this.parseCPUModel(),
            architecture : os.arch(),
            totalMem     : humem.totalmem,
            hostname     : os.hostname(),
            localIp      : data.localIp,
            publicIp     : data.publicIp,
            networkMask  : netmask.netmask,
            mac          : netmask.mac
        };
    },

    getPlatform() {
        getos((e, os) => {
            console.log(os);
        });
        if (os.platform() === 'linux') {

        } else {
            return osName(os.platform(), os.release());
        }
    },

    getRelease() {
        return os.release();
    },

    /**
     * Parses the CPU model retrived by the os module
     */
    parseCPUModel() {
        let model = os.cpus()[0].model,
            split = model.split('@'),
            modelName = split[0].trim(),
            frequency = split[1].trim();

        modelName = modelName.split('-');
        modelName = modelName[0].replace('CPU', '')
                    .replace(/\(.*?\)/g, '');

        return `${frequency} ${modelName}`;
    },

    /**
     * Retrives the current server internal Ip and external Ip.
     * Passes the data using a callback function.
     * @param  {Function} callback
     * @param  {Function} next
     */
    getIpObject(callback, next) {
        publicIp.then(ip => {
            let ipObject = {<commit_msg>Adds os data method in API<commit_after>/**
 * Required packages
 */
const os = require('os');
const osName = require('os-name');
const getos = require('getos');
const humem = require('humem');
const internalIp = require('internal-ip').v4();
const publicIp = require('public-ip').v4();
const netmask = require('ipmask')();

/**
 *  Abstract module with all methods
 */
module.exports = {

    /**
     * Advanced data method. Gathers all advanced data
     * and returns is as an object. The data param is optional.
     * @param  {Object} data
     */
    gatherAdvancedData(data = {}) {
        return {
            platform     : this.getOs('platform'),
            release      : this.getOs('release'),
            processor    : this.parseCPUModel(),
            architecture : os.arch(),
            totalMem     : humem.totalmem,
            hostname     : os.hostname(),
            localIp      : data.localIp,
            publicIp     : data.publicIp,
            networkMask  : netmask.netmask,
            mac          : netmask.mac
        };
    },

    /**
     * Returns data about OS distribution and release
     * @param {String} type
     */
    getOs(type) {
        let platform = os.platform(),
            release = os.release(),
            output;

        switch (type) {
            case 'platform':
                if (platform === 'linux') {
                    output = getos((e, os) => { return os.dist; });
                } else {
                    output = osName(platform, release);
                }
            break;
            case 'release':
                if (platform === 'linux') {
                    output = getos((e, os) => { return os.release; });
                } else {
                    output = release;
                }
            break;
        }

        return output;
    },

    /**
     * Parses the CPU model retrived by the os module
     */
    parseCPUModel() {
        let model = os.cpus()[0].model,
            split = model.split('@'),
            modelName = split[0].trim(),
            frequency = split[1].trim();

        modelName = modelName.split('-');
        modelName = modelName[0].replace('CPU', '')
                    .replace(/\(.*?\)/g, '');

        return `${frequency} ${modelName}`;
    },

    /**
     * Retrives the current server internal Ip and external Ip.
     * Passes the data using a callback function.
     * @param  {Function} callback
     * @param  {Function} next
     */
    getIpObject(callback, next) {
        publicIp.then(ip => {
            let ipObject = {
{'fraction_non_alphanumeric': 0.13949470956596846, 'fraction_numerical': 0.0025912329950334703, 'mean_word_length': 1.6408209806157354, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '3476514', 'n_tokens_mistral': 1288, 'n_tokens_neox': 1269, 'n_words': 323}