Module: FasterPath::Platform

Defined in:
lib/faster_path/platform.rb

Class Method Summary collapse

Class Method Details

.ffi_libraryObject



4
5
6
7
8
9
10
11
12
# File 'lib/faster_path/platform.rb', line 4

def ffi_library
  file = [
    lib_prefix,
    "faster_path.",
    lib_suffix
  ]

  File.join(rust_release, file.join())
end

.host_osObject



55
56
57
# File 'lib/faster_path/platform.rb', line 55

def host_os
  RbConfig::CONFIG['host_os'].downcase
end

.lib_prefixObject



27
28
29
30
31
32
33
34
35
36
# File 'lib/faster_path/platform.rb', line 27

def lib_prefix
  case operating_system()
  when /windows/
    ''
  when /cygwin/
    'cyg'
  else
    'lib'
  end
end

.lib_suffixObject



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/faster_path/platform.rb', line 38

def lib_suffix
  case operating_system()
  when /darwin/
    'dylib'
  when /linux/
    'so'
  when /windows|cygwin/
    'dll'
  else
    'so'
  end
end

.operating_systemObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/faster_path/platform.rb', line 14

def operating_system
  case host_os()
  when /linux|bsd|solaris/
    "linux"
  when /darwin/
    "darwin"
  when /mingw|mswin/
    "windows"
  else
    host_os()
  end
end

.rust_releaseObject



51
52
53
# File 'lib/faster_path/platform.rb', line 51

def rust_release
  File.expand_path("../../target/release/", __dir__)
end