Class: NativeFolder
- Inherits:
-
Object
- Object
- NativeFolder
- Defined in:
- lib/picrate/native_folder.rb
Overview
Utility to load native binaries on Java CLASSPATH
Constant Summary collapse
- WIN_FORMAT =
'windows%d'.freeze
- LINUX_FORMAT =
'linux%d'.freeze
- ARM32 =
'-armv6hf'.freeze
- ARM64 =
'-aarch64'.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
WIN_PATTERNS = [ /bccwin/i, /cygwin/i, /djgpp/i, /ming/i, /mswin/i, /wince/i ].freeze.
- #name ⇒ Object
Constructor Details
#initialize ⇒ NativeFolder
WIN_PATTERNS = [
/bccwin/i,
/cygwin/i,
/djgpp/i,
/ming/i,
/mswin/i,
/wince/i
].freeze
20 21 22 23 |
# File 'lib/picrate/native_folder.rb', line 20 def initialize @os = RbConfig::CONFIG['host_os'].downcase @bit = java.lang.System.get_property('os.arch') =~ /64/ ? 64 : 32 end |
Instance Attribute Details
#bit ⇒ Object (readonly)
Returns the value of attribute bit.
5 6 7 |
# File 'lib/picrate/native_folder.rb', line 5 def bit @bit end |
#os ⇒ Object (readonly)
Returns the value of attribute os.
5 6 7 |
# File 'lib/picrate/native_folder.rb', line 5 def os @os end |
Instance Method Details
#extension ⇒ Object
31 32 33 34 |
# File 'lib/picrate/native_folder.rb', line 31 def extension return '*.so' if os =~ /linux/ '*.dylib' # MacOS end |
#name ⇒ Object
25 26 27 28 29 |
# File 'lib/picrate/native_folder.rb', line 25 def name return 'macosx' if os =~ /darwin/ || os =~ /mac/ return format(LINUX_FORMAT, ARM32) if os =~ /^arm/ return format(LINUX_FORMAT, bit) if os =~ /linux/ end |