Class: NativeFolder

Inherits:
Object
  • Object
show all
Defined in:
lib/picrate/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%s'.freeze
ARM32 =
'-armv6hf'.freeze
ARM64 =
'-aarch64'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeNativeFolder



12
13
14
15
# File 'lib/picrate/native_folder.rb', line 12

def initialize
  @os = RbConfig::CONFIG['host_os'].downcase
  @bit = java.lang.System.get_property('os.arch')
end

Instance Attribute Details

#bitObject (readonly)

Returns the value of attribute bit.



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

def bit
  @bit
end

#osObject (readonly)

Returns the value of attribute os.



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

def os
  @os
end

Instance Method Details

#extensionObject



26
27
28
# File 'lib/picrate/native_folder.rb', line 26

def extension
  '*.so'
end

#nameObject

Raises:

  • (RuntimeError)


17
18
19
20
21
22
23
24
# File 'lib/picrate/native_folder.rb', line 17

def name
  if /linux/.match?(os)
    return format(LINUX_FORMAT, '64') if /amd64/.match?(bit)
    return format(LINUX_FORMAT, ARM32) if /arm/.match?(bit)
    return format(LINUX_FORMAT, ARM64) if /aarch/.match?(bit)
  end
  raise RuntimeError, "Unsupported Architecture"
end