Sha256: 49d07a6a343a064bab50ed5a2742e7f626e3f5d0d68647c95c51dc1fdd83cc6e

Contents?: true

Size: 896 Bytes

Versions: 15

Compression:

Stored size: 896 Bytes

Contents

class Pry
  class Command::GemList < Pry::ClassCommand
    match 'gem-list'
    group 'Gems'
    description 'List and search installed gems.'

    banner <<-'BANNER'
      Usage: gem-list [REGEX]

      List all installed gems, when a regex is provided, limit the output to those
      that match the regex.
    BANNER

    def process(pattern = nil)
      pattern = Regexp.compile(pattern || '')
      gems    = Rubygem.list(pattern).group_by(&:name)

      gems.each do |gem, specs|
        specs.sort! do |a,b|
          Gem::Version.new(b.version) <=> Gem::Version.new(a.version)
        end

        versions = specs.each_with_index.map do |spec, index|
          index == 0 ? bright_green(spec.version.to_s) : green(spec.version.to_s)
        end

        output.puts "#{default gem} (#{versions.join ', '})"
      end
    end
  end

  Pry::Commands.add_command(Pry::Command::GemList)
end

Version data entries

15 entries across 15 versions & 7 rubygems

Version Path
argon-1.3.1 vendor/bundle/ruby/2.7.0/gems/pry-0.12.2/lib/pry/commands/gem_list.rb
symbolic_enum-1.1.5 vendor/bundle/ruby/2.7.0/gems/pry-0.12.2/lib/pry/commands/gem_list.rb
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/pry-0.12.2/lib/pry/commands/gem_list.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/pry-0.12.2/lib/pry/commands/gem_list.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/pry-0.12.2/lib/pry/commands/gem_list.rb
chess_engine-0.0.2 vendor/bundle/gems/pry-0.12.2/lib/pry/commands/gem_list.rb
chess_engine-0.0.1 vendor/bundle/gems/pry-0.12.2/lib/pry/commands/gem_list.rb
alimentos-alu0100945645-0.1.0 vendor/bundle/ruby/2.3.0/gems/pry-0.12.2/lib/pry/commands/gem_list.rb
alimentos-alu0100945645-1.0.0 vendor/bundle/ruby/2.3.0/gems/pry-0.12.2/lib/pry/commands/gem_list.rb
pry-0.12.2-java lib/pry/commands/gem_list.rb
pry-0.12.2 lib/pry/commands/gem_list.rb
pry-0.12.1 lib/pry/commands/gem_list.rb
pry-0.12.1-java lib/pry/commands/gem_list.rb
pry-0.12.0 lib/pry/commands/gem_list.rb
pry-0.12.0-java lib/pry/commands/gem_list.rb