Sha256: 5e2350f54cb351cebf5d7083c025193aabed84ac84b59a9f8597ec9d24151187

Contents?: true

Size: 1020 Bytes

Versions: 8

Compression:

Stored size: 1020 Bytes

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/
    "arm"
  else
    cpu
  end

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

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

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

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

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

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
envkey-1.2.6 lib/envkey/platform.rb
envkey-1.2.4 lib/envkey/platform.rb
envkey-1.2.2 lib/envkey/platform.rb
envkey-1.2.1 lib/envkey/platform.rb
envkey-1.2.0 lib/envkey/platform.rb
envkey-1.1.0 lib/envkey/platform.rb
envkey-1.0.1 lib/envkey/platform.rb
envkey-1.0.0 lib/envkey/platform.rb