ffi-radix_tree 0.1.0 → 0.1.1

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: b552a559de9350d73c2c847b2aa4f0157fed12a8
4
- data.tar.gz: f25f0dc4ad08766c3f805b8f75cba8c6fbda5a3d
3
+ metadata.gz: d36fd469f2823e6b56e5d8a4dab8ff7f9cd133f3
4
+ data.tar.gz: 5cfcb3ed80dc6b731c95e16270fe48a1f7558e1c
5
5
  SHA512:
6
- metadata.gz: 63fc44026e11a67bdef49b7c7fd2c1fe3c5c1a34ef7ae3ae26823c52d77a0b278b43e506114dda67baf10f7cfb160e855c5bcef05005102e320ff3ae2395e9eb
7
- data.tar.gz: 8facbab3ba214d8c382f2c176d6284c9743de7d34e1368e558ed550fa8e4d2b06c988bd29cef5cf01e3286287b9398628a913707284d8f6652960f647ebb8ebf
6
+ metadata.gz: e08601eee9895a0a27bbaad76f44f51dc8f1dfd7f0768b23611734e34950a7edae76d45892a5e8316d4369614b4e32f5aca5ab591da0c326cecaaa828f2c0978
7
+ data.tar.gz: 80435e020cd98216c0699db2559b4b75d63925d70f2d1f1e8c603b4a7539349d446e3ff3305c53d917cfcdd83f60f77f5ce4392f3967a11ed041bb9b75da5e48
@@ -15,7 +15,7 @@ module FFI
15
15
  begin
16
16
  # bias the library discovery to a path inside the gem first, then
17
17
  # to the usual system paths
18
- gem_base = ::File.join(::File.dirname(__FILE__), '..', '..', '..')
18
+ gem_base = ::File.join(::File.dirname(__FILE__), '..', '..')
19
19
  inside_gem = ::File.join(gem_base, 'ext')
20
20
  local_path = ::FFI::Platform::IS_WINDOWS ? ENV['PATH'].split(';') : ENV['PATH'].split(':')
21
21
  env_path = [ ENV['RADIX_TREE_LIB_PATH'] ].compact
@@ -46,7 +46,7 @@ module FFI
46
46
  '/usr/local/lib', '/opt/local/lib', homebrew_path, '/usr/lib64'
47
47
  ]
48
48
  else
49
- [::File.join(gem_base, "vendor/radixtree/build/src")]
49
+ [::File.join(gem_base, "vendor/radixtree")]
50
50
  end
51
51
 
52
52
  RADIX_TREE_LIB_PATHS = radixtree_lib_paths.
@@ -81,49 +81,49 @@ module FFI
81
81
  attach_function :longest_prefix_value, [:pointer, :string, :pointer], :pointer
82
82
  attach_function :match_free, [:pointer], :void
83
83
  attach_function :has_key, [:pointer, :string], :bool
84
- end
85
84
 
86
- class Tree
87
- DESTROY_METHOD = ::RadixTree.method(:destroy)
88
- FREE_METHOD = ::RadixTree.method(:match_free)
85
+ class Tree
86
+ DESTROY_METHOD = ::FFI::RadixTree.method(:destroy)
87
+ FREE_METHOD = ::FFI::RadixTree.method(:match_free)
89
88
 
90
- def initialize
91
- @ptr = ::FFI::AutoPointer.new(::FFI::RadixTree.create, DESTROY_METHOD)
92
- end
89
+ def initialize
90
+ @ptr = ::FFI::AutoPointer.new(::FFI::RadixTree.create, DESTROY_METHOD)
91
+ end
93
92
 
94
- def has_key?(key)
95
- ::FFI::RadixTree.has_key(@ptr, key)
96
- end
93
+ def has_key?(key)
94
+ ::FFI::RadixTree.has_key(@ptr, key)
95
+ end
97
96
 
98
- def push(key, value)
99
- storage_data = ::MessagePack.pack(value)
100
- bytesize = storage_data.bytesize
101
- memory_buffer = ::FFI::MemoryPointer.new(:char, bytesize, true)
102
- memory_buffer.put_bytes(0, storage_data)
103
- ::FFI::RadixTree.insert(@ptr, key, memory_buffer, bytesize)
104
- end
97
+ def push(key, value)
98
+ storage_data = ::MessagePack.pack(value)
99
+ bytesize = storage_data.bytesize
100
+ memory_buffer = ::FFI::MemoryPointer.new(:char, bytesize, true)
101
+ memory_buffer.put_bytes(0, storage_data)
102
+ ::FFI::RadixTree.insert(@ptr, key, memory_buffer, bytesize)
103
+ end
105
104
 
106
- def get(key)
107
- byte_length = ::FFI::MemoryPointer.new(:int)
108
- byte_pointer = ::FFI::AutoPointer.new(::FFI::RadixTree.fetch(@ptr, key, byte_length), FREE_METHOD)
109
- bytesize = byte_length.read_int
110
- return nil if bytesize <= 0
111
- ::MessagePack.unpack(byte_pointer.get_bytes(0, bytesize))
112
- end
105
+ def get(key)
106
+ byte_length = ::FFI::MemoryPointer.new(:int)
107
+ byte_pointer = ::FFI::AutoPointer.new(::FFI::RadixTree.fetch(@ptr, key, byte_length), FREE_METHOD)
108
+ bytesize = byte_length.read_int
109
+ return nil if bytesize <= 0
110
+ ::MessagePack.unpack(byte_pointer.get_bytes(0, bytesize))
111
+ end
113
112
 
114
- def longest_prefix(string)
115
- value, p_out = ::FFI::RadixTree.longest_prefix(@ptr, string)
116
- p_out = ::FFI::AutoPointer.new(p_out, FREE_METHOD) unless p_out.nil?
117
- value.force_encoding("UTF-8") unless value.nil?
118
- value
119
- end
113
+ def longest_prefix(string)
114
+ value, p_out = ::FFI::RadixTree.longest_prefix(@ptr, string)
115
+ p_out = ::FFI::AutoPointer.new(p_out, FREE_METHOD) unless p_out.nil?
116
+ value.force_encoding("UTF-8") unless value.nil?
117
+ value
118
+ end
120
119
 
121
- def longest_prefix_value(string)
122
- byte_length = ::FFI::MemoryPointer.new(:int)
123
- byte_pointer = ::FFI::AutoPointer.new(::FFI::RadixTree.longest_prefix_value(@ptr, string, byte_length), FREE_METHOD)
124
- bytesize = byte_length.read_int
125
- return nil if bytesize <= 0
126
- ::MessagePack.unpack(byte_pointer.get_bytes(0, bytesize))
120
+ def longest_prefix_value(string)
121
+ byte_length = ::FFI::MemoryPointer.new(:int)
122
+ byte_pointer = ::FFI::AutoPointer.new(::FFI::RadixTree.longest_prefix_value(@ptr, string, byte_length), FREE_METHOD)
123
+ bytesize = byte_length.read_int
124
+ return nil if bytesize <= 0
125
+ ::MessagePack.unpack(byte_pointer.get_bytes(0, bytesize))
126
+ end
127
127
  end
128
128
  end
129
129
  end
@@ -1,5 +1,5 @@
1
1
  module FFI
2
2
  module RadixTree
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffi-radix_tree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Dewitt