Sha256: c54378974f5a779937ea641bdc75bbed76af9a4bd50fc4fb5148184ec0953189

Contents?: true

Size: 1.08 KB

Versions: 8

Compression:

Stored size: 1.08 KB

Contents

module VagrantPlugins
  module GuestDarwin
    module Cap
      class DarwinVersion
        
        VERSION_REGEX = /\d+.\d+.?\d*/.freeze

        # Get the darwin version
        #
        # @param [Machine]
        # @return [String] version of drawin
        def self.darwin_version(machine)
          output = ""
          machine.communicate.sudo("sysctl kern.osrelease") do |_, data|
            output = data
          end
          output.scan(VERSION_REGEX).first
        end

        # Get the darwin major version
        #
        # @param [Machine]
        # @return [int] major version of drawin (nil if version is not detected)
        def self.darwin_major_version(machine)
          output = ""
          machine.communicate.sudo("sysctl kern.osrelease") do |_, data|
            output = data
          end
          version_string = output.scan(VERSION_REGEX).first
          if version_string
            major_version = version_string.split(".").first.to_i
          else
            major_version = nil
          end
          major_version
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
vagrant-unbundled-2.3.6.0 plugins/guests/darwin/cap/darwin_version.rb
tamtam-vagrant-reload-1.2.1 vendor/cache/vagrant-2092df529ae7/plugins/guests/darwin/cap/darwin_version.rb
vagrant-unbundled-2.3.3.0 plugins/guests/darwin/cap/darwin_version.rb
vagrant-unbundled-2.3.2.0 plugins/guests/darwin/cap/darwin_version.rb
vagrant-unbundled-2.2.19.0 plugins/guests/darwin/cap/darwin_version.rb
vagrant-unbundled-2.2.18.0 plugins/guests/darwin/cap/darwin_version.rb
vagrant-unbundled-2.2.16.0 plugins/guests/darwin/cap/darwin_version.rb
vagrant-unbundled-2.2.14.0 plugins/guests/darwin/cap/darwin_version.rb