Skip to content

Commit

Permalink
Fall back to pure ruby implementation on LoadError
Browse files Browse the repository at this point in the history
  • Loading branch information
milch committed Jun 13, 2019
1 parent f150853 commit 49f811e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/jaro_winkler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
require 'jaro_winkler/version'

if RUBY_ENGINE == 'ruby'
require 'jaro_winkler/jaro_winkler_ext'
begin
require 'jaro_winkler/jaro_winkler_ext'
rescue LoadError
# Fall back to the pure implementation if the extension
# can't be loaded for any reason (e.g. it was never built)
require 'jaro_winkler/jaro_winkler_pure'
end
else
require 'jaro_winkler/jaro_winkler_pure'
end

0 comments on commit 49f811e

Please sign in to comment.