Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix deprecation warnings with RubyGems >= 1.6.

  • Loading branch information...
commit 3155c8bfb5d02a91bd1616d3182121b7a04c5dd6 1 parent abfad1c
@FooBarWidget FooBarWidget authored
Showing with 14 additions and 2 deletions.
  1. +14 −2 lib/phusion_passenger/app_process.rb
View
16 lib/phusion_passenger/app_process.rb
@@ -70,7 +70,7 @@ def self.detect_framework_version(app_root)
return nil
end
- search_results = Gem.cache.search(Gem::Dependency.new('rails', gem_version_spec), true)
+ search_results = search_gem('rails', gem_version_spec)
found_version = search_results.map do |x|
x.version.version
end.sort.last
@@ -79,7 +79,7 @@ def self.detect_framework_version(app_root)
# date because the Rails version may have been installed now.
# So we reload the RubyGems cache and try again.
Gem.clear_paths
- search_results = Gem.cache.search(Gem::Dependency.new('rails', gem_version_spec), true)
+ search_results = search_gem('rails', gem_version_spec)
found_version = search_results.map do |x|
x.version.version
end.sort.last
@@ -94,6 +94,18 @@ def self.detect_framework_version(app_root)
end
end
+ def self.search_gem(gem_name, gem_version_spec)
+ if defined?(Gem::Specification) && Gem::Specification.respond_to?(:find_all_by_name)
+ return Gem::Specification.find_all_by_name(gem_name, gem_version_spec)
+ elsif Gem.respond_to?(:source_index)
+ dep = Gem::Dependency.new(gem_name, gem_version_spec)
+ return Gem.source_index.search(dep, true)
+ else
+ dep = Gem::Dependency.new(gem_name, gem_version_spec)
+ return Gem.cache.search(dep, true)
+ end
+ end
+
# Construct an AppProcess by reading information from the given MessageChannel.
# The other side of the channel must be writing AppProcess information using
# AppProcess#write_to_channel.
Please sign in to comment.
Something went wrong with that request. Please try again.