Created
July 21, 2012 03:18
-
-
Save adamjmurray/3154437 to your computer and use it in GitHub Desktop.
Revisions
-
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ # Environment, set GEM_HOME & GEM_PATH. For example, we can launch JRuby like this: # GEM_HOME=/Users/amurray/tmp/gems/ GEM_PATH=/Users/amurray/tmp/gems java -jar ~/Downloads/jruby-complete-1.7.0.preview1.jar -S irb # ===================== # LISTING gems puts Gem::Specification.find_all.to_s puts Gem::Specification.find_all.map{|spec| "#{spec.name} (#{spec.version})" } # ===================== # USING (a specific version of) gems gem 'rake', '0.9.0' require 'rake' # ==================== # INSTALLING gems require 'rubygems/commands/install_command' cmd = Gem::Commands::InstallCommand.new cmd.handle_options ["--no-ri", "--no-rdoc", 'rake', '--version', '0.9'] # or omit --version and the following option to install the latest begin cmd.execute rescue Gem::SystemExitException => e puts "DONE: #{e.exit_code}" end # ===================== # UNINSTALLING gems require 'rubygems/commands/uninstall_command' cmd = Gem::Commands::UninstallCommand.new cmd.handle_options ['-x', '-I', 'jasmine'] # -x removes executables without prompting. -I ignores dependecies. Can also uninstall specific versions... cmd.execute # ===================== # UPDATING a gem to latest version require 'rubygems/commands/update_command' cmd = Gem::Commands::UpdateCommand.new cmd.handle_options ['--no-rdoc', '--no-ri', 'rake'] cmd.execute