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



62
63
64
# File 'lib/vagrant/util/platform.rb', line 62

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

.tar_file_optionsObject



57
58
59
60
# File 'lib/vagrant/util/platform.rb', line 57

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

.terminal_supports_colors?Boolean

Returns a boolean noting whether the terminal supports color. output.

Returns:

  • (Boolean)


49
50
51
52
53
54
55
# File 'lib/vagrant/util/platform.rb', line 49

def terminal_supports_colors?
  if windows?
    return ENV.has_key?("ANSICON")
  end

  true
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