aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/ruby.rb
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Formula/ruby.rb')
-rw-r--r--Library/Formula/ruby.rb74
1 files changed, 61 insertions, 13 deletions
diff --git a/Library/Formula/ruby.rb b/Library/Formula/ruby.rb
index cc2b5da3b..98de87a66 100644
--- a/Library/Formula/ruby.rb
+++ b/Library/Formula/ruby.rb
@@ -4,7 +4,7 @@ class Ruby < Formula
homepage 'https://www.ruby-lang.org/'
url "http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.bz2"
sha256 "6948b02570cdfb89a8313675d4aa665405900e27423db408401473f30fc6e901"
- revision 1
+ revision 2
bottle do
sha1 "9feba2200305e8750c26f83d562b900d31978905" => :mavericks
@@ -60,14 +60,19 @@ class Ruby < Formula
system "./configure", *args
system "make"
system "make install"
+
+ # Customize rubygems to look/install in the global gem directory
+ # instead of in the Cellar, making gems last across reinstalls
+ (lib/"ruby/2.1.0/rubygems/defaults/operating_system.rb").write rubygems_config
end
def post_install
- # Preserve gem, site, and vendor folders on upgrade/reinstall
- # by placing them in HOMEBREW_PREFIX and sym-linking
+ # Preserve site and vendor folders on upgrade/reinstall
+ # by placing them in HOMEBREW_PREFIX and symlinking
ruby_lib = HOMEBREW_PREFIX/"lib/ruby"
- ["gems", "site_ruby", "vendor_ruby"].each do |name|
+ # These directories are empty on install
+ ["site_ruby", "vendor_ruby"].each do |name|
link = lib/"ruby"/name
real = ruby_lib/name
@@ -76,18 +81,61 @@ class Ruby < Formula
real.mkpath
link.unlink if link.exist?
- link.symlink real
+ link.make_symlink real
end
end
- def caveats; <<-EOS.undent
- By default, gem installed executables will be placed into:
- #{opt_bin}
-
- You may want to add this to your PATH. After upgrades, you can run
- gem pristine --all --only-executables
-
- to restore binstubs for installed gems.
+ def rubygems_config; <<-EOS.undent
+ module Gem
+ def self.default_dir
+ path = [
+ "#{HOMEBREW_PREFIX}",
+ "lib",
+ "ruby",
+ "gems",
+ "2.1.0"
+ ]
+
+ @default_dir ||= File.join(*path)
+ end
+
+ def self.private_dir
+ path = if defined? RUBY_FRAMEWORK_VERSION then
+ [
+ File.dirname(RbConfig::CONFIG['sitedir']),
+ 'Gems',
+ RbConfig::CONFIG['ruby_version']
+ ]
+ elsif RbConfig::CONFIG['rubylibprefix'] then
+ [
+ RbConfig::CONFIG['rubylibprefix'],
+ 'gems',
+ RbConfig::CONFIG['ruby_version']
+ ]
+ else
+ [
+ RbConfig::CONFIG['libdir'],
+ ruby_engine,
+ 'gems',
+ RbConfig::CONFIG['ruby_version']
+ ]
+ end
+
+ @private_dir ||= File.join(*path)
+ end
+
+ def self.default_path
+ if Gem.user_home && File.exist?(Gem.user_home)
+ [user_dir, default_dir, private_dir]
+ else
+ [default_dir, private_dir]
+ end
+ end
+
+ def self.default_bindir
+ "#{HOMEBREW_PREFIX}/bin"
+ end
+ end
EOS
end