diff options
| author | Mike McQuaid | 2015-01-02 12:42:02 +0000 | 
|---|---|---|
| committer | Mike McQuaid | 2015-01-02 12:42:02 +0000 | 
| commit | 952ffa22701df35a63ec3c7e78ad7dd0086b4bc5 (patch) | |
| tree | eeeaf81b5977ad3afc29ecf6683503169cea5308 | |
| parent | 0f8a9ef9dbbc8d703eca930a2fab7cebf9e9b300 (diff) | |
| download | homebrew-952ffa22701df35a63ec3c7e78ad7dd0086b4bc5.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.
| -rw-r--r-- | Library/Homebrew/cmd/man.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/tests.rb | 10 | ||||
| -rw-r--r-- | Library/Homebrew/utils.rb | 8 | 
3 files changed, 12 insertions, 8 deletions
| diff --git a/Library/Homebrew/cmd/man.rb b/Library/Homebrew/cmd/man.rb index f28d76de1..c1a202156 100644 --- a/Library/Homebrew/cmd/man.rb +++ b/Library/Homebrew/cmd/man.rb @@ -13,7 +13,7 @@ module Homebrew        end      end -    which("ronn") || odie("You need to \"gem install ronn\" and put it in your path.") +    Homebrew.install_gem_setup_path! "ronn"      if ARGV.include?("--server") || ARGV.include?("-s")        puts "Man page test server: http://localhost:1207/" diff --git a/Library/Homebrew/cmd/tests.rb b/Library/Homebrew/cmd/tests.rb index 623c14f04..93f70f8eb 100644 --- a/Library/Homebrew/cmd/tests.rb +++ b/Library/Homebrew/cmd/tests.rb @@ -1,12 +1,8 @@  module Homebrew    def tests -    (HOMEBREW_LIBRARY/'Homebrew/test').cd do -      ENV['TESTOPTS'] = '-v' if ARGV.verbose? -      quiet_system("gem", "list", "--installed", "bundler") || \ -        system("gem", "install", "--no-ri", "--no-rdoc", -               "--user-install", "bundler") -      require 'rubygems' -      ENV["PATH"] = "#{Gem.user_dir}/bin:#{ENV["PATH"]}" +    (HOMEBREW_LIBRARY/"Homebrew/test").cd do +      ENV["TESTOPTS"] = "-v" if ARGV.verbose? +      Homebrew.install_gem_setup_path! "bundler"        quiet_system("bundle", "check") || \          system("bundle", "install", "--path", "vendor/bundle")        system "bundle", "exec", "rake", "test" 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 | 
