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



84
85
86
# File 'lib/command_kit/os/linux.rb', line 84

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



154
155
156
# File 'lib/command_kit/os/linux.rb', line 154

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



132
133
134
# File 'lib/command_kit/os/linux.rb', line 132

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



121
122
123
# File 'lib/command_kit/os/linux.rb', line 121

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



97
98
99
100
101
# File 'lib/command_kit/os/linux.rb', line 97

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



110
111
112
# File 'lib/command_kit/os/linux.rb', line 110

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



143
144
145
# File 'lib/command_kit/os/linux.rb', line 143

def suse_linux?
  @linux_distro == :suse
end