Permalink
Browse files

attempt to bring up to date <sigh>

  • Loading branch information...
1 parent 45ff311 commit 0d2079492b88010c6d427bf8283585e25b4bad7d @rdp committed Feb 18, 2011
Showing with 15 additions and 11 deletions.
  1. +0 −4 bin/fast_require
  2. +8 −6 lib/faster_require.rb
  3. +7 −1 spec/spec.fast_require.rb
View
@@ -1,4 +0,0 @@
-#!/usr/bin/env ruby
-require 'faster_require'
-FastRequire.clear_all!
-puts 'successfully cleared fast_require cache: (' + FastRequire.dir + ')'
View
@@ -1,3 +1,5 @@
+require 'rbconfig'
+
module FastRequire
$FAST_REQUIRE_DEBUG ||= $DEBUG # can set it via $DEBUG, or by itself
@@ -40,28 +42,28 @@ def self.guess_discover partial_name, add_dot_rb = false
if add_dot_rb
tests << partial_name + '.rb'
- tests << partial_name + '.so'
+ tests << partial_name + '.' + RbConfig::CONFIG['DLEXT']
end
tests.each{|b|
# assume that .rb.rb is...valid...
- if File.file?(b) && ((b[-3..-1] == '.rb') || (b[-3..-1] == '.so'))
+ if File.file?(b) && ((b[-3..-1] == '.rb') || (b[-3..-1] == '.' + RbConfig::CONFIG['DLEXT']))
return File.expand_path(b)
end
}
for dir in $:
if File.file?(b = (dir + '/' + partial_name))
# make sure we require a file that has the right suffix...
- if (b[-3..-1] == '.rb') || (b[-3..-1] == '.so')
+ if (b[-3..-1] == '.rb') || (b[-3..-1] == '.' + RbConfig::CONFIG['DLEXT'])
return File.expand_path(b)
end
end
end
- if add_dot_rb && (partial_name[-3..-1] != '.rb') && (partial_name[-3..-1] != '.so')
- guess_discover(partial_name + '.rb') || guess_discover(partial_name + '.so')
+ if add_dot_rb && (partial_name[-3..-1] != '.rb') && (partial_name[-3..-1] != '.' + RbConfig::CONFIG['DLEXT'])
+ guess_discover(partial_name + '.rb') || guess_discover(partial_name + '.')
else
nil
end
@@ -130,7 +132,7 @@ def require_cached lib
if known_loc = @@require_locs[lib]
return false if @@already_loaded[known_loc]
@@already_loaded[known_loc] = true
- if known_loc =~ /.so$/
+ if known_loc =~ /.#{RbConfig::CONFIG['DLEXT']}$/
puts 'doing original_non_cached_require on .so full path ' + known_loc if $FAST_REQUIRE_DEBUG
original_non_cached_require known_loc # not much we can do there...too bad...
else
@@ -10,8 +10,14 @@
require_relative '../lib/faster_require'
cached = '.cached_spec_locs' + RUBY_VERSION
# use it for our own local test specs
+ begin
+ require 'spec/autorun'
+ rescue LoadError
+ # rspec 2
+ require 'rspec'
+ end
+ # TODO rspec can't load? huh? what the...
FastRequire.load cached if File.exist? cached
- require 'spec/autorun'
FastRequire.save cached
else

0 comments on commit 0d20794

Please sign in to comment.