diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-16 00:14:16 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-16 00:14:16 +0000 |
commit | 28918eac58eb6e2681d10839ac0d1430b2a4f1f9 (patch) | |
tree | 3c2c9e36118efe1d9406acdd14c186788879bea3 /lib/rubygems/basic_specification.rb | |
parent | cfe1458078b8cf36e490c516977c52e1faa9e88a (diff) | |
download | ruby-28918eac58eb6e2681d10839ac0d1430b2a4f1f9.tar.gz |
* lib/rubygems: Update to RubyGems master commit 2a74263. This fixes
several bugs in RubyGems 2.2.0.preview.1.
* test/rubygems: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43298 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/basic_specification.rb')
-rw-r--r-- | lib/rubygems/basic_specification.rb | 74 |
1 files changed, 69 insertions, 5 deletions
diff --git a/lib/rubygems/basic_specification.rb b/lib/rubygems/basic_specification.rb index 24bb4bc014..5afa7ee14c 100644 --- a/lib/rubygems/basic_specification.rb +++ b/lib/rubygems/basic_specification.rb @@ -38,11 +38,12 @@ class Gem::BasicSpecification # Return true if this spec can require +file+. def contains_requirable_file? file - root = full_gem_path + build_extensions + suffixes = Gem.suffixes - require_paths.any? do |lib| - base = "#{root}/#{lib}/#{file}" + full_require_paths.any? do |dir| + base = "#{dir}/#{file}" suffixes.any? { |suf| File.file? "#{base}#{suf}" } end end @@ -52,6 +53,27 @@ class Gem::BasicSpecification File.dirname(loaded_from) == self.class.default_specifications_dir end + ## + # The directory the named +extension+ was installed into after being built. + # + # Usage: + # + # spec.extensions.each do |ext| + # puts spec.extension_install_dir ext + # end + + def extension_install_dir + ruby_api_version = + if 'no' == RbConfig::CONFIG['ENABLE_SHARED'] then + "#{Gem.ruby_api_version}-static" + else + Gem.ruby_api_version + end + + File.join base_dir, 'extensions', Gem::Platform.local.to_s, + ruby_api_version, full_name + end + def find_full_gem_path # :nodoc: # TODO: also, shouldn't it default to full_name if it hasn't been written? path = File.expand_path File.join(gems_dir, full_name) @@ -84,6 +106,28 @@ class Gem::BasicSpecification end ## + # Full paths in the gem to add to <code>$LOAD_PATH</code> when this gem is + # activated. + + def full_require_paths + full_paths = @require_paths.map do |path| + File.join full_gem_path, path + end + + full_paths << extension_install_dir unless @extensions.empty? + + full_paths + end + + ## + # Returns the full path to this spec's gem directory. + # eg: /usr/local/lib/ruby/1.8/gems/mygem-1.0 + + def gem_dir + @gem_dir ||= File.expand_path File.join(gems_dir, full_name) + end + + ## # Returns the full path to the gems directory containing this spec's # gem directory. eg: /usr/local/lib/ruby/1.8/gems @@ -119,10 +163,30 @@ class Gem::BasicSpecification end ## - # Require paths of the gem + # Paths in the gem to add to <code>$LOAD_PATH</code> when this gem is + # activated. + # + # See also #require_paths= + # + # If you have an extension you do not need to add <code>"ext"</code> to the + # require path, the extension build process will copy the extension files + # into "lib" for you. + # + # The default value is <code>"lib"</code> + # + # Usage: + # + # # If all library files are in the root directory... + # spec.require_path = '.' def require_paths - raise NotImplementedError + return @require_paths if @extensions.empty? + + relative_extension_install_dir = + File.join '..', '..', '..', 'extensions', Gem::Platform.local.to_s, + Gem.ruby_api_version, full_name + + @require_paths + [relative_extension_install_dir] end ## |