Sha256: cc8f2663c34438622b26a21edd3fba95fa297bf115c9e9b45fb93ba205e1b424

Contents?: true

Size: 1.56 KB

Versions: 9

Compression:

Stored size: 1.56 KB

Contents

require 'rbconfig'

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, :linux].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

        def arch?
          linux? &&
            File.exist?('/etc/rc.conf') &&
            File.exist?('/etc/pacman.conf') &&
            File.exist?('/etc/rc.d/')
        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

        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

9 entries across 9 versions & 2 rubygems

Version Path
vagrantup-0.8.5 lib/vagrant/util/platform.rb
vagrantup-0.8.4 lib/vagrant/util/platform.rb
vagrantup-0.8.3 lib/vagrant/util/platform.rb
vagrantup-0.8.2 lib/vagrant/util/platform.rb
vagrantup-0.8.1 lib/vagrant/util/platform.rb
vagrantup-0.8.0 lib/vagrant/util/platform.rb
vagrant-0.8.5 lib/vagrant/util/platform.rb
vagrant-0.8.2 lib/vagrant/util/platform.rb
vagrant-0.8.1 lib/vagrant/util/platform.rb