Class: NativeFolder
- Inherits:
-
Object
- Object
- NativeFolder
- Defined in:
- lib/jruby_art/native_folder.rb
Overview
Utility to load native binaries on Java CLASSPATH HACK until jruby returns a more specific ‘host_os’ than ‘linux’
Constant Summary collapse
- LINUX_FORMAT =
'linux%<bit>d'
- WIN_FORMAT =
ARM64 = ‘-aarch64’
'windows%<bit>d'
- WIN_PATTERNS =
[ /bccwin/i, /cygwin/i, /djgpp/i, /ming/i, /mswin/i, /wince/i ].freeze
Instance Attribute Summary collapse
-
#bit ⇒ Object
readonly
Returns the value of attribute bit.
-
#os ⇒ Object
readonly
Returns the value of attribute os.
Instance Method Summary collapse
- #extension ⇒ Object
-
#initialize ⇒ NativeFolder
constructor
A new instance of NativeFolder.
- #name ⇒ Object
Constructor Details
#initialize ⇒ NativeFolder
Returns a new instance of NativeFolder.
22 23 24 25 |
# File 'lib/jruby_art/native_folder.rb', line 22 def initialize @os = RbConfig::CONFIG['host_os'].downcase @bit = /64/.match?(java.lang.System.get_property('os.arch')) ? 64 : 32 end |
Instance Attribute Details
#bit ⇒ Object (readonly)
Returns the value of attribute bit.
8 9 10 |
# File 'lib/jruby_art/native_folder.rb', line 8 def bit @bit end |
#os ⇒ Object (readonly)
Returns the value of attribute os.
8 9 10 |
# File 'lib/jruby_art/native_folder.rb', line 8 def os @os end |
Instance Method Details
#extension ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/jruby_art/native_folder.rb', line 39 def extension return '*.so' if /linux/.match?(os) return '*.dll' if WIN_PATTERNS.any? { |pat| pat.match?(os) } '*.dylib' # MacOS end |
#name ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/jruby_art/native_folder.rb', line 27 def name return macos if /darwin|mac/.match?(os) return format(LINUX_FORMAT, bit: bit) if /linux/.match?(os) unless WIN_PATTERNS.any? { |pat| pat.match?(os) } raise StandardError, 'Unsupported Architecture' end format(WIN_FORMAT, bit: bit) end |