Class: NativeFolder

Inherits:
Object
  • Object
show all
Defined in:
lib/jruby_art/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
WIN_PATTERNS =
[
  /bccwin/i,
  /cygwin/i,
  /djgpp/i,
  /ming/i,
  /mswin/i,
  /wince/i
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeNativeFolder

Returns a new instance of NativeFolder.



18
19
20
21
# File 'lib/jruby_art/native_folder.rb', line 18

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/jruby_art/native_folder.rb', line 5

def bit
  @bit
end

#osObject (readonly)

Returns the value of attribute os.



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

def os
  @os
end

Instance Method Details

#extensionObject



29
30
31
32
33
# File 'lib/jruby_art/native_folder.rb', line 29

def extension
  return '*.so' if os =~ /linux/
  return '*.dll' if WIN_PATTERNS.any? { |pat| pat =~ os }
  '*.dylib' # MacOS
end

#nameObject



23
24
25
26
27
# File 'lib/jruby_art/native_folder.rb', line 23

def name
  return 'macosx' if os =~ /darwin/ || os =~ /mac/
  return format(WIN_FORMAT, bit) if WIN_PATTERNS.any? { |pat| pat =~ os }
  return format(LINUX_FORMAT, bit) if os =~ /linux/
end