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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeNativeFolder

ARM64 = ‘-aarch64’.freeze



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



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

def extension
  '*.so'
end

#nameObject

Raises:



17
18
19
20
21
22
23
# 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)
  end
  raise RuntimeError, "Unsupported Archicture"
end