Sha256: ab2775d7fb4c5a6cddb321fb06e4dbe379a4609e7526d1b89399eb5c5136c91f

Contents?: true

Size: 1.16 KB

Versions: 7

Compression:

Stored size: 1.16 KB

Contents

require 'config_builder/model'

# Integration with ConfigBuilder 0.x and older
module VagrantHosts
  module ConfigBuilder
    class Model < ::ConfigBuilder::Model::Base

      # @!attribute [rw] hosts
      attr_accessor :hosts
      # @!attribute [rw] autoconfigure
      attr_accessor :autoconfigure
      # @!attribute [rw] add_localhost_hostnames
      attr_accessor :add_localhost_hostnames
      # @!attribute [rw] sync_hosts
      attr_accessor :sync_hosts

      def initialize
        @defaults = {
          :hosts => [],
        }
      end

      def to_proc
        Proc.new do |vm_config|
          vm_config.provision :hosts do |h_config|
            h_config.autoconfigure = attr(:autoconfigure) unless attr(:autoconfigure).nil?
            h_config.add_localhost_hostnames = attr(:add_localhost_hostnames) unless attr(:add_localhost_hostnames).nil?
            h_config.sync_hosts = attr(:sync_hosts) unless attr(:sync_hosts).nil?

            attr(:hosts).each do |(address, aliases)|
              h_config.add_host address, aliases
            end
          end
        end
      end

      ::ConfigBuilder::Model::Provisioner.register('hosts', self)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
vagrant-hosts-2.9.0 lib/vagrant-hosts/config_builder/0_x.rb
vagrant-hosts-2.8.3 lib/vagrant-hosts/config_builder/0_x.rb
vagrant-hosts-2.8.2 lib/vagrant-hosts/config_builder/0_x.rb
vagrant-hosts-2.8.1 lib/vagrant-hosts/config_builder/0_x.rb
vagrant-hosts-2.8.0 lib/vagrant-hosts/config_builder/0_x.rb
vagrant-hosts-2.7.1 lib/vagrant-hosts/config_builder/0_x.rb
vagrant-hosts-2.7.0 lib/vagrant-hosts/config_builder/0_x.rb