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

Returns a new instance of NativeFolder.



10
11
12
13
# File 'lib/picrate/native_folder.rb', line 10

def initialize
  @os = java.lang.System.get_property('os.name').downcase
  @bit = java.lang.System.get_property('os.arch')
end

Instance Attribute Details

#bitObject (readonly)

Returns the value of attribute bit.



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

def bit
  @bit
end

#osObject (readonly)

Returns the value of attribute os.



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

def os
  @os
end

Instance Method Details

#extensionObject



24
25
26
# File 'lib/picrate/native_folder.rb', line 24

def extension
  '*.so'
end

#nameObject

Raises:

  • (RuntimeError)


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

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