diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2009-09-30 22:27:02 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-09-30 22:27:02 +0100 |
commit | dd2779e1b83b4d867d47dd286ec0c919f5df12a9 (patch) | |
tree | 6e52ea0a329c24429f4d1d41b065e082f0ed6baa /activesupport/lib/active_support/vendor.rb | |
parent | 329b14aa8fdd291a00d17ba12c2e0ab4c3a157cc (diff) | |
parent | 420004e030e96f2ace6e27fd622c90ee9e986677 (diff) | |
download | rails-dd2779e1b83b4d867d47dd286ec0c919f5df12a9.tar.gz rails-dd2779e1b83b4d867d47dd286ec0c919f5df12a9.tar.bz2 rails-dd2779e1b83b4d867d47dd286ec0c919f5df12a9.zip |
Merge commit 'mainstream/master'
Diffstat (limited to 'activesupport/lib/active_support/vendor.rb')
-rw-r--r-- | activesupport/lib/active_support/vendor.rb | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/activesupport/lib/active_support/vendor.rb b/activesupport/lib/active_support/vendor.rb index 10dbfd9a77..9f464c8246 100644 --- a/activesupport/lib/active_support/vendor.rb +++ b/activesupport/lib/active_support/vendor.rb @@ -1,23 +1,16 @@ -# Fakes out gem optional dependencies until they are fully supported by gemspec. -# Activate any optional dependencies that are available. -if defined? Gem - begin - gem 'builder', '~> 2.1.2' - rescue Gem::LoadError - end - - begin - gem 'memcache-client', '>= 1.6.5' - rescue Gem::LoadError - end - - begin - gem 'tzinfo', '~> 0.3.13' - rescue Gem::LoadError - end +def ActiveSupport.requirable?(file) + $LOAD_PATH.any? { |p| Dir.glob("#{p}/#{file}.*").any? } +end - begin - gem 'i18n', '~> 0.1.3' - rescue Gem::LoadError +[%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| + # 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 |