Module: StackCar::Os
- Defined in:
- lib/stack_car/os.rb
Class Method Summary collapse
- .arch? ⇒ Boolean
- .arch_cmd ⇒ Object
- .bash(command) ⇒ Object
- .fedora? ⇒ Boolean
- .fedora_cmd ⇒ Object
- .macos? ⇒ Boolean
- .ubuntu? ⇒ Boolean
- .ubuntu_cmd ⇒ Object
- .wsl? ⇒ Boolean
- .wsl_cmd ⇒ Object
Class Method Details
.arch? ⇒ Boolean
16 17 18 |
# File 'lib/stack_car/os.rb', line 16 def self.arch? self.bash(self.arch_cmd) end |
.arch_cmd ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'lib/stack_car/os.rb', line 54 def self.arch_cmd %q( if $(which lsb_release >/dev/null 2>&1); then lsb_release -d | grep --color=auto "Arch" > /dev/null else uname -a | grep --color=auto "ARCH" > /dev/null fi ) end |
.bash(command) ⇒ Object
4 5 6 |
# File 'lib/stack_car/os.rb', line 4 def self.bash(command) system("bash -c '#{command}'") end |
.fedora? ⇒ Boolean
12 13 14 |
# File 'lib/stack_car/os.rb', line 12 def self.fedora? self.bash(self.fedora_cmd) end |
.fedora_cmd ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/stack_car/os.rb', line 44 def self.fedora_cmd %q( if $(which lsb_release >/dev/null 2>&1); then lsb_release -d | grep --color=auto "Fedora" > /dev/null else uname -r | grep --color=auto "fc" > /dev/null fi ) end |
.macos? ⇒ Boolean
20 21 22 |
# File 'lib/stack_car/os.rb', line 20 def self.macos? self.bash('uname -a | grep "Darwin" > /dev/null') end |
.ubuntu? ⇒ Boolean
8 9 10 |
# File 'lib/stack_car/os.rb', line 8 def self.ubuntu? self.bash(self.ubuntu_cmd) end |
.ubuntu_cmd ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/stack_car/os.rb', line 34 def self.ubuntu_cmd %q( if $(which lsb_release >/dev/null 2>&1); then lsb_release -d | grep --color=auto "Ubuntu" > /dev/null else uname -a | grep --color=auto "Ubuntu" > /dev/null fi ) end |
.wsl? ⇒ Boolean
24 25 26 |
# File 'lib/stack_car/os.rb', line 24 def self.wsl? self.bash(self.wsl_cmd) end |
.wsl_cmd ⇒ Object
28 29 30 31 32 |
# File 'lib/stack_car/os.rb', line 28 def self.wsl_cmd %q( grep -i "microsoft\|wsl" /proc/version > /dev/null 2>&1 ) end |