Skip to content

Commit

Permalink
Supported older interface for backward compatibility.
Browse files Browse the repository at this point in the history
      and older interface displays "FuzzyStringMatch.new.create() is obsolute, please use FuzzyStringMatch.create() ..."
  • Loading branch information
kiyoka committed Feb 15, 2012
1 parent f396aea commit ce69e4c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/fuzzystringmatch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
require 'fuzzystringmatch/pure'
begin
if RUBY_PLATFORM == "java"
STDERR.puts "Warning: native version is disabled on java platform. falled back to pure ruby version..."
STDERR.puts "fuzzy-string-match Warning: native version is disabled on java platform. falled back to pure ruby version..."
else
require 'fuzzystringmatch/inline'
end
Expand All @@ -35,10 +35,14 @@ def self.create( type = :pure ) # factory method
begin
FuzzyStringMatch::JaroWinklerInline.new
rescue NameError
STDERR.puts "Warning: native version is disabled. falled back to pure ruby version..."
STDERR.puts "fuzzy-string-match Warning: native version is disabled. falled back to pure ruby version..."
FuzzyStringMatch::JaroWinklerPure.new
end
end
end
def create( type = :pure ) # this is obsolute
STDERR.puts "fuzzy-string-match Warning: FuzzyStringMatch.new.create() is obsolute, please use FuzzyStringMatch.create() ..."
FuzzyStringMatch::JaroWinkler.create( type )
end
end
end
10 changes: 10 additions & 0 deletions test/basic_native_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,13 @@
@jarow.pure?( ).should == (RUBY_PLATFORM == "java")
end
end

describe FuzzyStringMatch, "when older factory method was called, (Pure) are" do
before do
@jarow = FuzzyStringMatch::JaroWinkler.new.create
end
it "should" do
@jarow.getDistance( "henka", "henkan" ).should be_within(0.0001).of(0.9722)
@jarow.pure?( ).should be_true
end
end
10 changes: 10 additions & 0 deletions test/basic_pure_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,13 @@
@jarow.pure?( ).should be_true
end
end

describe FuzzyStringMatch, "when older factory method was called, (Pure) are" do
before do
@jarow = FuzzyStringMatch::JaroWinkler.new.create
end
it "should" do
@jarow.getDistance( "henka", "henkan" ).should be_within(0.0001).of(0.9722)
@jarow.pure?( ).should be_true
end
end

0 comments on commit ce69e4c

Please sign in to comment.