<commit_before>require 'rbconfig'

class Netrc
  VERSION = "0.7.7"

  # see http://stackoverflow.com/questions/4871309/what-is-the-correct-way-to-detect-if-ruby-is-running-on-windows
  WINDOWS = RbConfig::CONFIG["host_os"] =~ /mswin|mingw|cygwin/
  CYGWIN  = RbConfig::CONFIG["host_os"] =~ /cygwin/

  def self.default_path
    if WINDOWS && !CYGWIN
      File.join(ENV['USERPROFILE'].gsub("\\","/"), "_netrc")
    else
      File.join((ENV["HOME"] || "./"), ".netrc")
    end
  end

  def self.config
    @config ||= {}
  end

  def self.configure
    yield(self.config) if block_given?
    self.config
  end

  def self.check_permissions(path)
    perm = File.stat(path).mode & 0777
    if perm != 0600 && !(WINDOWS) && !(Netrc.config[:allow_permissive_netrc_file])
      raise Error, "Permission bits for '#{path}' should be 0600, but are "+perm.to_s(8)
    end<commit_msg>Fixed Errno::EACCES<commit_after>require 'rbconfig'

class Netrc
  VERSION = "0.7.7"

  # see http://stackoverflow.com/questions/4871309/what-is-the-correct-way-to-detect-if-ruby-is-running-on-windows
  WINDOWS = RbConfig::CONFIG["host_os"] =~ /mswin|mingw|cygwin/
  CYGWIN  = RbConfig::CONFIG["host_os"] =~ /cygwin/

  def self.default_path
    if WINDOWS && !CYGWIN
      File.join(ENV['USERPROFILE'].gsub("\\","/"), "_netrc")
    else
      # In some cases, people run master process as "root" user, and run worker processes as "www" user.
      # Fix "Permission denied" error in worker processes when $HOME is "/root".
      default_dir = (ENV['HOME'] && File.exists?(ENV['HOME']) && File.stat(ENV['HOME']).readable?) ? ENV['HOME'] : './'
      File.join(default_dir, ".netrc")
    end
  end

  def self.config
    @config ||= {}
  end

  def self.configure
    yield(self.config) if block_given?
    self.config
  end

  def self.check_permissions(path)
    perm = File.stat(path).mode & 0777
    if perm != 0600 && !(WINDOWS) && !(Netrc.config[:allow_permissive_netrc_file])
      raise Error, "Permission bits for '#{path}' should be 0600, but are "+perm.to_s(8)
    end
{'fraction_non_alphanumeric': 0.1665043816942551, 'fraction_numerical': 0.022395326192794548, 'mean_word_length': 3.400428265524625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, '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': '2299140', 'n_tokens_mistral': 784, 'n_tokens_neox': 737, 'n_words': 153}