<commit_before>/**
 * Handlebars Helpers: Data
 * Copyright (c) 2013 <NAME>, <NAME>, contributors
 * Licensed under the MIT License (MIT).
 */

'use strict';

// node_modules
var _ = require('lodash');

// Local utils
var Utils = require('../utils/utils');

// The module to be exported
var helpers = module.exports = {

  /**
   * {{value}}
   * Extract a value from a specific property
   * @param  {[type]} filepath [description]
   * @param  {[type]} prop     [description]
   * @return {[type]}          [description]
   */
  value: function (filepath, prop) {
    filepath = Utils.readJSON(filepath);
    prop = _.pick(filepath, prop);
    prop = _.pluck(prop);
    return new Utils.safeString(prop);
  },

  /**
   * {{prop}}
   * Extract a specific property
   * @param  {[type]} filepath [description]
   * @param  {[type]} prop     [description]
   * @return {[type]}          [description]
   */
  prop: function (filepath, prop) {
    filepath = Utils.readJSON(filepath);
    prop = _.pick(filepath, prop);
    return new Utils.safeString(JSON.stringify(prop, null, 2));
  },

  /**
   * {{stringify}}
   * Stringify an object to JSON
   * @param  {[type]} filepath [description]
   * @return {[type]}          [description]
   */
  stringify: function (filepath) {
    filepath = Utils.readJSON(filepath);
    return new Utils.safeString(JSON.stringify(filepath, null, 2));
  },

  /**
   * {{parseJSON}}
   * Contributed by github.com/keeganstreet
   */
  parseJSON: function (data, options) {
    return options.fn(JSON.parse(data));
  }

};

// Export helpers
module.exports.register = function (Handlebars, options) {
  options = options || {};<commit_msg>removes "Utils" method for reading JSON to make helpers more portable<commit_after>/**
 * Handlebars Helpers: Data
 * Copyright (c) 2013 <NAME>, <NAME>, contributors
 * Licensed under the MIT License (MIT).
 */

'use strict';

// node_modules
var fs = require('fs');
var _ = require('lodash');

// Local utils
var Utils = require('../utils/utils');

// The module to be exported
var helpers = module.exports = {

  /**
   * {{value}}
   * Extract a value from a specific property
   * @param  {[type]} filepath [description]
   * @param  {[type]} prop     [description]
   * @return {[type]}          [description]
   */
  value: function (filepath, prop) {
    filepath = JSON.parse(fs.readFileSync(filepath, 'utf8'));
    prop = _.pick(filepath, prop);
    prop = _.pluck(prop);
    return new Utils.safeString(prop);
  },

  /**
   * {{prop}}
   * Extract a specific property
   * @param  {[type]} filepath [description]
   * @param  {[type]} prop     [description]
   * @return {[type]}          [description]
   */
  prop: function (filepath, prop) {
    filepath = JSON.parse(fs.readFileSync(filepath, 'utf8'));
    prop = _.pick(filepath, prop);
    return new Utils.safeString(JSON.stringify(prop, null, 2));
  },

  /**
   * {{stringify}}
   * Stringify an object to JSON
   * @param  {[type]} filepath [description]
   * @return {[type]}          [description]
   */
  stringify: function (filepath) {
    filepath = JSON.parse(fs.readFileSync(filepath, 'utf8'));
    return new Utils.safeString(JSON.stringify(filepath, null, 2));
  },

  /**
   * {{parseJSON}}
   * Contributed by github.com/keeganstreet
   */
  parseJSON: function (data, options) {
    return options.fn(JSON.parse(data));
  }

};

// Export helpers
module.exports.register = function (Handlebars, options) {
  options = options || {};
{'fraction_non_alphanumeric': 0.15993121238177127, 'fraction_numerical': 0.004299226139294927, 'mean_word_length': 3.0914419695193436, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '1654320', 'n_tokens_mistral': 1149, 'n_tokens_neox': 1102, 'n_words': 292}