Class: NativeFolder

Inherits:
Object
  • Object
show all
Defined in:
lib/propane/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

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



18
19
20
21
# File 'lib/propane/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/propane/native_folder.rb', line 5

def bit
  @bit
end

#osObject (readonly)

Returns the value of attribute os.



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

def os
  @os
end

Instance Method Details

#extensionObject



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

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

#nameObject



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

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