diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-09-24 23:55:45 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-09-24 23:57:14 -0500 |
commit | bb6ca25d0346f69577d78b15cfeb1238911d2938 (patch) | |
tree | daec409d3e1ed08732b938adc1587748ba9f0618 | |
parent | 018ba2770158c7daaa3f0381d3a8c4e40ccd3232 (diff) | |
download | rails-bb6ca25d0346f69577d78b15cfeb1238911d2938.tar.gz rails-bb6ca25d0346f69577d78b15cfeb1238911d2938.tar.bz2 rails-bb6ca25d0346f69577d78b15cfeb1238911d2938.zip |
Check if the lib is in the load path and requirable before attempting to activate the gem version
-rw-r--r-- | activesupport/lib/active_support/vendor.rb | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/activesupport/lib/active_support/vendor.rb b/activesupport/lib/active_support/vendor.rb index 8ba1dade91..9f464c8246 100644 --- a/activesupport/lib/active_support/vendor.rb +++ b/activesupport/lib/active_support/vendor.rb @@ -1,13 +1,16 @@ +def ActiveSupport.requirable?(file) + $LOAD_PATH.any? { |p| Dir.glob("#{p}/#{file}.*").any? } +end + [%w(builder 2.1.2), %w(i18n 0.1.3), %w(memcache-client 1.7.5), %w(tzinfo 0.3.13)].each do |lib, version| - # Try to activate a gem ~> satisfying the requested version first. - begin - gem lib, "~> #{version}" - # Use the vendored lib if the gem's missing or we aren't using RubyGems. - rescue LoadError, NoMethodError - # Skip if there's already a vendored lib already provided. - if $LOAD_PATH.grep(Regexp.new(lib)).empty? - # Push, not unshift, so the vendored lib is lowest priority. - $LOAD_PATH << File.expand_path("#{File.dirname(__FILE__)}/vendor/#{lib}-#{version}/lib") + # If the lib is not already requirable + unless ActiveSupport.requirable? lib + # Try to activate a gem ~> satisfying the requested version first. + begin + gem lib, "~> #{version}" + # Use the vendored lib if the gem's missing or we aren't using RubyGems. + rescue LoadError, NoMethodError + $LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/vendor/#{lib}-#{version}/lib") end end end |