Top Level Namespace

Defined Under Namespace

Modules: Commonmarker

Constant Summary collapse

PACKAGE_ROOT_DIR =
File.expand_path(File.join(File.dirname(__FILE__), "..", ".."))
PACKAGE_EXT_DIR =
File.join(PACKAGE_ROOT_DIR, "ext", "commonmarker")
OS =
case os = RbConfig::CONFIG["host_os"].downcase
when /linux/
  # The official ruby-alpine Docker containers pre-build Ruby. As a result,
  # Ruby doesn't know that it's on a musl-based platform. `ldd` is the
  # a more reliable way to detect musl.
  # See https://github.com/skylightio/skylight-ruby/issues/92
  if ENV["SKYLIGHT_MUSL"] || %x(ldd --version 2>&1).include?("musl")
    "linux-musl"
  else
    "linux"
  end
when /darwin/
  "darwin"
when /freebsd/
  "freebsd"
when /netbsd/
  "netbsd"
when /openbsd/
  "openbsd"
when /sunos|solaris/
  "solaris"
when /mingw|mswin/
  "windows"
else
  os
end
ARCH =

Normalize the platform CPU

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

Instance Method Summary collapse

Instance Method Details

#abs_path(path) ⇒ Object



87
88
89
# File 'ext/commonmarker/_util.rb', line 87

def abs_path(path)
  File.join(PACKAGE_EXT_DIR, path)
end

#aix?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'ext/commonmarker/_util.rb', line 71

def aix?
  OS == "aix"
end

#concat_flags(*args) ⇒ Object



99
100
101
# File 'ext/commonmarker/_util.rb', line 99

def concat_flags(*args)
  args.compact.join(" ")
end

#darwin?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'ext/commonmarker/_util.rb', line 59

def darwin?
  OS == "darwin"
end

#find_header_or_abort(header, *paths) ⇒ Object



91
92
93
# File 'ext/commonmarker/_util.rb', line 91

def find_header_or_abort(header, *paths)
  find_header(header, *paths) || abort("#{header} was expected in `#{paths.join(", ")}`, but it is missing.")
end

#find_library_or_abort(lib, func, *paths) ⇒ Object



95
96
97
# File 'ext/commonmarker/_util.rb', line 95

def find_library_or_abort(lib, func, *paths)
  find_library(lib, func, *paths) || abort("#{lib} was expected in `#{paths.join(", ")}`, but it is missing.")
end

#macos?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'ext/commonmarker/_util.rb', line 63

def macos?
  darwin? || OS == "macos"
end

#nix?Boolean

Returns:

  • (Boolean)


75
76
77
# File 'ext/commonmarker/_util.rb', line 75

def nix?
  !(windows? || solaris? || darwin?)
end

#openbsd?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'ext/commonmarker/_util.rb', line 67

def openbsd?
  OS == "openbsd"
end

#solaris?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'ext/commonmarker/_util.rb', line 55

def solaris?
  OS == solaries
end

#windows?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'ext/commonmarker/_util.rb', line 51

def windows?
  OS == "windows"
end

#x86?Boolean

Returns:

  • (Boolean)


83
84
85
# File 'ext/commonmarker/_util.rb', line 83

def x86?
  ARCH == "x86"
end

#x86_64?Boolean

Returns:

  • (Boolean)


79
80
81
# File 'ext/commonmarker/_util.rb', line 79

def x86_64?
  ARCH == "x86_64"
end