Created
November 3, 2011 15:45
-
-
Save voxik/1336824 to your computer and use it in GitHub Desktop.
Add dedicate extensions folder into $LOAD_PATH.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 301522f15c42af06f41c560245bd77d212850877 Mon Sep 17 00:00:00 2001 | |
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <[email protected]> | |
Date: Thu, 3 Nov 2011 16:43:05 +0100 | |
Subject: [PATCH] Add dedicate extensions folder into . | |
--- | |
lib/rubygems/specification.rb | 37 ++++++++++++++++++++++++++++++------- | |
1 files changed, 30 insertions(+), 7 deletions(-) | |
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb | |
index 97db19e..263e7d3 100644 | |
--- a/lib/rubygems/specification.rb | |
+++ b/lib/rubygems/specification.rb | |
@@ -843,6 +843,12 @@ class Gem::Specification | |
File.join full_gem_path, path | |
end | |
+ unless extensions.empty? | |
+ paths += require_paths.map do |path| | |
+ File.join ext_dir, path | |
+ end | |
+ end | |
+ | |
# gem directories must come after -I and ENV['RUBYLIB'] | |
insert_index = Gem.load_path_insert_index | |
@@ -954,16 +960,16 @@ class Gem::Specification | |
def contains_requirable_file? file | |
root = full_gem_path | |
+ ext = ext_dir | |
+ | |
+ require_paths.any? do |lib| | |
+ base = ["#{root}/#{lib}/#{file}"] | |
+ base << "#{ext}/#{lib}/#{file}" unless extensions.empty? | |
- require_paths.each do |lib| | |
- base = "#{root}/#{lib}/#{file}" | |
- Gem.suffixes.each do |suf| | |
- path = "#{base}#{suf}" | |
- return true if File.file? path | |
+ base.any? do |path| | |
+ Gem.suffixes.any? { |suf| File.file? "#{path}#{suf}" } | |
end | |
end | |
- | |
- return false | |
end | |
## | |
@@ -1273,6 +1279,23 @@ class Gem::Specification | |
end | |
## | |
+ # Returns the full path to this spec's ext directory. | |
+ # eg: /usr/local/lib/ruby/1.8/exts/mygem-1.0 | |
+ | |
+ def ext_dir | |
+ @gem_dir ||= File.expand_path File.join(exts_dir, full_name) | |
+ end | |
+ | |
+ ## | |
+ # Returns the full path to the exts directory containing this spec's | |
+ # gem directory. eg: /usr/local/lib/ruby/1.8/exts | |
+ | |
+ def exts_dir | |
+ # TODO: this logic seems terribly broken, but tests fail if just base_dir | |
+ @exts_dir ||= File.join(loaded_from && base_dir || Gem.dir, "exts") | |
+ end | |
+ | |
+ ## | |
# Deprecated and ignored, defaults to true. | |
# | |
# Formerly used to indicate this gem was RDoc-capable. | |
-- | |
1.7.7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment