geokdtree 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ # 0.1.0, 02-19-2013
2
+ - initial release
3
+
4
+ # 0.2.0, 02-21-2013
5
+ - refactored native lib build using ffi-compiler, fixed linux installation issues
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Ruby/FFI Geokdtree v0.1.0
1
+ # Geokdtree v0.2.0
2
2
 
3
3
  Ruby & JRuby gem with a fast **k-d tree** C implementation using FFI bindings with support for latitude/longitude and **geo distance range search**.
4
4
 
@@ -6,33 +6,21 @@ A [k-d tree](https://en.wikipedia.org/wiki/K-d_tree) is a space-partitioning dat
6
6
 
7
7
  ## Installation
8
8
 
9
- Tested on OSX 10.8.2 with
10
- - MRI Ruby 1.9.3 p362
11
- - MRI Ruby 1.9.3 p385
9
+ Tested on **OSX 10.8.2** and **Linux 12.10** with
10
+ - MRI Ruby 1.9.3 p362, 1.9.3 p385
12
11
  - JRuby 1.7.2 (1.9.3 p327)
13
12
 
14
13
  Add this line to your application's Gemfile:
15
-
14
+ ```
16
15
  gem 'geokdtree'
17
-
16
+ ```
18
17
  And then execute:
19
-
18
+ ```
20
19
  $ bundle
21
-
22
- Or install it yourself as:
23
-
24
- $ gem install geokdtree
25
-
26
- ## JRuby Notes
27
-
28
- if the gem installation fails with the following error message, this is because JRuby disabled native extensions by default.
29
20
  ```
30
- Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension
21
+ Or install it yourself as:
31
22
  ```
32
-
33
- To fix this simply set the following JRuby runtime option
34
- ``` sh
35
- $ export JRUBY_OPTS=-Xcext.enabled=true
23
+ $ gem install geokdtree
36
24
  ```
37
25
 
38
26
  ## Usage
@@ -103,12 +91,20 @@ $ export JRUBY_OPTS=-Xcext.enabled=true
103
91
  puts(d.inspect) # => 403
104
92
  ```
105
93
 
94
+ ## Developement
95
+
96
+ 1. Fort it
97
+ 2. Install gems `$ bundle install`
98
+ 3. Compile lib `$ rake compile`
99
+ 4. Run specs `$ rake spec`
100
+ 5. Clean compiler generated files `$ rake clean`
101
+
106
102
  ## Contributing
107
103
 
108
104
  1. Fork it
109
- 2. Create your feature branch (`git checkout -b my-new-feature`)
110
- 3. Commit your changes (`git commit -am 'Add some feature'`)
111
- 4. Push to the branch (`git push origin my-new-feature`)
105
+ 2. Create your feature branch `git checkout -b my-new-feature`
106
+ 3. Commit your changes `git commit -am 'Add some feature'`
107
+ 4. Push to the branch `git push origin my-new-feature`
112
108
  5. Create new Pull Request
113
109
 
114
110
  ## Credits
@@ -118,4 +114,4 @@ $ export JRUBY_OPTS=-Xcext.enabled=true
118
114
  Colin Surprenant, [@colinsurprenant](http://twitter.com/colinsurprenant), [http://github.com/colinsurprenant](http://github.com/colinsurprenant), colin.surprenant@gmail.com
119
115
 
120
116
  ## License
121
- Ruby/FFI Geokdtree is distributed under the Apache License, Version 2.0.
117
+ Geokdtree is distributed under the Apache License, Version 2.0.
data/Rakefile CHANGED
@@ -3,28 +3,25 @@ require 'rake'
3
3
  require 'rake/clean'
4
4
  require 'bundler/gem_tasks'
5
5
  require 'rspec/core/rake_task'
6
+ require 'ffi-compiler/compile_task'
6
7
 
7
8
  task :default => :spec
8
9
 
9
- desc "clean, make and run specsrkae"
10
+ desc "run specs"
10
11
  task :spec do
11
12
  RSpec::Core::RakeTask.new
12
13
  end
13
14
 
14
- desc "compile C ext and FFI ext and copy objects into lib"
15
- task :make => [:clean] do
16
- Dir.chdir("ext/geokdtree") do
17
- ruby jruby? ? "-Xcext.enabled=true extconf.rb" : "extconf.rb"
18
- sh "make"
15
+ desc "compiler tasks"
16
+ namespace "ffi-compiler" do
17
+ FFI::Compiler::CompileTask.new('ext/geokdtree/geokdtree') do |c|
18
+ c.have_library?('pthread')
19
+ c.cflags << "-DUSE_LIST_NODE_ALLOCATOR"
19
20
  end
20
- cp "ext/geokdtree/geokdtree.bundle", "lib/"
21
21
  end
22
+ task :compile => ["ffi-compiler:default"]
22
23
 
23
24
  CLEAN.include('ext/**/*{.o,.log,.so,.bundle}')
24
25
  CLEAN.include('lib/**/*{.o,.log,.so,.bundle}')
25
26
  CLEAN.include('ext/**/Makefile')
26
27
 
27
- def jruby?
28
- !!(defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby')
29
- end
30
-
@@ -0,0 +1,6 @@
1
+ require 'ffi-compiler/compile_task'
2
+
3
+ FFI::Compiler::CompileTask.new('geokdtree') do |c|
4
+ c.have_library?('pthread')
5
+ c.cflags << "-DUSE_LIST_NODE_ALLOCATOR"
6
+ end
@@ -16,8 +16,11 @@ Gem::Specification.new do |gem|
16
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
- gem.extensions = ["ext/geokdtree/extconf.rb"]
19
+ gem.extensions = ["ext/geokdtree/Rakefile"]
20
20
 
21
- gem.add_development_dependency "rspec"
22
- gem.add_runtime_dependency "ffi"
21
+ gem.add_dependency 'rake'
22
+ gem.add_dependency 'ffi'
23
+ gem.add_dependency 'ffi-compiler'
24
+
25
+ gem.add_development_dependency 'rspec'
23
26
  end
@@ -1,10 +1,10 @@
1
1
  require 'ffi'
2
+ require 'ffi-compiler/loader'
2
3
 
3
4
  module Geokdtree
4
5
  module C
5
6
  extend FFI::Library
6
-
7
- ffi_lib File.dirname(__FILE__) + "/" + (FFI::Platform.mac? ? "geokdtree.bundle" : FFI.map_library_name("geokdtree"))
7
+ ffi_lib FFI::Compiler::Loader.find('geokdtree')
8
8
  end
9
9
  end
10
10
 
@@ -1,3 +1,3 @@
1
1
  module Geokdtree
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geokdtree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,17 +9,17 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-19 00:00:00.000000000 Z
12
+ date: 2013-02-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: rspec
15
+ name: rake
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
21
  version: '0'
22
- type: :development
22
+ type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
@@ -43,24 +43,57 @@ dependencies:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: ffi-compiler
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rspec
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
46
78
  description: Ruby & JRuby gem with a fast k-d tree C implementation using FFI bindings
47
79
  with support for latitude/longitude and geo distance range search
48
80
  email:
49
81
  - colin.surprenant@gmail.com
50
82
  executables: []
51
83
  extensions:
52
- - ext/geokdtree/extconf.rb
84
+ - ext/geokdtree/Rakefile
53
85
  extra_rdoc_files: []
54
86
  files:
55
87
  - .gitignore
88
+ - CHANGELOG.md
56
89
  - Gemfile
57
90
  - LICENSE.txt
58
91
  - README.md
59
92
  - Rakefile
60
93
  - example/usage.rb
94
+ - ext/geokdtree/Rakefile
61
95
  - ext/geokdtree/distance.c
62
96
  - ext/geokdtree/distance.h
63
- - ext/geokdtree/extconf.rb
64
97
  - ext/geokdtree/kdtree.c
65
98
  - ext/geokdtree/kdtree.h
66
99
  - geokdtree.gemspec
@@ -81,12 +114,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
81
114
  - - ! '>='
82
115
  - !ruby/object:Gem::Version
83
116
  version: '0'
117
+ segments:
118
+ - 0
119
+ hash: 1969207989393657853
84
120
  required_rubygems_version: !ruby/object:Gem::Requirement
85
121
  none: false
86
122
  requirements:
87
123
  - - ! '>='
88
124
  - !ruby/object:Gem::Version
89
125
  version: '0'
126
+ segments:
127
+ - 0
128
+ hash: 1969207989393657853
90
129
  requirements: []
91
130
  rubyforge_project:
92
131
  rubygems_version: 1.8.23
@@ -1,7 +0,0 @@
1
- require 'mkmf'
2
-
3
- $CFLAGS = "-pedantic -Wall -g -O3 -fPIC -g -DUSE_LIST_NODE_ALLOCATOR"
4
-
5
- have_library("pthread")
6
-
7
- create_makefile 'geokdtree'