Permalink
Browse files

Mkexy build require paths so exerb include them properly

mkexy is not aware that Ruby 1.9 expand $LOADED_FEATURES elements and
includes the full path to them.

require_name inside Utility2 tries to find a match of the right $LOAD_PATH
and remove it from the final require name.

It also removes the RUBY_PLATFROM from it so shared libraries are found.
  • Loading branch information...
1 parent fa27231 commit bdcb4923f1919af7dae3cd196c9e37778d5e15ca @luislavena luislavena committed Nov 26, 2011
Showing with 11 additions and 2 deletions.
  1. +11 −2 lib/exerb/utility2.rb
View
@@ -13,7 +13,7 @@ module Exerb::Utility2
def self.loaded_features(reject_list = [])
reject_list << File.expand_path(__FILE__)
- return $".collect { |filename|
+ return $LOADED_FEATURES.collect { |filename|
case filename.downcase
when /\.rb$/o then type = "script"
when /\.so$/o then type = "extension-library"
@@ -22,7 +22,7 @@ def self.loaded_features(reject_list = [])
[type, filename]
}.collect { |type, filename|
if File.exist?(filename)
- [type, filename, filename]
+ [type, require_name(filename), filename]
else
$LOAD_PATH.collect { |dirpath|
[type, filename, File.join(dirpath, filename)]
@@ -37,6 +37,15 @@ def self.loaded_features(reject_list = [])
}
end
+ def self.require_name(filename)
+ path = $LOAD_PATH.find { |path| filename.include?(path) }
+ if path
+ # remove both the path and the platform from the filename
+ return filename.gsub("#{path}/", "").gsub("#{RUBY_PLATFORM}/", "")
+ end
+
+ filename
+ end
end # Exerb::Utility2
#==============================================================================#

0 comments on commit bdcb492

Please sign in to comment.