<commit_before>require 'multi_json'

module Fitting
  class JsonFile
    NAME = 'storage.json'.freeze

    def self.save(json)
      File.open(NAME, 'w') do |file|
        file.write(MultiJson.dump(json))
      end
    end

    def self.push(key, value)
      save('tests' => tests.merge(key => value))
    end

    def self.tests
      MultiJson.load(File.read(NAME))['tests']<commit_msg>fix work with storage file<commit_after>require 'multi_json'

module Fitting
  class JsonFile
    NAME = 'storage.json'.freeze

    def self.save(json)
      File.open(NAME, 'w') do |file|
        file.write(MultiJson.dump(json))
      end
    end

    def self.push(key, value)
      save('tests' => tests.merge(key => value))
    rescue
    end

    def self.tests
      MultiJson.load(File.read(NAME))['tests']
    rescue
{'fraction_non_alphanumeric': 0.13038130381303814, 'fraction_numerical': 0.0, 'mean_word_length': 2.7168949771689497, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4298978', 'n_tokens_mistral': 277, 'n_tokens_neox': 270, 'n_words': 59}