lib/upm/tool_class_methods.rb in upm-0.1.14 vs lib/upm/tool_class_methods.rb in upm-0.1.15
- old
+ new
@@ -8,13 +8,14 @@
Dir["#{__dir__}/tools/*.rb"].each { |lib| require_relative(lib) }
end
def os_release
@os_release ||= begin
- open("/etc/os-release") do |io|
+ pairs = open("/etc/os-release") do |io|
io.read.scan(/^(\w+)="?(.+?)"?$/)
- end.to_h
+ end
+ Hash[pairs]
rescue Errno::ENOENT
{}
end
end
@@ -42,17 +43,17 @@
os_names = os_names ? [os_names].flatten : current_os_names
tool = nil
if os_names.any?
- tool = @@tools.find { |name, tool| os_names.any? { |name| tool.os.include? name } }&.last
+ tool = @@tools.find { |name, tool| os_names.any? { |name| tool.os.include? name } }
end
if tool.nil?
- tool = @@tools.find { |name, tool| File.which(tool.identifying_binary) }&.last
+ tool = @@tools.find { |name, tool| File.which(tool.identifying_binary) }
end
- tool
+ tool.last
end
end
end
end