Sha256: 2bf33b3abf5543cd140a975d7bba5fe153420245b6cd7e45d27fde2cfbb42659

Contents?: true

Size: 1.66 KB

Versions: 21

Compression:

Stored size: 1.66 KB

Contents

require 'rbconfig'
require 'tempfile'

module Vagrant
  module Util
    # This class just contains some platform checking code.
    class Platform
      class << self
        def tiger?
          platform.include?("darwin8")
        end

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

        [:darwin, :bsd, :freebsd, :linux, :solaris].each do |type|
          define_method("#{type}?") do
            platform.include?(type.to_s)
          end
        end

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

          false
        end

        # Returns boolean noting whether this is a 64-bit CPU. This
        # is not 100% accurate and there could easily be false negatives.
        #
        # @return [Boolean]
        def bit64?
          ["x86_64", "amd64"].include?(RbConfig::CONFIG["host_cpu"])
        end

        # Returns boolean noting whether this is a 32-bit CPU. This
        # can easily throw false positives since it relies on {#bit64?}.
        #
        # @return [Boolean]
        def bit32?
          !bit64?
        end

        # Returns a boolean noting whether the terminal supports color.
        # output.
        def terminal_supports_colors?
          if windows?
            return ENV.has_key?("ANSICON")
          end

          true
        end

        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

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

Version data entries

21 entries across 21 versions & 8 rubygems

Version Path
bmhatfield-vagrant-1.0.10 lib/vagrant/util/platform.rb
bmhatfield-vagrant-1.0.9 lib/vagrant/util/platform.rb
bmhatfield-vagrant-1.0.8 lib/vagrant/util/platform.rb
bmhatfield-vagrant-1.0.7 lib/vagrant/util/platform.rb
vagrantup-1.0.7 lib/vagrant/util/platform.rb
vagrantup-1.0.6 lib/vagrant/util/platform.rb
vagrantup-1.0.5 lib/vagrant/util/platform.rb
vagrantup-1.0.4 lib/vagrant/util/platform.rb
vagrantup-1.0.3 lib/vagrant/util/platform.rb
vagrantup-1.0.2 lib/vagrant/util/platform.rb
vagrant-fixed-ssh-1.0.7 lib/vagrant/util/platform.rb
vagrant-actionio-0.0.9 vendor/bundle/bundler/gems/vagrant-c74251a1d9c0/lib/vagrant/util/platform.rb
vagrant-lxc-0.0.1 vendor/vagrant/lib/vagrant/util/platform.rb
vagrant-1.0.7 lib/vagrant/util/platform.rb
vagrant-1.0.6 lib/vagrant/util/platform.rb
boxcar-0.10005.1 lib/vagrant/util/platform.rb
fragrant-0.0.5 vendor/bundle/ruby/1.9.1/gems/vagrant-1.0.5/lib/vagrant/util/platform.rb
vagrant-1.0.5 lib/vagrant/util/platform.rb
vagrant-1.0.4 lib/vagrant/util/platform.rb
vagrant-1.0.3 lib/vagrant/util/platform.rb