diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2014-08-07 11:45:47 -0400 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2014-08-07 16:38:18 -0500 |
commit | 199bcc2304bc032559ca0b9f82978b4ebb64fe41 (patch) | |
tree | 79dee940f52453a303daef036bcb9337dd8c21e7 /lib | |
parent | 1959569899868d5d7da83941072a0dce62a84f6c (diff) | |
download | ffi-yajl-199bcc2304bc032559ca0b9f82978b4ebb64fe41.tar.gz |
change allow_comment default to true
this matches yajl-ruby's default and fixes a regression in Chef
where we stopped accepting comments.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ffi_yajl/ext.rb | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/lib/ffi_yajl/ext.rb b/lib/ffi_yajl/ext.rb index 504cbe1..1c7486d 100644 --- a/lib/ffi_yajl/ext.rb +++ b/lib/ffi_yajl/ext.rb @@ -1,13 +1,8 @@ require 'rubygems' - require 'ffi_yajl/encoder' require 'ffi_yajl/parser' require 'ffi' require 'libyajl2' -begin - require 'fiddle' -rescue LoadError -end module FFI_Yajl # FIXME: DRY with ffi_yajl/ffi.rb @@ -15,16 +10,20 @@ module FFI_Yajl libpath = File.expand_path(File.join(Libyajl2.opt_path, libname)) libpath.gsub!(/dylib/, 'bundle') libpath = ::FFI.map_library_name("yajl") unless File.exist?(libpath) - if defined?(Fiddle) && Fiddle.respond_to?(:dlopen) + + begin + # deliberately delayed require + require 'fiddle' ::Fiddle.dlopen(libpath) - else - # deliberately convoluted delayed require here to avoid deprecation - # warning from requiring dl - require 'dl' - if defined?(DL) && DL.respond_to?(:dlopen) + rescue LoadError + begin + # deliberately delayed require + require 'dl' ::DL.dlopen(libpath) - else - raise "cannot find dlopen in either DL or Fiddle, cannot proceed" + rescue LoadError + # deliberately delayed require + require 'ffi_yajl/dlopen' + FFI_Yajl::Dlopen.dlopen(libpath) end end |