<commit_before>require 'base64'

module Resume
  class Parser
    # Base64-encoded values can be found in hash and array values
    # in the JSON, so specifically target those data types for
    # manipulation, and ignore any direct references given to the
    # keys or values of the JSON hash.
    def self.parse
      Proc.new do |object|
        case object
        when Hash
          object.each do |key, value|
            if key == :align
              # Prawn specifically requires :align values to
              # be symbols otherwise it errors out
              object[key] = value.to_sym
            else
              value = decode_content(value) if encoded?(value)
              value = FileFetcher.fetch(value) if asset?(value)
              object[key] = value
            end
          end
        when Array
          object.each_with_index do |value, index|
            object[index] = decode_content(value) if encoded?(value)
          end
        else
          object
        end
      end
    end<commit_msg>First pass at excluding font files from being downloaded immediately.<commit_after>require 'base64'

module Resume
  class Parser
    # Base64-encoded values can be found in hash and array values
    # in the JSON, so specifically target those data types for
    # manipulation, and ignore any direct references given to the
    # keys or values of the JSON hash.
    def self.parse
      Proc.new do |object|
        case object
        when Hash
          object.each do |key, value|
            if key == :align
              # Prawn specifically requires :align values to
              # be symbols otherwise it errors out
              object[key] = value.to_sym
            else
              if encoded?(value)
                value = decode_content(value)
              end
              if asset?(value) && key != :location
                value = FileFetcher.fetch(value)
              end
              object[key] = value
            end
          end
        when Array
          object.each_with_index do |value, index|
            object[index] = decode_content(value) if encoded?(value)
          end
        else
          object
        end
      end
    end
{'fraction_non_alphanumeric': 0.05615942028985507, 'fraction_numerical': 0.0036231884057971015, 'mean_word_length': 1.632896305125149, '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': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6029060', 'n_tokens_mistral': 545, 'n_tokens_neox': 540, 'n_words': 214}