aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2009-09-24 18:36:40 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2009-09-24 18:38:18 -0700
commit0bd6e933c01868db7c7e20d46c972c4e7395b743 (patch)
treed91dbf5aaf990748082e42eb772ba049844794a3 /activesupport/lib
parent772a32a22d71f7a22108719d88c94959ae4942b6 (diff)
downloadrails-0bd6e933c01868db7c7e20d46c972c4e7395b743.tar.gz
rails-0bd6e933c01868db7c7e20d46c972c4e7395b743.tar.bz2
rails-0bd6e933c01868db7c7e20d46c972c4e7395b743.zip
Restore split between require-time and runtime load path mungery. Simplifies vendor requires.
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support.rb3
-rw-r--r--activesupport/lib/active_support/cache/mem_cache_store.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/array/conversions.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/hash/conversions.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/string/xchar.rb2
-rw-r--r--activesupport/lib/active_support/values/time_zone.rb2
-rw-r--r--activesupport/lib/active_support/vendor.rb10
-rw-r--r--activesupport/lib/active_support/vendor/builder.rb7
-rw-r--r--activesupport/lib/active_support/vendor/i18n.rb7
-rw-r--r--activesupport/lib/active_support/vendor/memcache.rb7
-rw-r--r--activesupport/lib/active_support/vendor/tzinfo.rb7
11 files changed, 17 insertions, 34 deletions
diff --git a/activesupport/lib/active_support.rb b/activesupport/lib/active_support.rb
index 4444268997..0478ae4ebc 100644
--- a/activesupport/lib/active_support.rb
+++ b/activesupport/lib/active_support.rb
@@ -35,6 +35,7 @@ module ActiveSupport
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"
diff --git a/activesupport/lib/active_support/cache/mem_cache_store.rb b/activesupport/lib/active_support/cache/mem_cache_store.rb
index ea38baa9ad..516af99ce9 100644
--- a/activesupport/lib/active_support/cache/mem_cache_store.rb
+++ b/activesupport/lib/active_support/cache/mem_cache_store.rb
@@ -1,4 +1,4 @@
-require 'active_support/vendor/memcache'
+require 'memcache'
module ActiveSupport
module Cache
diff --git a/activesupport/lib/active_support/core_ext/array/conversions.rb b/activesupport/lib/active_support/core_ext/array/conversions.rb
index 0743ab181e..c53cf3f530 100644
--- a/activesupport/lib/active_support/core_ext/array/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/array/conversions.rb
@@ -157,7 +157,7 @@ class Array
#
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"
diff --git a/activesupport/lib/active_support/core_ext/hash/conversions.rb b/activesupport/lib/active_support/core_ext/hash/conversions.rb
index 1f8bd7cd82..bd9419e1a2 100644
--- a/activesupport/lib/active_support/core_ext/hash/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/hash/conversions.rb
@@ -84,7 +84,7 @@ class Hash
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
diff --git a/activesupport/lib/active_support/core_ext/string/xchar.rb b/activesupport/lib/active_support/core_ext/string/xchar.rb
index 26857c8b0d..7183218634 100644
--- a/activesupport/lib/active_support/core_ext/string/xchar.rb
+++ b/activesupport/lib/active_support/core_ext/string/xchar.rb
@@ -6,7 +6,7 @@ rescue LoadError
# 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
diff --git a/activesupport/lib/active_support/values/time_zone.rb b/activesupport/lib/active_support/values/time_zone.rb
index 4eb268ac7d..564528bfe2 100644
--- a/activesupport/lib/active_support/values/time_zone.rb
+++ b/activesupport/lib/active_support/values/time_zone.rb
@@ -306,7 +306,7 @@ module ActiveSupport
# 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
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
diff --git a/activesupport/lib/active_support/vendor/builder.rb b/activesupport/lib/active_support/vendor/builder.rb
deleted file mode 100644
index 349825f438..0000000000
--- a/activesupport/lib/active_support/vendor/builder.rb
+++ /dev/null
@@ -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'
diff --git a/activesupport/lib/active_support/vendor/i18n.rb b/activesupport/lib/active_support/vendor/i18n.rb
deleted file mode 100644
index 05c03277e3..0000000000
--- a/activesupport/lib/active_support/vendor/i18n.rb
+++ /dev/null
@@ -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'
diff --git a/activesupport/lib/active_support/vendor/memcache.rb b/activesupport/lib/active_support/vendor/memcache.rb
deleted file mode 100644
index 878464f6db..0000000000
--- a/activesupport/lib/active_support/vendor/memcache.rb
+++ /dev/null
@@ -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'
diff --git a/activesupport/lib/active_support/vendor/tzinfo.rb b/activesupport/lib/active_support/vendor/tzinfo.rb
deleted file mode 100644
index 0d47361d97..0000000000
--- a/activesupport/lib/active_support/vendor/tzinfo.rb
+++ /dev/null
@@ -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'