diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-07-09 23:21:36 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-07-09 23:21:36 +0000 |
commit | 47f0248b0858898dd24d1e654cedf174059ca677 (patch) | |
tree | 493e84160f8609db408d88349f0624a3ff92c3c2 /lib/rubygems.rb | |
parent | cd9f9e471977447a991ced4ea38efb2309459ef5 (diff) | |
download | ruby-47f0248b0858898dd24d1e654cedf174059ca677.tar.gz |
* lib/rubygems: Import RubyGems 2.1
* test/rubygems: Ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems.rb')
-rw-r--r-- | lib/rubygems.rb | 58 |
1 files changed, 55 insertions, 3 deletions
diff --git a/lib/rubygems.rb b/lib/rubygems.rb index 2c8dbee2a2..dfc1006fd4 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -8,7 +8,7 @@ require 'rbconfig' module Gem - VERSION = '2.0.4' + VERSION = '2.1.0' end # Must be first since it unloads the prelude from 1.9.2 @@ -143,6 +143,14 @@ module Gem specifications ] + ## + # Subdirectories in a gem repository for default gems + + REPOSITORY_DEFAULT_GEM_SUBDIRECTORIES = %w[ + gems + specifications/default + ] + @@win_platform = nil @configuration = nil @@ -379,6 +387,10 @@ module Gem paths.path end + def self.spec_cache_dir + paths.spec_cache_dir + end + ## # Quietly ensure the Gem directory +dir+ contains all the proper # subdirectories. If we can't create a directory due to a permission @@ -389,6 +401,23 @@ module Gem # World-writable directories will never be created. def self.ensure_gem_subdirectories dir = Gem.dir, mode = nil + ensure_subdirectories(dir, mode, REPOSITORY_SUBDIRECTORIES) + end + + ## + # Quietly ensure the Gem directory +dir+ contains all the proper + # subdirectories for handling default gems. If we can't create a + # directory due to a permission problem, then we will silently continue. + # + # If +mode+ is given, missing directories are created with this mode. + # + # World-writable directories will never be created. + + def self.ensure_default_gem_subdirectories dir = Gem.dir, mode = nil + ensure_subdirectories(dir, mode, REPOSITORY_DEFAULT_GEM_SUBDIRECTORIES) + end + + def self.ensure_subdirectories dir, mode, subdirs # :nodoc: old_umask = File.umask File.umask old_umask | 002 @@ -398,7 +427,7 @@ module Gem options[:mode] = mode if mode - REPOSITORY_SUBDIRECTORIES.each do |name| + subdirs.each do |name| subdir = File.join dir, name next if File.exist? subdir FileUtils.mkdir_p subdir, options rescue nil @@ -971,10 +1000,33 @@ module Gem attr_reader :loaded_specs ## - # Register a Gem::Specification for default gem + # Register a Gem::Specification for default gem. + # + # Two formats for the specification are supported: + # + # * MRI 2.0 style, where spec.files contains unprefixed require names. + # The spec's filenames will be registered as-is. + # * New style, where spec.files contains files prefixed with paths + # from spec.require_paths. The prefixes are stripped before + # registering the spec's filenames. Unprefixed files are omitted. + # def register_default_spec(spec) + new_format, prefix_pattern = nil + spec.files.each do |file| + if new_format == nil + new_format = spec.require_paths.any? {|path| file.start_with? path} + + prefix_group = spec.require_paths.map {|f| f + "/"}.join("|") + prefix_pattern = /^(#{prefix_group})/ + end + + if new_format + file = file.sub(prefix_pattern, "") + next unless $~ + end + @path_to_default_spec_map[file] = spec end end |