<commit_before># encoding: utf-8
require 'json'

module Reporter
  #
  # Used to write report to file on disk
  #
  class JsonFile
    def initialize(opts)
      @opts = opts
    end

    def send_report(report)
      write_to_file(report, @opts[:file])
    end

    def write_to_file(report, path)
      json_file = File.new(path, 'w')
      json_file.puts(report)
      json_file.close<commit_msg>Make json-file reporter save JSON content (#246)<commit_after># encoding: utf-8
require 'json'

module Reporter
  #
  # Used to write report to file on disk
  #
  class JsonFile
    def initialize(opts)
      @opts = opts
    end

    def send_report(report)
      write_to_file(report, @opts[:file])
    end

    def write_to_file(report, path)
      json_file = File.new(path, 'w')
      json_file.puts(JSON.generate(report))
      json_file.close
{'fraction_non_alphanumeric': 0.09787735849056604, 'fraction_numerical': 0.00589622641509434, 'mean_word_length': 2.912442396313364, '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': '2625212', 'n_tokens_mistral': 292, 'n_tokens_neox': 281, 'n_words': 75}