Module: Envkey::Platform

Defined in:
lib/envkey/platform.rb

Constant Summary collapse

OS =

Normalize the platform OS

case os = RbConfig::CONFIG['host_os'].downcase
when /linux/
  "linux"
when /darwin/
  "darwin"
when /bsd/
  "freebsd"
when /mingw|mswin/
  "windows"
else
  "linux"
end
ARCH =

Normalize the platform CPU

case cpu = RbConfig::CONFIG['host_cpu'].downcase
when /amd64|x86_64/
  "x86_64"
when /i?86|x86|i86pc/
  "x86"
when /ppc|powerpc/
  "powerpc"
when /^arm/
  "arm"
else
  cpu
end

Class Method Summary collapse

Class Method Details

.arch_partObject



39
40
41
# File 'lib/envkey/platform.rb', line 39

def self.arch_part
  ARCH == "x86_64" ? "amd64" : "386"
end

.extObject



43
44
45
# File 'lib/envkey/platform.rb', line 43

def self.ext
  platform_part == "windows" ? ".exe" : ""
end

.fetch_env_pathObject



47
48
49
# File 'lib/envkey/platform.rb', line 47

def self.fetch_env_path
  File.expand_path("../../ext/#{lib_file_dir}/envkey-fetch#{ext}", File.dirname(__FILE__))
end

.lib_file_dirObject



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

def self.lib_file_dir
  ["envkey-fetch", platform_part, arch_part].join("_")
end

.platform_partObject



30
31
32
33
34
35
36
37
# File 'lib/envkey/platform.rb', line 30

def self.platform_part
  case OS
    when "darwin", "linux", "windows", "freebsd"
      OS
    else
      "linux"
    end
end