Class: Vagrant::Util::Platform
- Inherits:
-
Object
- Object
- Vagrant::Util::Platform
- Defined in:
- lib/vagrant/util/platform.rb
Overview
This class just contains some platform checking code.
Class Method Summary collapse
-
.bit32? ⇒ Boolean
Returns boolean noting whether this is a 32-bit CPU.
-
.bit64? ⇒ Boolean
Returns boolean noting whether this is a 64-bit CPU.
- .cygwin? ⇒ Boolean
- .leopard? ⇒ Boolean
- .platform ⇒ Object
-
.platform_path(path) ⇒ String
This takes as input a path as a string and converts it into a platform-friendly version of the path.
- .tar_file_options ⇒ Object
-
.terminal_supports_colors? ⇒ Boolean
Returns a boolean noting whether the terminal supports color.
- .tiger? ⇒ Boolean
- .windows? ⇒ Boolean
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?.
49 50 51 |
# File 'lib/vagrant/util/platform.rb', line 49 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.
41 42 43 |
# File 'lib/vagrant/util/platform.rb', line 41 def bit64? ["x86_64", "amd64"].include?(RbConfig::CONFIG["host_cpu"]) end |
.cygwin? ⇒ Boolean
19 20 21 |
# File 'lib/vagrant/util/platform.rb', line 19 def cygwin? platform.include?("cygwin") end |
.leopard? ⇒ Boolean
15 16 17 |
# File 'lib/vagrant/util/platform.rb', line 15 def leopard? platform.include?("darwin9") end |
.platform ⇒ Object
81 82 83 |
# File 'lib/vagrant/util/platform.rb', line 81 def platform RbConfig::CONFIG["host_os"].downcase end |
.platform_path(path) ⇒ String
This takes as input a path as a string and converts it into a platform-friendly version of the path. This is most important when using the path in shell environments with Cygwin.
59 60 61 62 63 64 |
# File 'lib/vagrant/util/platform.rb', line 59 def platform_path(path) return path if !cygwin? process = Subprocess.execute("cygpath", "-u", path.to_s) process.stdout.chomp end |
.tar_file_options ⇒ Object
76 77 78 79 |
# File 'lib/vagrant/util/platform.rb', line 76 def # 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.
68 69 70 71 72 73 74 |
# File 'lib/vagrant/util/platform.rb', line 68 def terminal_supports_colors? if windows? return ENV.has_key?("ANSICON") end true end |
.tiger? ⇒ Boolean
11 12 13 |
# File 'lib/vagrant/util/platform.rb', line 11 def tiger? platform.include?("darwin8") end |
.windows? ⇒ Boolean
29 30 31 32 33 34 35 |
# File 'lib/vagrant/util/platform.rb', line 29 def windows? %W[mingw mswin].each do |text| return true if platform.include?(text) end false end |