Class: NativeFolder
- Inherits:
-
Object
- Object
- NativeFolder
- Defined in:
- lib/propane/native_folder.rb
Overview
Utility to load native binaries on Java CLASSPATH
Constant Summary collapse
- WIN_FORMAT =
'windows%d'
- LINUX_FORMAT =
'linux%d'
- WIN_PATTERNS =
[ /bccwin/i, /cygwin/i, /djgpp/i, /ming/i, /mswin/i, /wince/i ].freeze
Instance Attribute Summary collapse
-
#bit ⇒ Object
readonly
Returns the value of attribute bit.
-
#os ⇒ Object
readonly
Returns the value of attribute os.
Instance Method Summary collapse
- #extension ⇒ Object
-
#initialize ⇒ NativeFolder
constructor
A new instance of NativeFolder.
- #name ⇒ Object
Constructor Details
#initialize ⇒ NativeFolder
Returns a new instance of NativeFolder.
20 21 22 23 |
# File 'lib/propane/native_folder.rb', line 20 def initialize @os = RbConfig::CONFIG['host_os'].downcase @bit = /64/.match?(java.lang.System.get_property('os.arch')) ? 64 : 32 end |
Instance Attribute Details
#bit ⇒ Object (readonly)
Returns the value of attribute bit.
7 8 9 |
# File 'lib/propane/native_folder.rb', line 7 def bit @bit end |
#os ⇒ Object (readonly)
Returns the value of attribute os.
7 8 9 |
# File 'lib/propane/native_folder.rb', line 7 def os @os end |
Instance Method Details
#extension ⇒ Object
33 34 35 36 37 38 |
# File 'lib/propane/native_folder.rb', line 33 def extension return '*.so' if /linux/.match?(os) return '*.dll' if WIN_PATTERNS.any? { |pat| pat.match?(os) } '*.dylib' # MacOS end |
#name ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/propane/native_folder.rb', line 25 def name return 'macosx' if /darwin|mac/.match?(os) return format(LINUX_FORMAT, bit) if /linux/.match?(os) return format(WIN_FORMAT, bit) if WIN_PATTERNS.any? { |pat| pat.match?(os) } raise 'Unsupported Architecture' end |