Rollback AS bundler work and improve activation of vendored dependencies

This commit is contained in:
Joshua Peek 2009-09-13 22:55:46 -05:00
parent 6f9e449830
commit b2f0b8cbda
18 changed files with 54 additions and 96 deletions

View File

@ -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

View File

@ -6,7 +6,7 @@ module ActionView
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 +

View File

@ -7,7 +7,7 @@ $:.unshift(File.dirname(__FILE__) + '/fixtures/helpers')
$:.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')

View File

@ -1,5 +1,5 @@
require 'abstract_unit'
require 'tzinfo'
require 'active_support/vendor/tzinfo'
TZInfo::Timezone.cattr_reader :loaded_zones

View File

@ -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

View File

@ -37,11 +37,5 @@ 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"

View File

@ -1,4 +1,4 @@
require 'memcache'
require 'active_support/vendor/memcache'
module ActiveSupport
module Cache

View File

@ -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 '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"

View File

@ -84,7 +84,7 @@ class Hash
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

View File

@ -6,7 +6,7 @@ rescue LoadError
# 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

View File

@ -306,7 +306,7 @@ module ActiveSupport
# 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

View File

@ -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
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 'tzinfo', '~> 0.3.13'
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 '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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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/test_case'
require 'active_support/ruby/shim'
def uses_memcached(test_name)
require 'memcache'
require 'active_support/vendor/memcache'
begin
MemCache.new('localhost').stats
yield

View File

@ -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