<commit_before>class File

  def self.mime_type?(file)
     if file.class == File
       unless RUBY_PLATFORM.include? 'mswin32'
         mime = `file --mime -br #{file.path}`.strip
       else
         mime = EXTENSIONS[File.extname(file.path).gsub('.','').downcase.to_sym]
       end
     elsif file.class == String
       mime = EXTENSIONS[(file[file.rindex('.')+1, file.size]).downcase.to_sym]
     elsif file.class == StringIO
       temp = File.open(Dir.tmpdir + '/upload_file.' + Process.pid.to_s, "wb")
       temp << file.string
       temp.close
       mime = `file --mime -br #{temp.path}`
       mime = mime.gsub(/^.*: */,"")
       mime = mime.gsub(/;.*$/,"")
       mime = mime.gsub(/,.*$/,"")<commit_msg>Getting a nil object error for files with no extension, would prefer an 'unknown/unknown' mimetype<commit_after>class File

  def self.mime_type?(file)
     if file.class == File
       unless RUBY_PLATFORM.include? 'mswin32'
         mime = `file --mime -br #{file.path}`.strip
       else
         mime = EXTENSIONS[File.extname(file.path).gsub('.','').downcase.to_sym]
       end
     elsif file.class == String
       mime = EXTENSIONS[(file[file.rindex('.')+1, file.size]).downcase.to_sym] if not file.rindex('.').nil?
     elsif file.class == StringIO
       temp = File.open(Dir.tmpdir + '/upload_file.' + Process.pid.to_s, "wb")
       temp << file.string
       temp.close
       mime = `file --mime -br #{temp.path}`
       mime = mime.gsub(/^.*: */,"")
       mime = mime.gsub(/;.*$/,"")
       mime = mime.gsub(/,.*$/,"")
{'fraction_non_alphanumeric': 0.18427835051546393, 'fraction_numerical': 0.003865979381443299, 'mean_word_length': 2.376086956521739, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4182074', 'n_tokens_mistral': 572, 'n_tokens_neox': 541, 'n_words': 110}