Module: Dory::Os

Defined in:
lib/dory/os.rb

Class Method Summary collapse

Class Method Details

.arch?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/dory/os.rb', line 15

def self.arch?
  self.bash(self.arch_cmd)
end

.arch_cmdObject



43
44
45
46
47
48
49
50
51
# File 'lib/dory/os.rb', line 43

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



3
4
5
# File 'lib/dory/os.rb', line 3

def self.bash(command)
  system("bash -c '#{command}'")
end

.fedora?Boolean

Returns:

  • (Boolean)


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

def self.fedora?
  self.bash(self.fedora_cmd)
end

.fedora_cmdObject



33
34
35
36
37
38
39
40
41
# File 'lib/dory/os.rb', line 33

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

Returns:

  • (Boolean)


19
20
21
# File 'lib/dory/os.rb', line 19

def self.macos?
  self.bash('uname -a | grep "Darwin" > /dev/null')
end

.ubuntu?Boolean

Returns:

  • (Boolean)


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

def self.ubuntu?
  self.bash(self.ubuntu_cmd)
end

.ubuntu_cmdObject



23
24
25
26
27
28
29
30
31
# File 'lib/dory/os.rb', line 23

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