<commit_before>class Pry
  module DefaultCommands

    Gems = Pry::CommandSet.new :gems do

      command "gem-install", "Install a gem and refresh the gem cache." do |gem_name|
        gem_home = Gem.instance_variable_get(:@gem_home)
        output.puts "Attempting to install gem: #{bold(gem_name)}"

        begin
          if File.writable?(gem_home)
            Gem::DependencyInstaller.new.install(gem_name)
            output.puts "Gem #{bold(gem_name)} successfully installed."
          else
            if system("sudo gem install #{gem_name}")
              output.puts "Gem #{bold(gem_name)} successfully installed."
            else
              output.puts "Gem #{bold(gem_name)} could not be installed."
              next
            end
          end
        rescue Gem::GemNotFoundException
          output.puts "Required Gem: #{bold(gem_name)} not found."
          next
        end

        Gem.refresh
        output.puts "Refreshed gem cache."
      end

      command "gem-cd", "Change working directory to specified gem's directory." do |gem_name|
        require 'rubygems'
        gem_spec = Gem.source_index.find_name(gem_name).first
        next output.puts("Gem `#{gem_name}` not found.") if !gem_spec
        Dir.chdir(File.expand_path(gem_spec.full_gem_path))
      end


      command "gem-list", "List/search installed gems. (Optional parameter: a regexp to limit the search)" do |arg|
        gems = Gem.source_index.gems.values.group_by(&:name)
        if arg
          query = Regexp.new(arg, Regexp::IGNORECASE)
          gems = gems.select { |gemname, specs| gemname =~ query }
        end

        gems.each do |gemname, specs|
          versions = specs.map(&:version).sort.reverse.map(&:to_s)
          versions = ["<bright_green>#{versions.first}</bright_green>"] +
            versions[1..-1].map{|v| "<green>#{v}</green>" }

          gemname = highlight(gemname, query) if query
          result = "<white>#{gemname} <grey>(#{versions.join ', '})</grey>"
          output.puts colorize(result)
        end
      end

    end
  end
end<commit_msg>Fix gem-list to work against new API.<commit_after>class Pry
  module DefaultCommands

    Gems = Pry::CommandSet.new :gems do

      command "gem-install", "Install a gem and refresh the gem cache." do |gem_name|
        gem_home = Gem.instance_variable_get(:@gem_home)
        output.puts "Attempting to install gem: #{bold(gem_name)}"

        begin
          if File.writable?(gem_home)
            Gem::DependencyInstaller.new.install(gem_name)
            output.puts "Gem #{bold(gem_name)} successfully installed."
          else
            if system("sudo gem install #{gem_name}")
              output.puts "Gem #{bold(gem_name)} successfully installed."
            else
              output.puts "Gem #{bold(gem_name)} could not be installed."
              next
            end
          end
        rescue Gem::GemNotFoundException
          output.puts "Required Gem: #{bold(gem_name)} not found."
          next
        end

        Gem.refresh
        output.puts "Refreshed gem cache."
      end

      command "gem-cd", "Change working directory to specified gem's directory." do |gem_name|
        require 'rubygems'
        gem_spec = Gem.source_index.find_name(gem_name).first
        next output.puts("Gem `#{gem_name}` not found.") if !gem_spec
        Dir.chdir(File.expand_path(gem_spec.full_gem_path))
      end


      command "gem-list", "List/search installed gems. (Optional parameter: a regexp to limit the search)" do |arg|
        gems = Gem.source_index.gems.values.group_by(&:name)
        if arg
          query = Regexp.new(arg, Regexp::IGNORECASE)
          gems = gems.select { |gemname, specs| gemname =~ query }
        end

        gems.each do |gemname, specs|
          versions = specs.map(&:version).sort.reverse.map(&:to_s)
          versions = ["#{bright_green versions.first}"] + versions[1..-1].map{|v| "#{green v}" }

          gemname = highlight(gemname, query) if query
          output.puts "#{white gemname} (#{grey(versions.join ', ')})"
        end
      end

    end
  end
end
{'fraction_non_alphanumeric': 0.11673528699442964, 'fraction_numerical': 0.0009687575684185032, 'mean_word_length': 2.2570977917981074, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, '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': '5809517', 'n_tokens_mistral': 1264, 'n_tokens_neox': 1230, 'n_words': 313}