<commit_before># -*- encoding: utf-8 -*-

module TTY
  class System

    # A class responsible for finding an executable in the PATH
    class Which

      attr_reader :command

      # Initialize a Which
      #
      # @param [String] command
      #   the command to find
      #
      # @api public
      def initialize(command)
        @command = command
      end

      # Find an executable in the PATH
      #
      # @param [String] command
      #   the command to search in the PATH
      #
      # @example
      #   which("ruby")  # => /usr/local/bin/ruby
      #
      # @return [String]
      #   the full path to executable if found, `nil` otherwise
      #
      # @api public
      def which
        exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
        default_system_path.each do |path|
          exts.each do |ext|
            exec = File.join("#{path}", "#{command}#{ext}")
            return exec if File.executable? exec
          end
        end
        return nil
      end

      # Find default system paths
      #
      # @api private
      def default_system_path
        ENV['PATH'].split(File::PATH_SEPARATOR)
      end

    end # Which
  end # System
end # TTY
<commit_msg>Clean up system which command.<commit_after># encoding: utf-8

module TTY
  class System
    # A class responsible for finding an executable in the PATH
    class Which
      # The command to find
      attr_reader :command

      # Initialize a Which
      #
      # @param [String] command
      #   the command to find
      #
      # @api public
      def initialize(command)
        @command = command
      end

      # Find an executable in the PATH
      #
      # @param [String] command
      #   the command to search in the PATH
      #
      # @example
      #   which("ruby")  # => /usr/local/bin/ruby
      #
      # @return [String]
      #   the full path to executable if found, `nil` otherwise
      #
      # @api public
      def which
        exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
        default_system_path.each do |path|
          exts.each do |ext|
            exec = File.join("#{path}", "#{command}#{ext}")
            return exec if File.executable? exec
          end
        end
        nil
      end

      # Find default system paths
      #
      # @api private
      def default_system_path
        ENV['PATH'].split(File::PATH_SEPARATOR)
      end
    end # Which
  end # System
end # TTY

{'fraction_non_alphanumeric': 0.09995936611133685, 'fraction_numerical': 0.0008126777732629012, 'mean_word_length': 1.7025246981339188, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7425401', 'n_tokens_mistral': 740, 'n_tokens_neox': 712, 'n_words': 227}