<commit_before>module RProgram
  module Compat
    #
    # Returns the native _platform_.
    #
    #   Compat.arch  #=> "linux"
    #
    def Compat.platform
      RUBY_PLATFORM.split('-').last
    end

    #
    # Returns an array representing the +PATH+ environment variable.
    # If the +PATH+ environment variable is not setup, an empty array will
    # be returned.
    #
    #   Compat.paths #=> ["/bin", "/usr/bin"]
    #
    def Compat.paths
      # return an empty array in case
      # the PATH variable does not exist
      return [] unless ENV['PATH']

      if Compat.platform =~ /mswin(32|64)/
        return ENV['PATH'].split(';')
      else
        return ENV['PATH'].split(':')
      end
    end

    #
    # Finds the program matching _name_ and returns it's full path.
    # If the program was not found, +nil+ will be returned.
    #
    #   Compat.find_program('as')  #=> "/usr/bin/as"
    #
    def Compat.find_program(name)
      Compat.paths.each do |dir|
        full_path = File.expand_path(File.join(dir,name))

        return full_path if File.file?(full_path)
      end

      return nil
    end

    #
    # Finds the program matching one of the names within _names_ and
    # returns it's full path. If no program was found matching any of
    # the names, the +nil+ will be returned.
    #
    #   Compat.find_program_by_names("gas","as")  #=> "/usr/bin/as"
    #
    def Compat.find_program_by_names(*names)
      names.map { |name| Compat.find_program(name) }.compact.first
    end
  end
end<commit_msg>Added YARD tags to RProgram::Compat.<commit_after>module RProgram
  module Compat
    #
    # Determines the native platform.
    #
    # @return [String] The native platform.
    #
    # @example
    #   Compat.arch  #=> "linux"
    #
    def Compat.platform
      RUBY_PLATFORM.split('-').last
    end

    #
    # Determines the contents of the +PATH+ environment variable.
    #
    # @return [Array] The contents of the +PATH+ environment variable.
    #
    # @example
    #   Compat.paths #=> ["/bin", "/usr/bin"]
    #
    def Compat.paths
      # return an empty array in case
      # the PATH variable does not exist
      return [] unless ENV['PATH']

      if Compat.platform =~ /mswin(32|64)/
        return ENV['PATH'].split(';')
      else
        return ENV['PATH'].split(':')
      end
    end

    #
    # Finds the full-path of the program with the matching name.
    #
    # @param [String] name The name of the program to find.
    #
    # @return [String, nil] The full-path of the desired program.
    #
    # @example
    #   Compat.find_program('as')  #=> "/usr/bin/as"
    #
    def Compat.find_program(name)
      Compat.paths.each do |dir|
        full_path = File.expand_path(File.join(dir,name))

        return full_path if File.file?(full_path)
      end

      return nil
    end

    #
    # Finds the program matching one of the matching names.
    #
    # @param [Array] names The names of the program to use while
    #                      searching for the program.
    #
    # @return [String, nil] The first full-path for the program.
    #
    # @example
    #   Compat.find_program_by_names("gas","as")  #=> "/usr/bin/as"
    #
    def Compat.find_program_by_names(*names)
      names.map { |name| Compat.find_program(name) }.compact.first
    end
  end
end
{'fraction_non_alphanumeric': 0.11560347409404013, 'fraction_numerical': 0.002395926924228811, 'mean_word_length': 2.1839847473784557, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '317731', 'n_tokens_mistral': 1094, 'n_tokens_neox': 1059, 'n_words': 307}