Method: LinuxStat::OS.distribution

Defined in:
lib/linux_stat/os.rb

.distributionObject

Reads /etc/lsb-release or /etc/os-release tries to get information about the distribution.

If the information isn’t available, it will read and return /etc/issue.

The return type is String. If none of the info is available, it will return an empty frozen String.



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/linux_stat/os.rb', line 50

def distribution
	@@distribution ||= if os_release.key?(:NAME)
		os_release[:NAME]
	else
		v = lsb_release

		if v.key?(:DISTRIB_DESCRIPTION)
			v[:DISTRIB_DESCRIPTION]
		elsif v.key?(:DISTRIB_ID)
			v[:DISTRIB_ID]
		elsif File.readable?('/etc/issue'.freeze)
			IO.read('/etc/issue'.freeze, encoding: 'ASCII-8bit'.freeze).strip
		else
			'Unknown'.freeze
		end
	end
end