<commit_before>module ParseGemspec
  class Parser
    def self.parse(contents)
      spec = nil
      Tempfile.create('parse_gemspec') do |f|
        f.write contents
        f.rewind
        spec = Gem::Specification.load(f.path)
      end
      {
        name: spec.name,
        version: spec.version.version
      }
    end
  end
end<commit_msg>chore(parser): use Tempfile.open instead of Tempfile.create<commit_after>module ParseGemspec
  class Parser
    def self.parse(contents)
      spec = nil
      begin
        temp_file = Tempfile.open('parse_gemspec') do |f|
          f.write contents
          f.flush
          f.rewind
          spec = Gem::Specification.load(f.path)
          f
        end
      ensure
        temp_file.close!
      end
      {
        name: spec.name,
        version: spec.version.version
      }
    end
  end
end
{'fraction_non_alphanumeric': 0.08313817330210772, 'fraction_numerical': 0.0, 'mean_word_length': 1.7580645161290323, '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': '6858308', 'n_tokens_mistral': 263, 'n_tokens_neox': 262, 'n_words': 59}