Permalink
Browse files

Restore split between require-time and runtime load path mungery. Sim…

…plifies vendor requires.
  • Loading branch information...
1 parent 772a32a commit 0bd6e933c01868db7c7e20d46c972c4e7395b743 @jeremy jeremy committed Sep 25, 2009
@@ -6,7 +6,7 @@ class Builder < TemplateHandler
self.default_format = Mime::XML
def compile(template)
- require 'active_support/vendor/builder'
+ require 'builder'
"xml = ::Builder::XmlMarkup.new(:indent => 2);" +
"self.output_buffer = xml.target!;" +
template.source +
@@ -1,5 +1,5 @@
require 'abstract_unit'
-require 'active_support/vendor/tzinfo'
+require 'tzinfo'
TZInfo::Timezone.cattr_reader :loaded_zones
@@ -35,6 +35,7 @@ def load_all!; load_all_hooks.each { |hook| hook.call } end
end
require 'active_support/autoload'
+require 'active_support/vendor'
-require 'active_support/vendor/i18n'
+require 'i18n'
I18n.load_path << "#{File.dirname(__FILE__)}/active_support/locale/en.yml"
@@ -1,4 +1,4 @@
-require 'active_support/vendor/memcache'
+require 'memcache'
module ActiveSupport
module Cache
@@ -157,7 +157,7 @@ def to_formatted_s(format = :default)
#
def to_xml(options = {})
raise "Not all elements respond to to_xml" unless all? { |e| e.respond_to? :to_xml }
- require 'active_support/vendor/builder' unless defined?(Builder)
+ require 'builder' unless defined?(Builder)
options = options.dup
options[:root] ||= all? { |e| e.is_a?(first.class) && first.class.to_s != "Hash" } ? ActiveSupport::Inflector.pluralize(ActiveSupport::Inflector.underscore(first.class.name)) : "records"
@@ -84,7 +84,7 @@ def to_query(namespace = nil)
alias_method :to_param, :to_query
def to_xml(options = {})
- require 'active_support/vendor/builder' unless defined?(Builder)
+ require 'builder' unless defined?(Builder)
options = options.dup
options[:indent] ||= 2
@@ -6,7 +6,7 @@
# fast_xs extension unavailable
else
begin
- require 'active_support/vendor/builder'
+ require 'builder'
rescue LoadError
# builder demands the first shot at defining String#to_xs
end
@@ -306,7 +306,7 @@ def period_for_local(time, dst=true)
# TODO: Preload instead of lazy load for thread safety
def tzinfo
- require 'active_support/vendor/tzinfo' unless defined?(TZInfo)
+ require 'tzinfo' unless defined?(TZInfo)
@tzinfo ||= TZInfo::Timezone.get(MAPPING[name])
end
@@ -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
@@ -1,7 +0,0 @@
-begin
- gem 'builder', '~> 2.1.2'
-rescue LoadError, NoMethodError
- $LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/builder-2.1.2/lib")
-end
-
-require 'builder'
@@ -1,7 +0,0 @@
-begin
- gem 'i18n', '~> 0.1.3'
-rescue LoadError, NoMethodError
- $LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/i18n-0.1.3/lib")
-end
-
-require 'i18n'
@@ -1,7 +0,0 @@
-begin
- gem 'memcache-client', '~> 1.7.5'
-rescue LoadError, NoMethodError
- $LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/memcache-client-1.7.5/lib")
-end
-
-require 'memcache'
@@ -1,7 +0,0 @@
-begin
- gem 'tzinfo', '~> 0.3.13'
-rescue LoadError, NoMethodError
- $LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/tzinfo-0.3.13/lib")
-end
-
-require 'tzinfo'
@@ -19,7 +19,7 @@
require 'active_support/ruby/shim'
def uses_memcached(test_name)
- require 'active_support/vendor/memcache'
+ require 'memcache'
begin
MemCache.new('localhost').stats
yield

0 comments on commit 0bd6e93

Please sign in to comment.