<commit_before>module GemInstaller
  class GemRunnerProxy
    attr_writer :gem_runner_class, :gem_cmd_manager_class, :output_listener_class
    attr_writer :options, :enhanced_stream_ui

    def run(args = [], stdin = [])
      gem_runner = @gem_runner_class.new(:command_manager => @gem_cmd_manager_class)
      # We have to manually initialize the configuration here, or else the GemCommandManager singleton
      # will initialize with the (incorrect) default args when we call GemRunner.run.
      gem_runner.do_configuration(args)
      @gem_cmd_manager_class.instance.ui = @enhanced_stream_ui
      
      listener = @output_listener_class.new
      stdout_output_listener = listener
      stderr_output_listener = listener
      if @options[:quiet]
        listener.echo = false
      end
      @enhanced_stream_ui.register_outs_listener(stdout_output_listener)
      @enhanced_stream_ui.register_errs_listener(stderr_output_listener)
      @enhanced_stream_ui.queue_input(stdin)
      exit_status = nil
      begin
        gem_runner.run(args)
      rescue GemInstaller::RubyGemsExit => normal_exit
        exit_status = normal_exit.message
      rescue GemInstaller::GemInstallerError => abnormal_exit
        raise_error_with_output(abnormal_exit.message, listener, args)
      end
      output_lines = listener.read!
      output_lines.push(exit_status) if exit_status
      return output_lines
    end
    
    def raise_error_with_output(exit_status, listener, args)
      args_string = args.join(" ")
      error_message = "\n#{exit_status}\n"
      error_message += "Gem command was:\n  gem #{args_string}\n\n"
      error_message += "Gem command output was:\n"
      error_message += listener.read!.join("\n")
      error_message += "\n\n"
      raise GemInstaller::GemInstallerError.new(error_message)
    end
  end
end
<commit_msg>fix to gem_runner_proxy for rubygems versions prior to 0.9<commit_after>module GemInstaller
  class GemRunnerProxy
    attr_writer :gem_runner_class, :gem_cmd_manager_class, :output_listener_class
    attr_writer :options, :enhanced_stream_ui

    def run(args = [], stdin = [])
      rubygems_version = Gem::RubyGemsVersion
      gem_runner = nil
      if rubygems_version.index('0.8') == 0
        gem_runner = @gem_runner_class.new()
      else
        gem_runner = @gem_runner_class.new(:command_manager => @gem_cmd_manager_class)
      end
      # We have to manually initialize the configuration here, or else the GemCommandManager singleton
      # will initialize with the (incorrect) default args when we call GemRunner.run.
      gem_runner.do_configuration(args)
      @gem_cmd_manager_class.instance.ui = @enhanced_stream_ui
      
      listener = @output_listener_class.new
      stdout_output_listener = listener
      stderr_output_listener = listener
      if @options[:quiet]
        listener.echo = false
      end
      @enhanced_stream_ui.register_outs_listener(stdout_output_listener)
      @enhanced_stream_ui.register_errs_listener(stderr_output_listener)
      @enhanced_stream_ui.queue_input(stdin)
      exit_status = nil
      begin
        gem_runner.run(args)
      rescue GemInstaller::RubyGemsExit => normal_exit
        exit_status = normal_exit.message
      rescue GemInstaller::GemInstallerError => abnormal_exit
        raise_error_with_output(abnormal_exit.message, listener, args)
      end
      output_lines = listener.read!
      output_lines.push(exit_status) if exit_status
      return output_lines
    end
    
    def raise_error_with_output(exit_status, listener, args)
      args_string = args.join(" ")
      error_message = "\n#{exit_status}\n"
      error_message += "Gem command was:\n  gem #{args_string}\n\n"
      error_message += "Gem command output was:\n"
      error_message += listener.read!.join("\n")
      error_message += "\n\n"
      raise GemInstaller::GemInstallerError.new(error_message)
    end
  end
end

{'fraction_non_alphanumeric': 0.0800203873598369, 'fraction_numerical': 0.0012742099898063201, 'mean_word_length': 3.460227272727273, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '2539302', 'n_tokens_mistral': 1194, 'n_tokens_neox': 1167, 'n_words': 239}