Module: CommandKit::OS::Linux

Extended by:
ModuleMethods
Included in:
PackageManager
Defined in:
lib/command_kit/os/linux.rb

Overview

Provides methods for determining the specific type of Linux.

Example

require 'command_kit/command'
require 'command_kit/os/linux'

class Command < CommandKit::Command

  include CommandKit::OS::Linux

  def run
    if debian_linux?
      # ...
    elsif redhat_linux?
      # ...
    elsif suse_linux?
      # ...
    elsif arch_linux?
      # ...
    end
  end
end

Since:

  • 0.2.0

Defined Under Namespace

Modules: ClassMethods, ModuleMethods

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ModuleMethods

included

Instance Attribute Details

#linux_distro:fedora, ... (readonly)

The Linux distro.

Returns:

  • (:fedora, :redhat, :debian, :suse, :arch, nil)

Since:

  • 0.2.0



82
83
84
# File 'lib/command_kit/os/linux.rb', line 82

def linux_distro
  @linux_distro
end

Instance Method Details

#arch_linux?Boolean

Determines if the current OS is Arch Linux based distro.

Returns:

  • (Boolean)

Since:

  • 0.2.0



152
153
154
# File 'lib/command_kit/os/linux.rb', line 152

def arch_linux?
  @linux_distro == :arch
end

#debian_linux?Boolean

Determines if the current OS is Debian Linux based distro.

Returns:

  • (Boolean)

Since:

  • 0.2.0



130
131
132
# File 'lib/command_kit/os/linux.rb', line 130

def debian_linux?
  @linux_distro == :debian
end

#fedora_linux?Boolean

Determines if the current OS is Fedora Linux based distro.

Returns:

  • (Boolean)

Since:

  • 0.2.0



119
120
121
# File 'lib/command_kit/os/linux.rb', line 119

def fedora_linux?
  @linux_distro == :fedora
end

#initialize(linux_distro: self.class.linux_distro, **kwargs) ⇒ Object

Initializes the command.

Parameters:

  • linux_distro (:fedora, :redhat, :debian, :suse, :arch, nil) (defaults to: self.class.linux_distro)

    Overrides the default detected Linux distro.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

Since:

  • 0.2.0



95
96
97
98
99
# File 'lib/command_kit/os/linux.rb', line 95

def initialize(linux_distro: self.class.linux_distro, **kwargs)
  super(**kwargs)

  @linux_distro = linux_distro
end

#redhat_linux?Boolean

Determines if the current OS is RedHat Linux based distro.

Returns:

  • (Boolean)

Since:

  • 0.2.0



108
109
110
# File 'lib/command_kit/os/linux.rb', line 108

def redhat_linux?
  @linux_distro == :redhat
end

#suse_linux?Boolean

Determines if the current OS is SUSE Linux based distro.

Returns:

  • (Boolean)

Since:

  • 0.2.0



141
142
143
# File 'lib/command_kit/os/linux.rb', line 141

def suse_linux?
  @linux_distro == :suse
end