2

I am well aware that you can check your current OS using the os gem. But what I have not found is how to get the specific OS version. For example, if I am running the Ruby project on Windows 8.1, I want Windows 8.1 to be printed instead of just Windows.

2 Answers2

0

I've take a look on the specs of OS gem and unfortunately I couldn't find such method or attribute for that.

One alternative: you can execute your own system calls (via cocaine gem):

  1. on linux you can find through lsb-release or other methods
  2. on OSX: sw_vers -productVersion
  3. On Windows ver through command.

Perhaps you can try to add it on the gem itself create a new PR?

AndreDurao
  • 5,600
  • 7
  • 41
  • 61
0

Try using the gem sys-uname : https://rubygems.org/gems/sys-uname

require 'sys/uname'
include Sys

class Test
  puts Uname.uname
end

This is the output:

....., build_number="7601", build_type="Multiprocessor Free", caption="Microsoft Windows 7 Professional ", code_set="1252", country_code="1", creation_class_name="Win32_OperatingSystem", cscreation_class_name="Win32_ComputerSystem", csd_version="Service Pack 1", ...

plus other details

Sid
  • 408
  • 4
  • 7