<commit_before>/**
 * lifesized: Get the physical size of displays and their ppi
 */

var screen = require('screen'),
    remote = require('remote'),
    execSync = require('child_process').execSync,
    path = require('path'),
    os = require('os');

var lifesized = {

    /**
     * Get the pixels per inch of a screen
     *
     * @param [screen] (Electron Screen Instance) If not provided the display
              this process' BrowserWindow' is over will be used
     */
    ppi: function(screen){
        screen = screen || getBrowserWindowDisplay();
        return getPPI(screen);
    }
};

/**
 * Get the display that the window is mostly over
 */
function getBrowserWindowDisplay(){
    return screen.getDisplayMatching(remote.getCurrentWindow().getBounds());
}

/**
 * Get a screens PPI
 */
function getPPI(screen){
    // If on a mac use our native binary to do the work, otherwise fall back
    // to a default
    if(os.platform() === "darwin"){
        return  parseFloat(
                    execSync(
                        path.resolve(__dirname, "../bin/lifesized-cli") + " " + screen.id
                    )
                );
    } else {
        return 72.0;
    }
}

module.exports = lifesized;
<commit_msg>Fix for working in the main process<commit_after>/**
 * lifesized: Get the physical size of displays and their ppi
 */

var screen = require('screen'),
    execSync = require('child_process').execSync,
    path = require('path'),
    os = require('os');

var lifesized = {

    /**
     * Get the pixels per inch of a screen
     *
     * @param [screen] (Electron Screen Instance) If not provided the display
              this process' BrowserWindow' is over will be used
     */
    ppi: function(display){
        display = display || getBrowserWindowDisplay();
        return getPPI(display);
    }
};

/**
 * Get the display that the window is mostly over
 */
function getBrowserWindowDisplay(){
    // Don't require remote unless we hit here as it can't be required in the
    // main process. Main processes need to provide
    var remote = require('remote');
    return screen.getDisplayMatching(remote.getCurrentWindow().getBounds());
}

/**
 * Get a screens PPI
 */
function getPPI(display){
    // If on a mac use our native binary to do the work, otherwise fall back
    // to a default
    if(os.platform() === "darwin"){
        return  parseFloat(
                    execSync(
                        path.resolve(__dirname, "../bin/lifesized-cli") + " " + display.id
                    )
                );
    } else {
        return 72.0;
    }
}

module.exports = lifesized;

{'fraction_non_alphanumeric': 0.11588145896656535, 'fraction_numerical': 0.0022796352583586625, 'mean_word_length': 2.2506172839506173, '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': '2708666', 'n_tokens_mistral': 738, 'n_tokens_neox': 711, 'n_words': 242}