Skip to content

Commit

Permalink
Merge pull request #38 from jelera/master
Browse files Browse the repository at this point in the history
Add Linux-specific OS#parse_os_release method
  • Loading branch information
rdp committed Dec 31, 2019
2 parents bc1a7c2 + 9fa704f commit 765a416
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/os.rb
Expand Up @@ -282,6 +282,20 @@ def self.app_config_path(name)
end
end

def self.parse_os_release
if OS.linux? && File.exist?('/etc/os-release')
output = {}

File.read('/etc/os-release').each_line do |line|
parsed_line = line.chomp.tr('"', '').split('=')
output[parsed_line[0].to_sym] = parsed_line[1]
end
output
else
raise "File /etc/os-release doesn't exists or not Linux"
end
end

class << self
alias :doze? :windows? # a joke name but I use it and like it :P
alias :jruby? :java?
Expand Down

0 comments on commit 765a416

Please sign in to comment.