Module: Opal::OS
- Defined in:
- opal/lib/opal/os.rb
Class Method Summary collapse
- .bash_c(*commands) ⇒ Object
- .cmd_sep ⇒ Object
- .dev_null ⇒ Object
- .env_sep ⇒ Object
- .macos? ⇒ Boolean
- .path_sep ⇒ Object
- .shellescape(str) ⇒ Object
- .windows? ⇒ Boolean
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 'opal/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_sep ⇒ Object
31 32 33 |
# File 'opal/lib/opal/os.rb', line 31 def cmd_sep windows? ? ' & ' : ' ; ' end |
.dev_null ⇒ Object
35 36 37 |
# File 'opal/lib/opal/os.rb', line 35 def dev_null windows? ? 'NUL' : '/dev/null' end |
.env_sep ⇒ Object
23 24 25 |
# File 'opal/lib/opal/os.rb', line 23 def env_sep windows? ? ';' : ':' end |
.macos? ⇒ Boolean
11 12 13 |
# File 'opal/lib/opal/os.rb', line 11 def macos? /darwin|mac os/.match?(RbConfig::CONFIG['host_os']) end |
.path_sep ⇒ Object
27 28 29 |
# File 'opal/lib/opal/os.rb', line 27 def path_sep windows? ? '\\' : '/' end |
.shellescape(str) ⇒ Object
15 16 17 18 19 20 21 |
# File 'opal/lib/opal/os.rb', line 15 def shellescape(str) if windows? '"' + str.gsub('"', '""') + '"' else str.shellescape end end |
.windows? ⇒ Boolean
7 8 9 |
# File 'opal/lib/opal/os.rb', line 7 def windows? /bccwin|cygwin|djgpp|mingw|mswin|wince/.match?(RbConfig::CONFIG['host_os']) end |