aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rubygems.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-21 23:27:30 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-21 23:27:30 +0000
commit5307d803f5cce7b14a6afd1d51f6d53ec85ca87d (patch)
treeaac2997a9ff000fbf2f1f9f27077bb7b2403f2c9 /lib/rubygems.rb
parentb1529a30e08040b717adef8ac1fa8be1c060e7e1 (diff)
downloadruby-5307d803f5cce7b14a6afd1d51f6d53ec85ca87d.tar.gz
* lib/rubygems: Update to RubyGems master 50a8210. Important changes
in this commit: RubyGems now automatically checks for gem.deps.rb or Gemfile when running ruby executables. This behavior is similar to `bundle exec rake`. This change may be reverted before Ruby 2.1.0 if too many bugs are found. * test/rubygems: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43767 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems.rb')
-rw-r--r--lib/rubygems.rb99
1 files changed, 55 insertions, 44 deletions
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index 2e8ad7bba1..a6c97ed16d 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -215,50 +215,6 @@ module Gem
end
end
- def self.detect_gemdeps
- if path = ENV['RUBYGEMS_GEMDEPS']
- path = path.dup.untaint
-
- if path == "-"
- here = Dir.pwd.untaint
- start = here
-
- begin
- while true
- path = GEM_DEP_FILES.find { |f| File.file?(f) }
-
- if path
- path = File.join here, path
- break
- end
-
- Dir.chdir ".."
-
- # If we're at a toplevel, stop.
- return if Dir.pwd == here
-
- here = Dir.pwd
- end
- ensure
- Dir.chdir start
- end
- end
-
- path.untaint
-
- return unless File.file? path
-
- rs = Gem::RequestSet.new
- rs.load_gemdeps path
-
- rs.resolve_current.map do |s|
- sp = s.full_spec
- sp.activate
- sp
- end
- end
- end
-
##
# Find the full path to the executable for gem +name+. If the +exec_name+
# is not given, the gem's default_executable is chosen, otherwise the
@@ -1035,6 +991,61 @@ module Gem
load_plugin_files files
end
+ ##
+ # Looks for gem dependency files (gem.deps.rb, Gemfile, Isolate) from the
+ # current directory up and activates the gems in the first file found.
+ #
+ # This is run automatically when rubygems starts. To disable, set
+ # the <code>RUBYGEMS_GEMDEPS=</code> environment variable to an empty
+ # string.
+
+ def self.use_gemdeps
+ return unless path = ENV['RUBYGEMS_GEMDEPS'] || '-'
+ path = path.dup.untaint
+
+ if path == "-"
+ here = Dir.pwd.untaint
+ start = here
+
+ begin
+ while true
+ path = GEM_DEP_FILES.find { |f| File.file?(f) }
+
+ if path
+ path = File.join here, path
+ break
+ end
+
+ Dir.chdir ".."
+
+ # If we're at a toplevel, stop.
+ return if Dir.pwd == here
+
+ here = Dir.pwd
+ end
+ ensure
+ Dir.chdir start
+ end
+ end
+
+ path.untaint
+
+ return unless File.file? path
+
+ rs = Gem::RequestSet.new
+ rs.load_gemdeps path
+
+ rs.resolve_current.map do |s|
+ sp = s.full_spec
+ sp.activate
+ sp
+ end
+ end
+
+ class << self
+ alias detect_gemdeps use_gemdeps # :nodoc:
+ end
+
# FIX: Almost everywhere else we use the `def self.` way of defining class
# methods, and then we switch over to `class << self` here. Pick one or the
# other.