Class: NativeFolder

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeNativeFolder

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

#bitObject (readonly)

Returns the value of attribute bit.



5
6
7
# File 'lib/picrate/native_folder.rb', line 5

def bit
  @bit
end

#osObject (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

#extensionObject



31
32
33
34
# File 'lib/picrate/native_folder.rb', line 31

def extension
  return '*.so' if os =~ /linux/
  '*.dylib' # MacOS
end

#nameObject



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