Skip to content

Commit c318501

Browse files
create FFI modules separately
so one does not have to remove the constant as a fallback of an error
1 parent f91e100 commit c318501

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

lib/idnx.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ def to_punycode(hostname)
2121
rescue LoadError
2222
# fallback to pure ruby punycode 2003 implementation
2323
require "idnx/ruby"
24-
Idnx.send(:remove_const, :Lib)
25-
Idnx::Lib = Idnx::Ruby
24+
Lib = Ruby
2625
end
2726
end

lib/idnx/idn2.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
module Idnx
4-
module Lib
4+
module Idn2
55
extend FFI::Library
66

77
if FFI::Platform.mac?
@@ -55,4 +55,6 @@ def lookup(hostname)
5555
ascii
5656
end
5757
end
58+
59+
Lib = Idn2
5860
end

lib/idnx/windows.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
require "win32ole"
44

55
module Idnx
6-
module Lib
6+
module Windows
77
extend FFI::Library
88

99
ffi_lib "Normaliz.dll"
@@ -102,4 +102,6 @@ def lookup(hostname)
102102
unicode.strip! # remove null-byte
103103
end
104104
end
105+
106+
Lib = Windows
105107
end

0 commit comments

Comments
 (0)