Module: ScreenRecorder::OS Private

Defined in:
lib/screen-recorder/os.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0.beta11

Class Method Summary collapse

Class Method Details

.cygwin?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

Since:

  • 1.0.0.beta11



67
68
69
# File 'lib/screen-recorder/os.rb', line 67

def cygwin?
  RUBY_PLATFORM.include?('cygwin')
end

.cygwin_path(path, only_cygwin: false, **opts) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0.beta11



75
76
77
78
79
80
81
82
# File 'lib/screen-recorder/os.rb', line 75

def cygwin_path(path, only_cygwin: false, **opts)
  return path if only_cygwin && !cygwin?

  flags = []
  opts.each { |k, v| flags << "--#{k}" if v }

  `cygpath #{flags.join ' '} "#{path}"`.strip
end

.engineObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0.beta11



10
11
12
# File 'lib/screen-recorder/os.rb', line 10

def engine
  @engine ||= RUBY_ENGINE.to_sym
end

.homeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0.beta11



6
7
8
# File 'lib/screen-recorder/os.rb', line 6

def home
  @home ||= Dir.home
end

.jruby?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

Since:

  • 1.0.0.beta11



30
31
32
# File 'lib/screen-recorder/os.rb', line 30

def jruby?
  engine == :jruby
end

.linux?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

Since:

  • 1.0.0.beta11



50
51
52
# File 'lib/screen-recorder/os.rb', line 50

def linux?
  os == :linux
end

.mac?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

Since:

  • 1.0.0.beta11



46
47
48
# File 'lib/screen-recorder/os.rb', line 46

def mac?
  os == :macosx
end

.null_deviceObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0.beta11



71
72
73
# File 'lib/screen-recorder/os.rb', line 71

def null_device
  File::NULL
end

.osObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0.beta11



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/screen-recorder/os.rb', line 14

def os
  host_os = RbConfig::CONFIG['host_os']
  @os ||= case host_os
          when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
            :windows
          when /darwin|mac os/
            :macosx
          when /linux/
            :linux
          when /solaris|bsd/
            :unix
          else
            raise Error::WebDriverError, "unknown os: #{host_os.inspect}"
          end
end

.ruby_versionObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0.beta11



38
39
40
# File 'lib/screen-recorder/os.rb', line 38

def ruby_version
  RUBY_VERSION
end

.truffleruby?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

Since:

  • 1.0.0.beta11



34
35
36
# File 'lib/screen-recorder/os.rb', line 34

def truffleruby?
  engine == :truffleruby
end

.unix?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

Since:

  • 1.0.0.beta11



54
55
56
# File 'lib/screen-recorder/os.rb', line 54

def unix?
  os == :unix
end

.unix_path(path) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0.beta11



84
85
86
# File 'lib/screen-recorder/os.rb', line 84

def unix_path(path)
  path.tr(File::ALT_SEPARATOR, File::SEPARATOR)
end

.windows?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

Since:

  • 1.0.0.beta11



42
43
44
# File 'lib/screen-recorder/os.rb', line 42

def windows?
  os == :windows
end

.windows_path(path) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0.beta11



88
89
90
# File 'lib/screen-recorder/os.rb', line 88

def windows_path(path)
  path.tr(File::SEPARATOR, File::ALT_SEPARATOR)
end

.wsl?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

Since:

  • 1.0.0.beta11



58
59
60
61
62
63
64
65
# File 'lib/screen-recorder/os.rb', line 58

def wsl?
  return false unless linux?

  File.read('/proc/version').downcase.include?('microsoft')
rescue Errno::EACCES
  # the file cannot be accessed on Linux on DeX
  false
end