From 4f3006ec3fee281848640a244d3852acaba4e39d Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Thu, 26 Jun 2014 11:26:56 -0700 Subject: fix DL/Fiddle logic stop using ffi the ffi_lib attempt didn't work. also fix to delay the require of the 'dl' library until we've determined that Fiddle does not meet our needs (otherwise we get deprecation warnings even though we don't wind up using DL). --- lib/ffi_yajl/ext.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/ffi_yajl/ext.rb b/lib/ffi_yajl/ext.rb index 2523f9b..504cbe1 100644 --- a/lib/ffi_yajl/ext.rb +++ b/lib/ffi_yajl/ext.rb @@ -8,10 +8,6 @@ begin require 'fiddle' rescue LoadError end -begin - require 'dl' -rescue LoadError -end module FFI_Yajl # FIXME: DRY with ffi_yajl/ffi.rb @@ -21,11 +17,15 @@ module FFI_Yajl libpath = ::FFI.map_library_name("yajl") unless File.exist?(libpath) if defined?(Fiddle) && Fiddle.respond_to?(:dlopen) ::Fiddle.dlopen(libpath) - elsif defined?(DL) && DL.respond_to?(:dlopen) - ::DL.dlopen(libpath) else - extend ::FFI::Library - ffi_lib libpath + # deliberately convoluted delayed require here to avoid deprecation + # warning from requiring dl + require 'dl' + if defined?(DL) && DL.respond_to?(:dlopen) + ::DL.dlopen(libpath) + else + raise "cannot find dlopen in either DL or Fiddle, cannot proceed" + end end class Parser -- cgit v1.2.1