Skip to content

Commit

Permalink
Added VERSION information and a spec to check that it matches config.h.
Browse files Browse the repository at this point in the history
  • Loading branch information
translunar committed Mar 6, 2014
1 parent 46f238e commit 923e82d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ruby/flann.gemspec
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
lib = File.expand_path('../lib/', __FILE__)
$:.unshift lib unless $:.include?(lib)

# require 'flann/version'
require 'flann/version'

Gem::Specification.new do |gem|
gem.name = "flann"
gem.version = '0.0.1'
gem.version = Flann::VERSION::STRING
gem.summary = "Ruby interface for FLANN, approximate nearest neighbors methods in C"
gem.description = "Ruby interface for FLANN, approximate nearest neighbors methods in C"
gem.homepage = 'http://www.cs.ubc.ca/research/flann/'
Expand Down
2 changes: 2 additions & 0 deletions src/ruby/lib/flann.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
require 'ffi'
require 'nmatrix'

require_relative "flann/version.rb"
require_relative "flann/index.rb"


module Flann
extend FFI::Library
ffi_lib "libflann"
Expand Down
10 changes: 10 additions & 0 deletions src/ruby/lib/flann/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Flann
module VERSION
MAJOR = 1
MINOR = 8
TINY = 4
MINISCULE = 1

STRING = [MAJOR, MINOR, TINY, MINISCULE].compact.join('.')
end
end
14 changes: 14 additions & 0 deletions src/ruby/spec/flann_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
require File.dirname(__FILE__) + "/spec_helper.rb"

describe Flann do
it "::VERSION::STRING matches #define FLANN_VERSION_ in config.h" do
found = false
File.open(File.dirname(__FILE__) + "/../../cpp/flann/config.h", "r") do |f|
while line = f.gets
next unless line =~ /#[\s]*define[\s]+FLANN_VERSION_[\s]+"\d.\d.\d"/
fields = line.split
found = true
expect(fields.last[1...-1]).to eq(Flann::VERSION::STRING.split('.')[0...-1].join('.'))
end
end

raise("could not find version string in config.h") unless found
end

context "#set_distance_type!" do
it "sets the distance functor without error" do
pending "distance type unsupported in the C bindings, use the C++ bindings instead"
Expand Down

0 comments on commit 923e82d

Please sign in to comment.