Module: Opal::OS

Defined in:
lib/opal/os.rb

Class Method Summary collapse

Class Method Details

.bash_c(*commands) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/opal/os.rb', line 39

def bash_c(*commands)
  cmd = if windows?
          [
            'bundle',
            'exec',
            'cmd',
            '/c',
          ]
        else
          [
            'bundle',
            'exec',
            'bash',
            '-c',
          ]
        end

  cmd << commands.join(cmd_sep)
end

.cmd_sepObject



31
32
33
# File 'lib/opal/os.rb', line 31

def cmd_sep
  windows? ? ' & ' : ' ; '
end

.dev_nullObject



35
36
37
# File 'lib/opal/os.rb', line 35

def dev_null
  windows? ? 'NUL' : '/dev/null'
end

.env_sepObject



23
24
25
# File 'lib/opal/os.rb', line 23

def env_sep
  windows? ? ';' : ':'
end

.macos?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/opal/os.rb', line 11

def macos?
  /darwin|mac os/.match?(RbConfig::CONFIG['host_os'])
end

.path_sepObject



27
28
29
# File 'lib/opal/os.rb', line 27

def path_sep
  windows? ? '\\' : '/'
end

.shellescape(str) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/opal/os.rb', line 15

def shellescape(str)
  if windows?
    '"' + str.gsub('"', '""') + '"'
  else
    str.shellescape
  end
end

.windows?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/opal/os.rb', line 7

def windows?
  /bccwin|cygwin|djgpp|mingw|mswin|wince/.match?(RbConfig::CONFIG['host_os'])
end