Sha256: b0f016fae9c1b45d0b1c1236b55d3f1373429ddad8849e57b795f533b462ea10

Contents?: true

Size: 779 Bytes

Versions: 19

Compression:

Stored size: 779 Bytes

Contents

require 'log4r'

module Vagrant
  module Hosts
    # This method detects the correct host based on the `match?` methods
    # implemented in the registered hosts.
    #
    # @param [Hash] registry Hash mapping key to host class
    def self.detect(registry)
      logger = Log4r::Logger.new("vagrant::hosts")

      # Sort the hosts by their precedence
      host_klasses = registry.values.sort_by { |a| a.precedence }.reverse
      logger.debug("Host path search classes: #{host_klasses.inspect}")

      # Test for matches and return the host class that matches
      host_klasses.each do |klass|
        if klass.match?
          logger.info("Host class: #{klass}")
          return klass
        end
      end

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

Version data entries

19 entries across 19 versions & 6 rubygems

Version Path
tamtam-vagrant-reload-1.1.3 vendor/cache/vagrant-0ac2a8738841/lib/vagrant/hosts.rb
tamtam-vagrant-reload-1.1.2 vendor/cache/vagrant-0ac2a8738841/lib/vagrant/hosts.rb
tamtam-vagrant-reload-1.1.1 vendor/cache/vagrant-0ac2a8738841/lib/vagrant/hosts.rb
tamtam-vagrant-reload-1.1 vendor/cache/vagrant-0ac2a8738841/lib/vagrant/hosts.rb
tnargav-1.3.6 lib/vagrant/hosts.rb
tnargav-1.3.3 lib/vagrant/hosts.rb
vagrant-shell-0.2.9 demo/templates/vendor/bundle/ruby/1.9.1/gems/tnargav-1.2.2/lib/vagrant/hosts.rb
tnargav-1.2.3 lib/vagrant/hosts.rb
vagrant-shell-0.2.8 demo/templates/vendor/bundle/ruby/1.9.1/gems/tnargav-1.2.2/lib/vagrant/hosts.rb
vagrant-shell-0.2.6 vendor/bundle/gems/tnargav-1.2.2/lib/vagrant/hosts.rb
vagrant-shell-0.2.5 vendor/bundle/gems/tnargav-1.2.2/lib/vagrant/hosts.rb
tnargav-1.2.2 lib/vagrant/hosts.rb
vagrantup-1.1.3 lib/vagrant/hosts.rb
vagrantup-1.1.2 lib/vagrant/hosts.rb
vagrantup-1.1.1 lib/vagrant/hosts.rb
vagrantup-1.1.0 lib/vagrant/hosts.rb
vagrantup-1.1.4 lib/vagrant/hosts.rb
vagrant-actionio-0.0.9 vendor/bundle/bundler/gems/vagrant-c74251a1d9c0/lib/vagrant/hosts.rb
vagrant-lxc-0.0.1 vendor/vagrant/lib/vagrant/hosts.rb