Sha256: a1e40e13c3bb892004f03689d6a37447ec8ed538f263e5435689e5600365b300

Contents?: true

Size: 1.58 KB

Versions: 15

Compression:

Stored size: 1.58 KB

Contents

class Pry
  class Command::InstallCommand < Pry::ClassCommand
    match 'install-command'
    group 'Commands'
    description 'Install a disabled command.'

    banner <<-'BANNER'
      Usage: install-command COMMAND

      Installs the gems necessary to run the given COMMAND. You will generally not
      need to run this unless told to by an error message.
    BANNER

    def process(name)
      require 'rubygems/dependency_installer' unless defined? Gem::DependencyInstaller
      command = find_command(name)

      unless command
        output.puts "Command #{ green(name) } is not found"
        return
      end

      if command_dependencies_met?(command.options)
        output.puts "Dependencies for #{ green(name) } are met. Nothing to do"
        return
      end

      output.puts "Attempting to install #{ green(name) } command..."
      gems_to_install = Array(command.options[:requires_gem])

      gems_to_install.each do |g|
        next if Rubygem.installed?(g)

        output.puts "Installing #{ green(g) } gem..."
        Rubygem.install(g)
      end

      gems_to_install.each do |g|
        begin
          require g
        rescue LoadError
          fail_msg = "Required gem #{ green(g) } installed but not found."
          fail_msg += " Aborting command installation\n"
          fail_msg += 'Tips: 1. Check your PATH; 2. Run `bundle update`'
          raise CommandError, fail_msg
        end
      end

      output.puts "Installation of #{ green(name) } successful! Type `help #{name}` for information"
    end
  end

  Pry::Commands.add_command(Pry::Command::InstallCommand)
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/install_command.rb
symbolic_enum-1.1.5 vendor/bundle/ruby/2.7.0/gems/pry-0.12.2/lib/pry/commands/install_command.rb
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/pry-0.12.2/lib/pry/commands/install_command.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/pry-0.12.2/lib/pry/commands/install_command.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/pry-0.12.2/lib/pry/commands/install_command.rb
chess_engine-0.0.2 vendor/bundle/gems/pry-0.12.2/lib/pry/commands/install_command.rb
chess_engine-0.0.1 vendor/bundle/gems/pry-0.12.2/lib/pry/commands/install_command.rb
alimentos-alu0100945645-0.1.0 vendor/bundle/ruby/2.3.0/gems/pry-0.12.2/lib/pry/commands/install_command.rb
alimentos-alu0100945645-1.0.0 vendor/bundle/ruby/2.3.0/gems/pry-0.12.2/lib/pry/commands/install_command.rb
pry-0.12.2-java lib/pry/commands/install_command.rb
pry-0.12.2 lib/pry/commands/install_command.rb
pry-0.12.1 lib/pry/commands/install_command.rb
pry-0.12.1-java lib/pry/commands/install_command.rb
pry-0.12.0 lib/pry/commands/install_command.rb
pry-0.12.0-java lib/pry/commands/install_command.rb