<commit_before>module GemInstaller
  class GemCommandManager
    attr_writer :gem_spec_manager, :gem_runner_proxy, :gem_interaction_handler
    
    def list_remote_gem(gem, additional_options)
      run_args = ["list",gem.name,"--remote","--details"]
      run_args += additional_options
      @gem_runner_proxy.run(run_args)
    end

    def uninstall_gem(gem)
      return if !@gem_spec_manager.is_gem_installed?(gem)
      @gem_interaction_handler.dependent_gem = gem
      run_gem_command('uninstall', gem, gem.uninstall_options)
    end

    def install_gem(gem)
      return if @gem_spec_manager.is_gem_installed?(gem)
      @gem_interaction_handler.dependent_gem = gem
      run_gem_command('install', gem, gem.install_options)
    end
    
    def dependency(name, version, additional_options = [])
      # rubygems has bug up to 0.9.4 where the pipe options uses 'puts', instead of 'say', so we can't capture it
      # with enhanced_stream_ui.  Patched: http://rubyforge.org/tracker/index.php?func=detail&aid=9020&group_id=126&atid=577
      # TODO: use pipe option on later versions which support it
      run_args = ["dependency",/^#{name}$/,"--version",version]
      run_args += additional_options
      output_lines = @gem_runner_proxy.run(run_args)
      # dependency output has all lines in the first element
      output_array = output_lines[0].split("\n")
      # drop the first line which just echoes the dependent gem
      output_array.shift
      # drop the line containing 'requires' (rubygems < 0.9.0)
      if output_array[0] == '  Requires'
        output_array.shift
      end
      # drop all empty lines
      output_array.reject! { |line| line == "" }
      # strip leading space
      output_array.each { |line| line.strip! }
      # convert into gems
      output_gems = output_array.collect do |line|
        name = line.split(' ')[0]<commit_msg>change dependency command invocation to not be regex (doesn't parse in config_file)<commit_after>module GemInstaller
  class GemCommandManager
    attr_writer :gem_spec_manager, :gem_runner_proxy, :gem_interaction_handler
    
    def list_remote_gem(gem, additional_options)
      run_args = ["list",gem.name,"--remote","--details"]
      run_args += additional_options
      @gem_runner_proxy.run(run_args)
    end

    def uninstall_gem(gem)
      return if !@gem_spec_manager.is_gem_installed?(gem)
      @gem_interaction_handler.dependent_gem = gem
      run_gem_command('uninstall', gem, gem.uninstall_options)
    end

    def install_gem(gem)
      return if @gem_spec_manager.is_gem_installed?(gem)
      @gem_interaction_handler.dependent_gem = gem
      run_gem_command('install', gem, gem.install_options)
    end
    
    def dependency(name, version, additional_options = [])
      # rubygems has bug up to 0.9.4 where the pipe options uses 'puts', instead of 'say', so we can't capture it
      # with enhanced_stream_ui.  Patched: http://rubyforge.org/tracker/index.php?func=detail&aid=9020&group_id=126&atid=577
      # TODO: use pipe option on later versions which support it
      
      run_args = ["dependency","^#{name}$","--version",version]
      run_args += additional_options
      output_lines = @gem_runner_proxy.run(run_args)
      # dependency output has all lines in the first element
      output_array = output_lines[0].split("\n")
      # drop the first line which just echoes the dependent gem
      output_array.shift
      # drop the line containing 'requires' (rubygems < 0.9.0)
      if output_array[0] == '  Requires'
        output_array.shift
      end
      # drop all empty lines
      output_array.reject! { |line| line == "" }
      # strip leading space
      output_array.each { |line| line.strip! }
      # convert into gems
      output_gems = output_array.collect do |line|
        name = line.split(' ')[0]
{'fraction_non_alphanumeric': 0.10028653295128939, 'fraction_numerical': 0.00989841104454285, 'mean_word_length': 3.300111982082867, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2258259', 'n_tokens_mistral': 1205, 'n_tokens_neox': 1166, 'n_words': 290}