[#133] Provide workaround for rubygems 1.5 compatibility

Remove the deprecation warnings for version_requirements with rubygems < 1.5
and allow ChiliProject to run with rubygems >= 1.5.
This commit is contained in:
Thibaut Deloffre 2011-02-22 14:23:40 +01:00 committed by Holger Just
parent 2cfb603642
commit 28bbee155c
1 changed files with 40 additions and 0 deletions

View File

@ -118,5 +118,45 @@ rescue Gem::LoadError => load_error
exit 1
end
# TODO: Workaround for rubygems > 1.5 compatibility (#133), to be removed
# for Rails > 2.3.5
#
# Fixes the deprecation warning about removal of version_requirements for
# rubygems < 1.5 and provide a workaround for rubygems >= 1.5 where that
# method was finally removed.
module Rails
# See lib/gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb
class GemDependency < Gem::Dependency
def dependencies
return [] if framework_gem?
return [] unless installed?
specification.dependencies.reject do |dependency|
dependency.type == :development
end.map do |dependency|
GemDependency.new(dependency.name,
:requirement => (dependency.respond_to?(:requirement) ?
dependency.requirement :
dependency.version_requirements))
end
end
if method_defined?(:requirement)
# rubygem > 1.5
def requirement
req = super
req unless req == Gem::Requirement.default
end
# bypass passenger error
alias :version_requirements :requirement
else
# rubygem < 1.5
def requirement
req = version_requirements
req unless req == Gem::Requirement.default
end
end
end
end
# All that for this:
Rails.boot!