Class: Vagrant::Util::Platform

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant/util/platform.rb

Overview

This class just contains some platform checking code.

Class Method Summary collapse

Class Method Details

.bit32?Boolean

Returns boolean noting whether this is a 32-bit CPU. This can easily throw false positives since it relies on #bit64?.

Returns:

  • (Boolean)


43
44
45
# File 'lib/vagrant/util/platform.rb', line 43

def bit32?
  !bit64?
end

.bit64?Boolean

Returns boolean noting whether this is a 64-bit CPU. This is not 100% accurate and there could easily be false negatives.

Returns:

  • (Boolean)


35
36
37
# File 'lib/vagrant/util/platform.rb', line 35

def bit64?
  ["x86_64", "amd64"].include?(RbConfig::CONFIG["host_cpu"])
end

.leopard?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/vagrant/util/platform.rb', line 13

def leopard?
  platform.include?("darwin9")
end

.platformObject



52
53
54
# File 'lib/vagrant/util/platform.rb', line 52

def platform
  RbConfig::CONFIG["host_os"].downcase
end

.tar_file_optionsObject



47
48
49
50
# File 'lib/vagrant/util/platform.rb', line 47

def tar_file_options
  # create, write only, fail if the file exists, binary if windows
  File::WRONLY|File::EXCL|File::CREAT|(Mario::Platform.windows? ? File::BINARY : 0)
end

.tiger?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/vagrant/util/platform.rb', line 9

def tiger?
  platform.include?("darwin8")
end

.windows?Boolean

Returns:

  • (Boolean)


23
24
25
26
27
28
29
# File 'lib/vagrant/util/platform.rb', line 23

def windows?
  %W[mingw mswin].each do |text|
    return true if platform.include?(text)
  end

  false
end