Installing and Using a Gem : gem « Development « Ruby






Installing and Using a Gem


require 'rubygems/installer'
require 'rubygems/remote_installer'

def install_gem(gem_name)
  if File.file? gem_name:
    Gem::Installer.new(gem_name).install
  else
    Gem::RemoteInstaller.new.install(gem_name)
  end
end

install_gem('cmdparse')

 








Related examples in the same category

1.Installing RubyInline on Unix-related platforms
2.install rails
3.Finding Libraries by Searching Gem Repositories.rb
4.Loop through gems cache
5.Use gem to get library version
6.Uninstalling a Gem.rb