Method: LinuxStat::OS.os_release

Defined in:
lib/linux_stat/os.rb

.os_releaseObject

Reads /etc/os-release and returns a Hash. For example:

LinuxStat::OS.os_release

=> {:NAME=>"Arch Linux", :PRETTY_NAME=>"Arch Linux", :ID=>"arch", :BUILD_ID=>"rolling",

:ANSI_COLOR=>“38;2;23;147;209”, :HOME_URL=>“www.archlinux.org/”, :DOCUMENTATION_URL=>“wiki.archlinux.org/”, :SUPPORT_URL=>“bbs.archlinux.org/”, :BUG_REPORT_URL=>“bugs.archlinux.org/”, :LOGO=>“archlinux”}

If the info isn’t available, it will return an empty Hash.

The amount of data read is 4096 bytes. Any more than that will result in truncated output.

The information is also cached, and once loaded, won’t change in runtime. Because changing the /etc/lsb-release isn’t expected in runtime.



23
24
25
# File 'lib/linux_stat/os.rb', line 23

def os_release
	@@os_release ||= File.readable?('/etc/os-release') ? release('/etc/os-release') : {}
end