Sha256: 3c9d490cf0bf68a98b8fdbdebd677c1bb91468ef91ddc0d2d635ec429dd94f30

Contents?: true

Size: 1.23 KB

Versions: 10

Compression:

Stored size: 1.23 KB

Contents

module Envkey::Platform
  # Normalize the platform OS
  OS = case os = RbConfig::CONFIG['host_os'].downcase
  when /linux/
    "linux"
  when /darwin/
    "darwin"
  when /bsd/
    "freebsd"
  when /mingw|mswin/
    "windows"
  else
    "linux"
  end

  # Normalize the platform CPU
  ARCH = 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|^aarch/
    "arm"
  else
    cpu
  end

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

  def self.arch_part
    if (platform_part == "darwin" || platform_part == "linux") && ARCH == "arm"
      "arm64"
    elsif ARCH == "x86_64"
      "amd64"
    else
      raise "As of 1.3.0, envkey-ruby only supports 64-bit systems. Please use an earlier version for 32-bit support."
    end
  end

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

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

  def self.lib_file_dir
    ["envkey-source", Envkey::ENVKEY_SOURCE_VERSION.to_s, platform_part, arch_part].join("_")
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
envkey-2.4.2 lib/envkey/platform.rb
envkey-2.4.0 lib/envkey/platform.rb
envkey-2.3.0 lib/envkey/platform.rb
envkey-2.1.0 lib/envkey/platform.rb
envkey-2.0.10 lib/envkey/platform.rb
envkey-2.0.9 lib/envkey/platform.rb
envkey-2.0.8 lib/envkey/platform.rb
envkey-2.0.7 lib/envkey/platform.rb
envkey-2.0.6 lib/envkey/platform.rb
envkey-2.0.5 lib/envkey/platform.rb