Permalink
Browse files

Rollback AS bundler work and improve activation of vendored dependencies

  • Loading branch information...
1 parent 6f9e449 commit b2f0b8cbda74cc89834b2db749fb0fbe44f5d8f2 @josh josh committed Sep 14, 2009
View
@@ -9,12 +9,6 @@ only :test do
gem "mocha"
gem "sqlite3-ruby"
gem "RedCloth"
-
- activesupport_vendor = rails_root.join('activesupport', 'lib', 'active_support', 'vendor')
-
- gem 'builder', '2.1.2', :vendored_at => activesupport_vendor.join('builder-2.1.2')
- gem 'memcache-client', '1.6.5', :vendored_at => activesupport_vendor.join('memcache-client-1.6.5')
- gem 'tzinfo', '0.3.13', :vendored_at => activesupport_vendor.join('tzinfo-0.3.13')
end
disable_system_gems
@@ -6,7 +6,7 @@ class Builder < TemplateHandler
self.default_format = Mime::XML
def compile(template)
- require 'builder'
+ require 'active_support/vendor/builder'
"xml = ::Builder::XmlMarkup.new(:indent => 2);" +
"self.output_buffer = xml.target!;" +
template.source +
@@ -7,7 +7,7 @@
$:.unshift(File.dirname(__FILE__) + '/fixtures/alternate_helpers')
require 'bundler_helper'
-ensure_requirable %w( rack rack/test sqlite3 builder memcache tzinfo )
+ensure_requirable %w( rack rack/test sqlite3 )
ENV['TMPDIR'] = File.join(File.dirname(__FILE__), 'tmp')
@@ -1,5 +1,5 @@
require 'abstract_unit'
-require 'tzinfo'
+require 'active_support/vendor/tzinfo'
TZInfo::Timezone.cattr_reader :loaded_zones
View
@@ -1,18 +0,0 @@
-lib_dir = Pathname.new(File.dirname(__FILE__)).join('lib')
-vendor_dir = lib_dir.join('active_support', 'vendor')
-
-# gem 'builder', '~> 2.1.2'
-# gem 'memcache-client', '>= 1.6.5'
-# gem 'tzinfo', '~> 0.3.13'
-# gem 'i18n', '~> 0.1.3'
-
-gem 'builder', '2.1.2', :vendored_at => vendor_dir.join('builder-2.1.2')
-gem 'memcache-client', '1.6.5', :vendored_at => vendor_dir.join('memcache-client-1.6.5')
-gem 'tzinfo', '0.3.13', :vendored_at => vendor_dir.join('tzinfo-0.3.13')
-gem 'i18n', '0.1.3', :vendored_at => vendor_dir.join('i18n-0.1.3')
-
-only :test do
- gem 'mocha', '>= 0.9.7'
-end
-
-disable_rubygems
@@ -37,11 +37,5 @@ def load_all!; load_all_hooks.each { |hook| hook.call } end
require 'active_support/autoload'
require 'active_support/vendor'
-begin
- require 'i18n'
-rescue LoadError
- $: << File.expand_path(File.join(File.dirname(__FILE__), 'active_support/vendor/i18n-0.1.3/lib'))
- retry
-end
-
+require 'active_support/vendor/i18n'
I18n.load_path << "#{File.dirname(__FILE__)}/active_support/locale/en.yml"
@@ -1,4 +1,4 @@
-require 'memcache'
+require 'active_support/vendor/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 'builder' unless defined?(Builder)
+ require 'active_support/vendor/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 'builder' unless defined?(Builder)
+ require 'active_support/vendor/builder' unless defined?(Builder)
options = options.dup
options[:indent] ||= 2
@@ -6,7 +6,7 @@
# fast_xs extension unavailable
else
begin
- require 'builder'
+ require 'active_support/vendor/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 'tzinfo' unless defined?(TZInfo)
+ require 'active_support/vendor/tzinfo' unless defined?(TZInfo)
@tzinfo ||= TZInfo::Timezone.get(MAPPING[name])
end
@@ -1,27 +1,23 @@
-# Prefer gems to the bundled libs.
-require 'rubygems'
+# 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 'builder', '~> 2.1.2'
-rescue Gem::LoadError
- $:.unshift "#{File.dirname(__FILE__)}/vendor/builder-2.1.2/lib"
-end
-
-begin
- gem 'memcache-client', '>= 1.6.5'
-rescue Gem::LoadError
- $:.unshift "#{File.dirname(__FILE__)}/vendor/memcache-client-1.6.5/lib"
-end
+ begin
+ gem 'memcache-client', '>= 1.6.5'
+ rescue Gem::LoadError
+ end
-begin
- gem 'tzinfo', '~> 0.3.13'
-rescue Gem::LoadError
- $:.unshift "#{File.dirname(__FILE__)}/vendor/tzinfo-0.3.13/lib"
-end
+ begin
+ gem 'tzinfo', '~> 0.3.13'
+ rescue Gem::LoadError
+ end
-begin
- gem 'i18n', '~> 0.1.3'
-rescue Gem::LoadError
- $:.unshift "#{File.dirname(__FILE__)}/vendor/i18n-0.1.3/lib"
- require 'i18n'
+ begin
+ gem 'i18n', '~> 0.1.3'
+ rescue Gem::LoadError
+ end
end
@@ -0,0 +1,6 @@
+begin
+ require 'builder'
+rescue LoadError
+ $:.unshift File.expand_path(File.join(File.dirname(__FILE__), 'builder-2.1.2', 'lib'))
+ retry
+end
@@ -0,0 +1,6 @@
+begin
+ require 'i18n'
+rescue LoadError
+ $:.unshift File.expand_path(File.join(File.dirname(__FILE__), 'i18n-0.1.3', 'lib'))
+ retry
+end
@@ -0,0 +1,6 @@
+begin
+ require 'memcache'
+rescue LoadError
+ $:.unshift File.expand_path(File.join(File.dirname(__FILE__), 'memcache-client-1.6.5', 'lib'))
+ retry
+end
@@ -0,0 +1,6 @@
+begin
+ require 'tzinfo'
+rescue LoadError
+ $:.unshift File.expand_path(File.join(File.dirname(__FILE__), 'tzinfo-0.3.13', 'lib'))
+ retry
+end
@@ -1,8 +1,6 @@
ORIG_ARGV = ARGV.dup
-require 'bundler_helper'
-ensure_requirable %w( builder memcache tzinfo )
-
+require 'rubygems'
require 'test/unit'
ENV['NO_RELOAD'] = '1'
@@ -14,7 +12,7 @@
require 'active_support/ruby/shim'
def uses_memcached(test_name)
- require 'memcache'
+ require 'active_support/vendor/memcache'
begin
MemCache.new('localhost').stats
yield
@@ -1,30 +0,0 @@
-BUNDLER_ENV_FILE = File.join(File.dirname(__FILE__), '..', 'vendor', 'gems', 'environment')
-
-def load_bundled_gems
- load_bundled_gems! if File.exist?("#{BUNDLER_ENV_FILE}.rb")
-end
-
-def load_bundled_gems!
- puts "Checking if the bundled testing requirements are up to date..."
-
- result = system "gem bundle"
- unless result
- puts "The gem bundler is not installed. Installing."
- system "gem install bundler"
- system "gem bundle"
- end
-
- require BUNDLER_ENV_FILE
-end
-
-def ensure_requirable(libs)
- load_bundled_gems
-
- begin
- libs.each { |lib| require lib }
- rescue LoadError => e
- puts "Missing required libs to run test"
- puts e.message
- load_bundled_gems!
- end
-end

0 comments on commit b2f0b8c

Please sign in to comment.