<commit_before>class Pry
  module DefaultCommands

    Gems = Pry::CommandSet.new do

      command "gem-install", "Install a gem and refresh the gem cache." do |gem|
        if gem
          if File.writable? Gem.dir
            installer = Gem::DependencyInstaller.new :install_dir => Gem.dir
            installer.install gem
            output.puts "Gem '#{text.green gem}' installed."
          elsif File.writable? Gem.user_dir 
            installer = Gem::DependencyInstaller.new :install_dir => Gem.user_dir
            installer.install gem
            output.puts "Gem '#{text.green gem}' installed to your user directory"
          else
            output.puts "Insufficient permissions to install `#{text.green gem}`"
          end

          Gem.refresh
        else
          output.puts "A gem name is a required argument."
        end
      end

      command "gem-cd", "Change working directory to specified gem's directory." do |gem|
        if gem
          spec = Gem.source_index.find_name(gem).first
          spec ? Dir.chdir(spec.full_gem_path) : output.puts("Gem `#{gem}` not found.")
        else
          output.puts 'gem-cd requires the name of a gem as an argument.'
        end
      end


      command "gem-list", "List/search installed gems. (Optional parameter: a regexp to limit the search)" do |pattern|
        pattern = Regexp.new pattern.to_s, Regexp::IGNORECASE
        gems = Gem.source_index.gems.values.group_by(&:name)

        gems.each do |gem, specs|
          if gem =~ pattern<commit_msg>Be consistent in error messages.<commit_after>class Pry
  module DefaultCommands

    Gems = Pry::CommandSet.new do

      command "gem-install", "Install a gem and refresh the gem cache." do |gem|
        if gem
          if File.writable? Gem.dir
            installer = Gem::DependencyInstaller.new :install_dir => Gem.dir
            installer.install gem
            output.puts "Gem '#{text.green gem}' installed."
          elsif File.writable? Gem.user_dir 
            installer = Gem::DependencyInstaller.new :install_dir => Gem.user_dir
            installer.install gem
            output.puts "Gem '#{text.green gem}' installed to your user directory"
          else
            output.puts "Insufficient permissions to install `#{text.green gem}`"
          end

          Gem.refresh
        else
          output.puts "gem-install requires the name of a gem as an argument."
        end
      end

      command "gem-cd", "Change working directory to specified gem's directory." do |gem|
        if gem
          spec = Gem.source_index.find_name(gem).first
          spec ? Dir.chdir(spec.full_gem_path) : output.puts("Gem `#{gem}` not found.")
        else
          output.puts 'gem-cd requires the name of a gem as an argument.'
        end
      end


      command "gem-list", "List/search installed gems. (Optional parameter: a regexp to limit the search)" do |pattern|
        pattern = Regexp.new pattern.to_s, Regexp::IGNORECASE
        gems = Gem.source_index.gems.values.group_by(&:name)

        gems.each do |gem, specs|
          if gem =~ pattern
{'fraction_non_alphanumeric': 0.09367982034007058, 'fraction_numerical': 0.0, 'mean_word_length': 2.13682092555332, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4870098', 'n_tokens_mistral': 894, 'n_tokens_neox': 877, 'n_words': 280}