summaryrefslogtreecommitdiff
path: root/lib/ffi_yajl.rb
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2013-12-31 10:16:30 -0600
committerLamont Granquist <lamont@scriptkiddie.org>2013-12-31 10:16:30 -0600
commit18c88157be17f04cbd3f53edc9377eb57a46888c (patch)
tree5bdffc0a1b73314f213455e735fd926589eda1a7 /lib/ffi_yajl.rb
parent8226eab6e1127f030ad304c0f297e0f0d79572da (diff)
downloadffi-yajl-18c88157be17f04cbd3f53edc9377eb57a46888c.tar.gz
reorganization of ext-vs-ffi
cleanup ext-vs-ffi logic, require 'ffi_yajl/ffi' and 'ffi_yajl/ext' should work now
Diffstat (limited to 'lib/ffi_yajl.rb')
-rw-r--r--lib/ffi_yajl.rb19
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/ffi_yajl.rb b/lib/ffi_yajl.rb
index 0f906b6..ea900bc 100644
--- a/lib/ffi_yajl.rb
+++ b/lib/ffi_yajl.rb
@@ -1,10 +1,13 @@
-require 'rubygems'
-require 'ffi_yajl/encoder'
-require 'ffi_yajl/parser'
-
-module FFI_Yajl
- class ParseError < StandardError; end
- class EncodeError < StandardError; end
+if ENV['FORCE_FFI_YAJL'] == "ext"
+ require 'ffi_yajl/ext'
+elsif ENV['FORCE_FFI_YAJL'] == "ffi" || defined?(Yajl)
+ # on Linux yajl-ruby and non-FFI ffi_yajl conflict
+ require 'ffi_yajl/ffi'
+else
+ begin
+ require 'ffi_yajl/ext'
+ rescue LoadError
+ require 'ffi_yajl/ffi'
+ end
end
-