From 0fe083e271db79f676b557aa30a0c51822e40487 Mon Sep 17 00:00:00 2001 From: Seiya Nishizawa Date: Fri, 23 May 2014 09:23:43 +0900 Subject: [PATCH] use Gem::Specification.find_by_name instead of Gem.source_index for Ruby >= 2.0 --- ext/mpi/extconf.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ext/mpi/extconf.rb b/ext/mpi/extconf.rb index 03eff3a..4320394 100644 --- a/ext/mpi/extconf.rb +++ b/ext/mpi/extconf.rb @@ -4,12 +4,20 @@ gem_path = nil begin require "rubygems" - if (spec = Gem.source_index.find_name("narray")).any? - gem_path = spec.last.full_gem_path + if Gem::Specification.respond_to?(:find_by_name) + if spec = Gem::Specification.find_by_name("narray") + gem_path = spec.full_gem_path + end + else + if (spec = Gem.source_index.find_name("narray")).any? + gem_path = spec.full_gem_path + end end rescue LoadError dir_config("narray", Config::CONFIG["sitearchdir"]) end -find_header("narray.h", File.join(gem_path,"src")) +unless find_header("narray.h", gem_path) + find_header("narray.h", File.join(gem_path,"src")) +end create_makefile("mpi")