2012-08-11 20:22:29 -04:00
|
|
|
class Pry
|
2012-12-25 16:35:17 -05:00
|
|
|
class Command::GemInstall < Pry::ClassCommand
|
|
|
|
match 'gem-install'
|
2012-08-11 21:26:59 -04:00
|
|
|
group 'Gems'
|
2012-12-25 16:35:17 -05:00
|
|
|
description 'Install a gem and refresh the gem cache.'
|
2018-10-12 15:09:29 -04:00
|
|
|
command_options argument_required: true
|
2012-08-11 21:26:59 -04:00
|
|
|
|
2013-01-09 15:23:19 -05:00
|
|
|
banner <<-'BANNER'
|
2012-08-11 20:22:29 -04:00
|
|
|
Usage: gem-install GEM_NAME
|
|
|
|
|
2014-03-31 15:19:14 -04:00
|
|
|
Installs the given gem, refreshes the gem cache, and requires the gem for you
|
|
|
|
based on a best guess from the gem name.
|
2013-01-09 15:23:19 -05:00
|
|
|
|
|
|
|
gem-install pry-stack_explorer
|
2012-08-11 20:22:29 -04:00
|
|
|
BANNER
|
|
|
|
|
|
|
|
def setup
|
|
|
|
require 'rubygems/dependency_installer' unless defined? Gem::DependencyInstaller
|
|
|
|
end
|
|
|
|
|
|
|
|
def process(gem)
|
2013-01-08 18:27:27 -05:00
|
|
|
Rubygem.install(gem)
|
2017-11-16 11:54:14 -05:00
|
|
|
output.puts "Gem `#{ green(gem) }` installed."
|
2014-03-31 14:57:02 -04:00
|
|
|
require gem
|
|
|
|
rescue LoadError
|
2014-03-31 14:44:43 -04:00
|
|
|
require_path = gem.split('-').join('/')
|
|
|
|
require require_path
|
2012-08-11 20:22:29 -04:00
|
|
|
end
|
|
|
|
end
|
2012-12-25 16:35:17 -05:00
|
|
|
|
|
|
|
Pry::Commands.add_command(Pry::Command::GemInstall)
|
2012-08-11 20:22:29 -04:00
|
|
|
end
|