aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/utils.rb
diff options
context:
space:
mode:
authorMike McQuaid2015-01-02 12:42:02 +0000
committerMike McQuaid2015-01-02 12:42:02 +0000
commit9e8103cf38f10a4240f0a796bbecdb635dbc74d4 (patch)
treeea272f7fc17ba44240ad8f494d904f0c9c0d8477 /Library/Homebrew/utils.rb
parent81986ee7a75befabd0e4998568349163049b843b (diff)
downloadbrew-9e8103cf38f10a4240f0a796bbecdb635dbc74d4.tar.bz2
Add Homebrew.install_gem_setup_path! function.
This uses the logic from tests.rb in man.rb too so that this can be shared in a few places.
Diffstat (limited to 'Library/Homebrew/utils.rb')
-rw-r--r--Library/Homebrew/utils.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index cafee2025..c7e61e379 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -119,6 +119,14 @@ module Homebrew
def self.git_last_commit
HOMEBREW_REPOSITORY.cd { `git show -s --format="%cr" HEAD 2>/dev/null`.chuzzle }
end
+
+ def self.install_gem_setup_path! gem
+ return if quiet_system "gem", "list", "--installed", gem
+ system "gem", "install", "--no-ri", "--no-rdoc",
+ "--user-install", gem
+ require "rubygems"
+ ENV["PATH"] = "#{Gem.user_dir}/bin:#{ENV["PATH"]}"
+ end
end
def with_system_path