summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2015-02-17 15:08:09 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2015-02-17 15:10:34 -0800
commita750fa504bcb1f6eb173948b48d6ab8ca1c8ce13 (patch)
treedd117aa3da5d8c51c8d22cf1ec77a79d17326d2a
parent0561ad9615b5f3f181d790e2db16086aa572b1eb (diff)
downloadffi-yajl-a750fa504bcb1f6eb173948b48d6ab8ca1c8ce13.tar.gz
mixin windows? helper directly into the object
its useful to be able to include/extend the platform class and then use this sugar directly
-rw-r--r--lib/ffi_yajl/ext.rb4
-rw-r--r--lib/ffi_yajl/platform.rb10
2 files changed, 9 insertions, 5 deletions
diff --git a/lib/ffi_yajl/ext.rb b/lib/ffi_yajl/ext.rb
index 0d0faf3..5784023 100644
--- a/lib/ffi_yajl/ext.rb
+++ b/lib/ffi_yajl/ext.rb
@@ -7,12 +7,14 @@ require 'libyajl2'
require 'ffi_yajl/platform'
module FFI_Yajl
+ extend FFI_Yajl::Platform
+
# FIXME: DRY with ffi_yajl/ffi.rb
# FIXME: extract map_library_name from FFI and stop requiring it at the top level
# 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 Platform::windows?
+ libname = "libyajl.so" if 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
index bde716d..6c2a498 100644
--- a/lib/ffi_yajl/platform.rb
+++ b/lib/ffi_yajl/platform.rb
@@ -1,5 +1,7 @@
-module Platform
- def self.windows?
- !!(RUBY_PLATFORM =~ /mswin|mingw|cygwin|windows/)
+module FFI_Yajl
+ module Platform
+ def windows?
+ !!(RUBY_PLATFORM =~ /mswin|mingw|cygwin|windows/)
+ end
end
-end \ No newline at end of file
+end