summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTyler Vann-Campbell <tyler@buddy.com>2015-02-08 13:20:43 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2015-02-17 15:10:34 -0800
commit0561ad9615b5f3f181d790e2db16086aa572b1eb (patch)
treefea872102598c3ffce7d4ee0c35731bf5a60c231 /lib
parent497cead6e7df8a26ae5b7d66713be68cdc7f2c36 (diff)
downloadffi-yajl-0561ad9615b5f3f181d790e2db16086aa572b1eb.tar.gz
Move #windows? to lib to allow not checking libname to determine platform
Diffstat (limited to 'lib')
-rw-r--r--lib/ffi_yajl/ext.rb3
-rw-r--r--lib/ffi_yajl/platform.rb5
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/ffi_yajl/ext.rb b/lib/ffi_yajl/ext.rb
index 7a84ef1..0d0faf3 100644
--- a/lib/ffi_yajl/ext.rb
+++ b/lib/ffi_yajl/ext.rb
@@ -4,6 +4,7 @@ require 'ffi_yajl/encoder'
require 'ffi_yajl/parser'
require 'ffi'
require 'libyajl2'
+require 'ffi_yajl/platform'
module FFI_Yajl
# FIXME: DRY with ffi_yajl/ffi.rb
@@ -11,7 +12,7 @@ module FFI_Yajl
# so that the C-library can be installed without FFI
libname = ::FFI.map_library_name("yajl")
# awful windows patch, but there is an open issue to entirely replace FFI.map_library_name already
- libname = "libyajl.so" if libname == "yajl.dll"
+ libname = "libyajl.so" if Platform::windows?
libpath = File.expand_path(File.join(Libyajl2.opt_path, libname))
libpath.gsub!(/dylib/, 'bundle')
libpath = ::FFI.map_library_name("yajl") unless File.exist?(libpath)
diff --git a/lib/ffi_yajl/platform.rb b/lib/ffi_yajl/platform.rb
new file mode 100644
index 0000000..bde716d
--- /dev/null
+++ b/lib/ffi_yajl/platform.rb
@@ -0,0 +1,5 @@
+module Platform
+ def self.windows?
+ !!(RUBY_PLATFORM =~ /mswin|mingw|cygwin|windows/)
+ end
+end \ No newline at end of file