<commit_before>###! object helpers ###

Utils = require '../utils/utils'
grunt = require 'grunt'
_     = require 'lodash'

pkg = grunt.file.readJSON('package.json')

# Value: extracts a value from a specific property
module.exports =
  value: value = (file, prop) ->
    file = Utils.readJSON(file)
    prop = _.pick(file, prop)
    prop = _.pluck(prop)
    Utils.safeString(prop)

  # Property: extracts a specific property
  prop: prop = (file, prop) ->
    file = Utils.readJSON(file)
    prop = _.pick(file, prop)
    Utils.safeString("\n" + JSON.stringify(prop, null, 2))

  # Stringify: stringifies to JSON
  stringify: stringify = (file) ->
    file = Utils.readJSON(file)
    Utils.safeString(JSON.stringify(file, null, 2))

  # https://github.com/assemble/assemble/issues/228#issuecomment-20855238
  parseJSON: parseJSON = (data, options) ->
    options.fn JSON.parse(data)


module.exports.register = (Handlebars, options) ->

  Handlebars.registerHelper 'stringify', stringify
  Handlebars.registerHelper 'parseJSON', parseJSON
  Handlebars.registerHelper 'value', value
  Handlebars.registerHelper 'prop', prop

  # Return a property from the `assemble.options` object
  Handlebars.registerHelper "opt", (key) ->
    options[key] or ""

  @<commit_msg>update attribution for parseJSON helper<commit_after>###! object helpers ###

Utils = require '../utils/utils'
grunt = require 'grunt'
_     = require 'lodash'

pkg = grunt.file.readJSON('package.json')

# Value: extracts a value from a specific property
module.exports =
  value: value = (file, prop) ->
    file = Utils.readJSON(file)
    prop = _.pick(file, prop)
    prop = _.pluck(prop)
    Utils.safeString(prop)

  # Property: extracts a specific property
  prop: prop = (file, prop) ->
    file = Utils.readJSON(file)
    prop = _.pick(file, prop)
    Utils.safeString("\n" + JSON.stringify(prop, null, 2))

  # Stringify: stringifies to JSON
  stringify: stringify = (file) ->
    file = Utils.readJSON(file)
    Utils.safeString(JSON.stringify(file, null, 2))

  ###
  # From: <NAME> (@keeganstreet)
  # https://github.com/assemble/assemble/issues/228#issuecomment-20855238
  ###
  parseJSON: parseJSON = (data, options) ->
    options.fn JSON.parse(data)


module.exports.register = (Handlebars, options) ->

  Handlebars.registerHelper 'stringify', stringify
  Handlebars.registerHelper 'parseJSON', parseJSON
  Handlebars.registerHelper 'value', value
  Handlebars.registerHelper 'prop', prop

  # Return a property from the `assemble.options` object
  Handlebars.registerHelper "opt", (key) ->
    options[key] or ""

  @
{'fraction_non_alphanumeric': 0.13659099653712967, 'fraction_numerical': 0.010003847633705272, 'mean_word_length': 3.8417132216014895, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 16, 'https://': 2, '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': '4800516', 'n_tokens_mistral': 864, 'n_tokens_neox': 817, 'n_words': 203}