Module: CSD::Extensions::Gem::Platform

Included in:
Gem::Platform
Defined in:
lib/csd/extensions/gem/platform.rb

Overview

This module comprises extensions to the Array object.

Instance Method Summary collapse

Instance Method Details

#debian?Boolean

Determines whether the OS is Debian or Ubuntu. Returns true or false.

Returns:

  • (Boolean)


21
22
23
# File 'lib/csd/extensions/gem/platform.rb', line 21

def debian?
  kernel_version and kernel_version =~ /Debian|Ubuntu/
end

#humanizeObject

This method returns a human-readable string for the current OS and CPU architecture.



14
15
16
17
# File 'lib/csd/extensions/gem/platform.rb', line 14

def humanize
  version_string = version ? ", version #{version}" : ''
  "#{os} (#{cpu}#{version_string})"
end

#kernel_releaseObject

On linux systems, this method returns the current kernel release.



45
46
47
# File 'lib/csd/extensions/gem/platform.rb', line 45

def kernel_release
  Cmd.run('uname --kernel-release', :internal => true, :force_in_reveal => true).output.to_s.chop if os == 'linux'
end

#kernel_versionObject

On linux systems, this method returns the current kernel version.



39
40
41
# File 'lib/csd/extensions/gem/platform.rb', line 39

def kernel_version
  Cmd.run('uname --kernel-version', :internal => true, :force_in_reveal => true).output.to_s.chop if os == 'linux'
end

#ubuntu?Boolean

Determines whether the OS is Ubuntu. Returns true or false.

Returns:

  • (Boolean)


27
28
29
# File 'lib/csd/extensions/gem/platform.rb', line 27

def ubuntu?
  kernel_version and kernel_version =~ /Ubuntu/
end

#ubuntu_10?Boolean

Determines whether the OS is Ubuntu 10. Returns true or false.

Returns:

  • (Boolean)


33
34
35
# File 'lib/csd/extensions/gem/platform.rb', line 33

def ubuntu_10?
  ubuntu? and %w{ 2.6.32-21-generic 2.6.32-22-generic }.include?(kernel_release)
end