ffi-hiredis_vip-core 0.1.0.pre3 → 0.1.0.pre4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b679c377de470cfe396c388d4a4c7946e2331f5a
4
- data.tar.gz: 110075769569adc12766136039c5a6c7d68b9ec7
3
+ metadata.gz: 663a312faeb9876f597a3d3ec243a78a6f8a1a1a
4
+ data.tar.gz: 03c4726d35b3a48335f2f52c7da6e5da5de43c00
5
5
  SHA512:
6
- metadata.gz: 3c7125d422a5324f13883ce346579826a0990b9d3a1c51366564d1dd6dbe57b9179fccf45687904f1b2451cff15b84f6c38737b6e5e5b38bdb3dd08677afe16f
7
- data.tar.gz: 64b9f29bcd4106a04b91712d7090be284fac147fd4302aae4a05efc74f3caec346f1a9ceb78044e66d1c001e5dc4f412b8392d922225f308ade6c9d2c2b4de3a
6
+ metadata.gz: 29af71e9d5f9fee7fd73f7df585d17df858390b126eca07b923b76f6e96c89f2e93427c20da8268c6eaa4b973efb6bde5caea4941daa10994089b60d85efee34
7
+ data.tar.gz: 19adb10cc75ecee01a98df7d5b1874bb47d29a64e15931dc2f9bcc56cc8cad4784d319261c293093d71ef6e2c07925fa6e08240452e2756aada88c62eca02441
@@ -8,10 +8,61 @@ module FFI
8
8
  module Core
9
9
  extend ::FFI::Library
10
10
  ffi_lib_flags :now, :global
11
- # TODO: can we support libhiredis + libhiredis_vip and enable clustering on the latter?
12
- # TODO: need to provide ways to set the loading of the lip and check standard lib paths
13
- LIB_HOME = ENV["HIREDIS_VIP_HOME"]
14
- ffi_lib File.expand_path("#{LIB_HOME}/libhiredis_vip.#{::FFI::Platform::LIBSUFFIX}", File.dirname(__FILE__))
11
+
12
+ ##
13
+ # ffi-rzmq-core for reference
14
+ #
15
+ # https://github.com/chuckremes/ffi-rzmq-core/blob/master/lib/ffi-rzmq-core/libzmq.rb
16
+ #
17
+ begin
18
+ # bias the library discovery to a path inside the gem first, then
19
+ # to the usual system paths
20
+ inside_gem = File.join(File.dirname(__FILE__), '..', '..', 'ext')
21
+ local_path = FFI::Platform::IS_WINDOWS ? ENV['PATH'].split(';') : ENV['PATH'].split(':')
22
+ env_path = [ ENV['HIREDIS_VIP_LIB_PATH'] ].compact
23
+ rbconfig_path = RbConfig::CONFIG["libdir"]
24
+ homebrew_path = nil
25
+
26
+ # RUBYOPT set by RVM breaks 'brew' so we need to unset it.
27
+ rubyopt = ENV.delete('RUBYOPT')
28
+
29
+ begin
30
+ stdout, stderr, status = Open3.capture3("brew", "--prefix")
31
+ homebrew_path = if status.success?
32
+ "#{stdout.chomp}/lib"
33
+ else
34
+ '/usr/local/homebrew/lib'
35
+ end
36
+ rescue
37
+ # Homebrew doesn't exist
38
+ end
39
+
40
+ # Restore RUBYOPT after executing 'brew' above.
41
+ ENV['RUBYOPT'] = rubyopt
42
+
43
+ # Search for libhiredis_vip in the following order...
44
+ HIREDIS_VIP_LIB_PATHS = ([inside_gem] + env_path + local_path + [rbconfig_path] + [
45
+ '/usr/local/lib', '/opt/local/lib', homebrew_path, '/usr/lib64'
46
+ ]).compact.map{|path| "#{path}/libhiredis_vip.#{FFI::Platform::LIBSUFFIX}"}
47
+ ffi_lib(HIREDIS_VIP_LIB_PATHS + %w{libhiredis_vip})
48
+
49
+ rescue LoadError
50
+ if HIREDIS_VIP_LIB_PATHS.any? {|path|
51
+ File.file? File.join(path, "libhiredis_vip.#{FFI::Platform::LIBSUFFIX}")}
52
+ warn "Unable to load this gem. The libhiredis_vip library exists, but cannot be loaded."
53
+ warn "If this is Windows:"
54
+ warn "- Check that you have MSVC runtime installed or statically linked"
55
+ warn "- Check that your DLL is compiled for #{FFI::Platform::ADDRESS_SIZE} bit"
56
+ else
57
+ warn "Unable to load this gem. The libhiredis_vip library (or DLL) could not be found."
58
+ warn "If this is a Windows platform, make sure libhiredis_vip.dll is on the PATH."
59
+ warn "If the DLL was built with mingw, make sure the other two dependent DLLs,"
60
+ warn "libgcc_s_sjlj-1.dll and libstdc++6.dll, are also on the PATH."
61
+ warn "For non-Windows platforms, make sure libhiredis_vip is located in this search path:"
62
+ warn HIREDIS_VIP_LIB_PATHS.inspect
63
+ end
64
+ raise LoadError, "The libhiredis_vip library (or DLL) could not be loaded"
65
+ end
15
66
 
16
67
  RedisClusterFlags = enum :HIRCLUSTER_FLAG_NULL, 0x0,
17
68
  :HIRCLUSTER_FLAG_ADD_SLAVE, 0x1000, #/* The flag to decide whether add slave node in redisClusterContext->nodes. This is set in the
@@ -50,7 +101,6 @@ module FFI
50
101
  end
51
102
 
52
103
  attach_function :freeReplyObject, [:pointer], :void, :blocking => true
53
-
54
104
  attach_function :redisReplyElement, [:pointer, :size_t], RedisReply.ptr, :blocking => true
55
105
  attach_function :redisConnect, [:string, :int], :pointer, :blocking => true
56
106
  attach_function :redisReconnect, [:pointer], RedisOkType, :blocking => true # :pointer => redisContext
@@ -1,7 +1,7 @@
1
1
  module FFI
2
2
  module HiredisVip
3
3
  module Core
4
- VERSION = "0.1.0.pre3"
4
+ VERSION = "0.1.0.pre4"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffi-hiredis_vip-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre3
4
+ version: 0.1.0.pre4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Dewitt
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-10 00:00:00.000000000 Z
11
+ date: 2016-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi