Skip to content

Commit 923e82d

Browse files
committed
Added VERSION information and a spec to check that it matches config.h.
1 parent 46f238e commit 923e82d

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

src/ruby/flann.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
lib = File.expand_path('../lib/', __FILE__)
22
$:.unshift lib unless $:.include?(lib)
33

4-
# require 'flann/version'
4+
require 'flann/version'
55

66
Gem::Specification.new do |gem|
77
gem.name = "flann"
8-
gem.version = '0.0.1'
8+
gem.version = Flann::VERSION::STRING
99
gem.summary = "Ruby interface for FLANN, approximate nearest neighbors methods in C"
1010
gem.description = "Ruby interface for FLANN, approximate nearest neighbors methods in C"
1111
gem.homepage = 'http://www.cs.ubc.ca/research/flann/'

src/ruby/lib/flann.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
require 'ffi'
22
require 'nmatrix'
33

4+
require_relative "flann/version.rb"
45
require_relative "flann/index.rb"
56

7+
68
module Flann
79
extend FFI::Library
810
ffi_lib "libflann"

src/ruby/lib/flann/version.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module Flann
2+
module VERSION
3+
MAJOR = 1
4+
MINOR = 8
5+
TINY = 4
6+
MINISCULE = 1
7+
8+
STRING = [MAJOR, MINOR, TINY, MINISCULE].compact.join('.')
9+
end
10+
end

src/ruby/spec/flann_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
require File.dirname(__FILE__) + "/spec_helper.rb"
22

33
describe Flann do
4+
it "::VERSION::STRING matches #define FLANN_VERSION_ in config.h" do
5+
found = false
6+
File.open(File.dirname(__FILE__) + "/../../cpp/flann/config.h", "r") do |f|
7+
while line = f.gets
8+
next unless line =~ /#[\s]*define[\s]+FLANN_VERSION_[\s]+"\d.\d.\d"/
9+
fields = line.split
10+
found = true
11+
expect(fields.last[1...-1]).to eq(Flann::VERSION::STRING.split('.')[0...-1].join('.'))
12+
end
13+
end
14+
15+
raise("could not find version string in config.h") unless found
16+
end
17+
418
context "#set_distance_type!" do
519
it "sets the distance functor without error" do
620
pending "distance type unsupported in the C bindings, use the C++ bindings instead"

0 commit comments

Comments
 (0)