aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/vendor.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/vendor.rb')
-rw-r--r--activesupport/lib/active_support/vendor.rb33
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