lib/idnx.rb in idnx-0.0.1 vs lib/idnx.rb in idnx-0.1.0

- old
+ new

@@ -2,11 +2,11 @@ require_relative "idnx/version" require "ffi" module Idnx - Error = Class.new(StandardError) + class Error < StandardError; end module_function def to_punycode(hostname) Lib.lookup(hostname) @@ -14,7 +14,13 @@ end if FFI::Platform.windows? require "idnx/windows" else - require "idnx/idn2" + begin + require "idnx/idn2" + rescue LoadError + # fallback to pure ruby punycode 2003 implementation + require "idnx/ruby" + Idnx::Lib = Idnx::Ruby + end end