<commit_before>require 'config/emoij'

@Travis.Helpers =
  COLORS:
    default:  'yellow'
    passed:   'green'
    failed:   'red'
    errored:  'gray'
    canceled: 'gray'

  compact: (object) ->
    result = {}
    (result[key] = value unless $.isEmpty(value)) for key, value of object || {}
    result

  safe: (string) ->
    new Handlebars.SafeString(string)

  colorForState: (state) ->
    Travis.Helpers.COLORS[state] || Travis.Helpers.COLORS['default']

  formatCommit: (sha, branch) ->
    Travis.Helpers.formatSha(sha) + if branch then " (#{branch})" else ''

  formatSha: (sha) ->
    (sha || '').substr(0, 7)

  formatConfig: (config) ->
    config = $.only config, Object.keys(Travis.CONFIG_KEYS_MAP)
    values = $.map config, (value, key) ->
      value = (if value && value.join then value.join(', ') else value) || ''
      if key == 'rvm' && "#{value}".match(/^\d+$/)
        value = "#{value}.0"
      '%@: %@'.fmt Travis.CONFIG_KEYS_MAP[key], value
    if values.length == 0 then '-' else values.join(', ')

  formatMessage: (message, options) ->
    message = message || ''
    message = message.split(/\n/)[0]  if options.short
    message = @_emojize(@_escape(message))
    if !!options.repo
      message = @githubify(message, options.repo.get('owner'), options.repo.get('name'))
    message.replace /\n/g, '<br/>'

  pathFrom: (url) ->
    (url || '').split('/').pop()

  timeAgoInWords: (date) ->
    $.timeago.distanceInWords date

  durationFrom: (started, finished) ->
    started = started and @_toUtc(new Date(@_normalizeDateString(started)))
    finished = if finished then @_toUtc(new Date(@_normalizeDateString(finished))) else @_nowUtc()
    if started && finished then Math.round((finished - started) / 1000) else 0

  timeInWords: (duration) ->
    days = Math.floor(duration / 86400)
    hours = Math.floor(duration % 86400 / 3600)
    minutes = Math.floor(duration % 3600 / 60)<commit_msg>Replace leading whitespace in commit message.<commit_after>require 'config/emoij'

@Travis.Helpers =
  COLORS:
    default:  'yellow'
    passed:   'green'
    failed:   'red'
    errored:  'gray'
    canceled: 'gray'

  compact: (object) ->
    result = {}
    (result[key] = value unless $.isEmpty(value)) for key, value of object || {}
    result

  safe: (string) ->
    new Handlebars.SafeString(string)

  colorForState: (state) ->
    Travis.Helpers.COLORS[state] || Travis.Helpers.COLORS['default']

  formatCommit: (sha, branch) ->
    Travis.Helpers.formatSha(sha) + if branch then " (#{branch})" else ''

  formatSha: (sha) ->
    (sha || '').substr(0, 7)

  formatConfig: (config) ->
    config = $.only config, Object.keys(Travis.CONFIG_KEYS_MAP)
    values = $.map config, (value, key) ->
      value = (if value && value.join then value.join(', ') else value) || ''
      if key == 'rvm' && "#{value}".match(/^\d+$/)
        value = "#{value}.0"
      '%@: %@'.fmt Travis.CONFIG_KEYS_MAP[key], value
    if values.length == 0 then '-' else values.join(', ')

  formatMessage: (message, options) ->
    message = message || ''
    message = message.split(/\n/)[0]  if options.short
    message = @_emojize(@_escape(message))
    if !!options.repo
      message = @githubify(message, options.repo.get('owner'), options.repo.get('name'))
    message.replace /\n/g, '<br/>'
    message.replace /^ +/, '&nbsp;'

  pathFrom: (url) ->
    (url || '').split('/').pop()

  timeAgoInWords: (date) ->
    $.timeago.distanceInWords date

  durationFrom: (started, finished) ->
    started = started and @_toUtc(new Date(@_normalizeDateString(started)))
    finished = if finished then @_toUtc(new Date(@_normalizeDateString(finished))) else @_nowUtc()
    if started && finished then Math.round((finished - started) / 1000) else 0

  timeInWords: (duration) ->
    days = Math.floor(duration / 86400)
    hours = Math.floor(duration % 86400 / 3600)
    minutes = Math.floor(duration % 3600 / 60)
{'fraction_non_alphanumeric': 0.1764256619144603, 'fraction_numerical': 0.015274949083503055, 'mean_word_length': 3.1886993603411513, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, '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': '3819978', 'n_tokens_mistral': 1387, 'n_tokens_neox': 1319, 'n_words': 304}