Sha256: 25f67a9e8f561638d18ad8e1ba1cfc1768f1979ef045365dd594d0a08ef257eb

Contents?: true

Size: 1.52 KB

Versions: 77

Compression:

Stored size: 1.52 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)

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

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

      gems_to_install.each do |g|
        next if Rubygem.installed?(g)
        output.puts "Installing `#{g}` gem..."

        begin
          Gem::DependencyInstaller.new.install(g)
        rescue Gem::GemNotFoundException
          raise CommandError, "Required Gem: `#{g}` not found. Aborting command installation."
        end
      end

      Gem.refresh
      gems_to_install.each do |g|
        begin
          require g
        rescue LoadError
          raise CommandError, "Required Gem: `#{g}` installed but not found?!. Aborting command installation."
        end
      end

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

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

Version data entries

77 entries across 77 versions & 5 rubygems

Version Path
asana2flowdock-1.0.0 vendor/bundle/ruby/1.9.1/gems/pry-0.9.12.6/lib/pry/commands/install_command.rb
pry-0.9.12.6 lib/pry/commands/install_command.rb
pry-0.9.12.6-i386-mswin32 lib/pry/commands/install_command.rb
pry-0.9.12.6-i386-mingw32 lib/pry/commands/install_command.rb
pry-0.9.12.6-java lib/pry/commands/install_command.rb
pry-0.9.12.5 lib/pry/commands/install_command.rb
pry-0.9.12.5-i386-mswin32 lib/pry/commands/install_command.rb
pry-0.9.12.5-i386-mingw32 lib/pry/commands/install_command.rb
pry-0.9.12.5-java lib/pry/commands/install_command.rb
pry-0.9.12.4 lib/pry/commands/install_command.rb
pry-0.9.12.4-i386-mswin32 lib/pry/commands/install_command.rb
pry-0.9.12.4-i386-mingw32 lib/pry/commands/install_command.rb
pry-0.9.12.4-java lib/pry/commands/install_command.rb
pry-0.9.12.3 lib/pry/commands/install_command.rb
pry-0.9.12.3-i386-mswin32 lib/pry/commands/install_command.rb
pry-0.9.12.3-i386-mingw32 lib/pry/commands/install_command.rb
pry-0.9.12.3-java lib/pry/commands/install_command.rb
torquebox-console-0.3.0 vendor/bundle/jruby/1.9/gems/pry-0.9.12-java/lib/pry/commands/install_command.rb
sshp-0.0.2 vendor/ruby/1.9.1/gems/pry-0.9.12.2/lib/pry/commands/install_command.rb
sshp-0.0.1 vendor/ruby/1.9.1/gems/pry-0.9.12.2/lib/pry/commands/install_command.rb