Module: Siding::Platform

Defined in:
lib/siding/platform.rb

Constant Summary collapse

UNIX_SOCKET_PATH_LIMIT =
104

Class Method Summary collapse

Class Method Details

.descriptionObject



29
30
31
32
33
34
35
# File 'lib/siding/platform.rb', line 29

def description
  return "Linux" if linux?
  return "macOS" if macos?
  return "Windows" if windows?

  host_os.to_s
end

.host_osObject



11
# File 'lib/siding/platform.rb', line 11

def host_os = RbConfig::CONFIG["host_os"]

.linux?Boolean

Returns:

  • (Boolean)


12
# File 'lib/siding/platform.rb', line 12

def linux? = host_os.match?(/linux/i)

.macos?Boolean

Returns:

  • (Boolean)


13
# File 'lib/siding/platform.rb', line 13

def macos? = host_os.match?(/darwin/i)

.supported?Boolean

Returns:

  • (Boolean)


15
# File 'lib/siding/platform.rb', line 15

def supported? = linux? || macos?

.unsupported_reasonObject



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/siding/platform.rb', line 17

def unsupported_reason
  return nil if supported?

  if windows?
    "Windows is not supported: it provides neither fork() with copy-on-write nor " \
      "file-descriptor passing over Unix domain sockets. Commands run unaccelerated."
  else
    "Unrecognized platform #{host_os.inspect}. Only Linux and macOS are supported. " \
      "Commands run unaccelerated."
  end
end

.windows?Boolean

Returns:

  • (Boolean)


14
# File 'lib/siding/platform.rb', line 14

def windows? = host_os.match?(/mswin|mingw|cygwin/i)