Sha256: e01a8d8a7855f373742dfd5017e44105275f13fadc466c35ed5aa48dccb5d077

Contents?: true

Size: 863 Bytes

Versions: 8

Compression:

Stored size: 863 Bytes

Contents

module Vagrant
  module Hosts
    autoload :Base,    'vagrant/hosts/base'
    autoload :Arch,    'vagrant/hosts/arch'
    autoload :BSD,     'vagrant/hosts/bsd'
    autoload :FreeBSD, 'vagrant/hosts/freebsd'
    autoload :Fedora,  'vagrant/hosts/fedora'
    autoload :Linux,   'vagrant/hosts/linux'
    autoload :Windows, 'vagrant/hosts/windows'

    # This method detects the correct host based on the `match?` methods
    # implemented in the registered hosts.
    def self.detect(registry)
      # Sort the hosts by their precedence
      host_klasses = registry.to_hash.values
      host_klasses = host_klasses.sort_by { |a| a.precedence }.reverse

      # Test for matches and return the host class that matches
      host_klasses.each do |klass|
        return klass if klass.match?
      end

      # No matches found...
      return nil
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
vagrantup-0.9.3 lib/vagrant/hosts.rb
vagrantup-0.9.2 lib/vagrant/hosts.rb
vagrantup-0.9.1 lib/vagrant/hosts.rb
vagrantup-0.9.0 lib/vagrant/hosts.rb
vagrant-0.9.3 lib/vagrant/hosts.rb
vagrant-0.9.2 lib/vagrant/hosts.rb
vagrant-0.9.1 lib/vagrant/hosts.rb
vagrant-0.9.0 lib/vagrant/hosts.rb