From 0039c0344c54423413728a92509b42fe7f37d90c Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Thu, 24 Sep 2009 17:21:14 -0700 Subject: Avoid inadvertently loading an old tzinfo gem --- activesupport/lib/active_support/vendor.rb | 5 ----- 1 file changed, 5 deletions(-) (limited to 'activesupport/lib/active_support/vendor.rb') diff --git a/activesupport/lib/active_support/vendor.rb b/activesupport/lib/active_support/vendor.rb index 10dbfd9a77..5c79c6a420 100644 --- a/activesupport/lib/active_support/vendor.rb +++ b/activesupport/lib/active_support/vendor.rb @@ -11,11 +11,6 @@ if defined? Gem rescue Gem::LoadError end - begin - gem 'tzinfo', '~> 0.3.13' - rescue Gem::LoadError - end - begin gem 'i18n', '~> 0.1.3' rescue Gem::LoadError -- cgit v1.2.3 From 772a32a22d71f7a22108719d88c94959ae4942b6 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Thu, 24 Sep 2009 17:29:59 -0700 Subject: Convert the other vendored libs to avoid pulling in old gems. Works even if rubygems isn't loaded. --- activesupport/lib/active_support/vendor.rb | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 activesupport/lib/active_support/vendor.rb (limited to 'activesupport/lib/active_support/vendor.rb') diff --git a/activesupport/lib/active_support/vendor.rb b/activesupport/lib/active_support/vendor.rb deleted file mode 100644 index 5c79c6a420..0000000000 --- a/activesupport/lib/active_support/vendor.rb +++ /dev/null @@ -1,18 +0,0 @@ -# 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 'i18n', '~> 0.1.3' - rescue Gem::LoadError - end -end -- cgit v1.2.3 From 0bd6e933c01868db7c7e20d46c972c4e7395b743 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Thu, 24 Sep 2009 18:36:40 -0700 Subject: Restore split between require-time and runtime load path mungery. Simplifies vendor requires. --- activesupport/lib/active_support/vendor.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 activesupport/lib/active_support/vendor.rb (limited to 'activesupport/lib/active_support/vendor.rb') diff --git a/activesupport/lib/active_support/vendor.rb b/activesupport/lib/active_support/vendor.rb new file mode 100644 index 0000000000..d9dfc184da --- /dev/null +++ b/activesupport/lib/active_support/vendor.rb @@ -0,0 +1,10 @@ +[%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 + # Push, not unshift, so the vendored lib is lowest priority. + $LOAD_PATH << File.expand_path("#{File.dirname(__FILE__)}/vendor/#{lib}-#{version}/lib") + end +end -- cgit v1.2.3 From 018ba2770158c7daaa3f0381d3a8c4e40ccd3232 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Thu, 24 Sep 2009 19:10:31 -0700 Subject: Skip addition to load path if an externally-provided lib is already in place. Just to keep the path shorter. --- activesupport/lib/active_support/vendor.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'activesupport/lib/active_support/vendor.rb') diff --git a/activesupport/lib/active_support/vendor.rb b/activesupport/lib/active_support/vendor.rb index d9dfc184da..8ba1dade91 100644 --- a/activesupport/lib/active_support/vendor.rb +++ b/activesupport/lib/active_support/vendor.rb @@ -4,7 +4,10 @@ gem lib, "~> #{version}" # Use the vendored lib if the gem's missing or we aren't using RubyGems. rescue LoadError, NoMethodError - # Push, not unshift, so the vendored lib is lowest priority. - $LOAD_PATH << File.expand_path("#{File.dirname(__FILE__)}/vendor/#{lib}-#{version}/lib") + # 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") + end end end -- cgit v1.2.3 From bb6ca25d0346f69577d78b15cfeb1238911d2938 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Thu, 24 Sep 2009 23:55:45 -0500 Subject: Check if the lib is in the load path and requirable before attempting to activate the gem version --- activesupport/lib/active_support/vendor.rb | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'activesupport/lib/active_support/vendor.rb') 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 -- cgit v1.2.3