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.'
|
2012-08-11 21:26:59 -04:00
|
|
|
command_options :argument_required => true
|
|
|
|
|
2013-01-09 15:23:19 -05:00
|
|
|
banner <<-'BANNER'
|
2012-08-11 20:22:29 -04:00
|
|
|
Usage: gem-install GEM_NAME
|
|
|
|
|
2013-01-09 15:23:19 -05:00
|
|
|
Installs the given gem and refreshes the gem cache so that you can immediately
|
|
|
|
'require GEM_FILE'.
|
|
|
|
|
|
|
|
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)
|
|
|
|
output.puts "Gem `#{ text.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
|