Sha256: 307bf723c579a30a492ef98f82af62115b4ed6d766cc52a1e179c0e2372bf2e3

Contents?: true

Size: 1.6 KB

Versions: 9

Compression:

Stored size: 1.6 KB

Contents

module VagrantPlugins
  module Parallels
    class Config < Vagrant.plugin("2", :config)
      attr_reader :customizations
      attr_accessor :destroy_unused_network_interfaces
      attr_reader :network_adapters
      attr_accessor :name

      def initialize
        @customizations   = []
        @destroy_unused_network_interfaces = UNSET_VALUE
        @network_adapters  = {}
        @name             = UNSET_VALUE

        network_adapter(0, :shared)
      end

      def customize(*command)
        event   = command.first.is_a?(String) ? command.shift : "pre-boot"
        command = command[0]
        @customizations << [event, command]
      end

      def network_adapter(slot, type, *args)
        @network_adapters[slot] = [type, args]
      end

      def finalize!
        if @destroy_unused_network_interfaces == UNSET_VALUE
          @destroy_unused_network_interfaces = true
        end

        @name = nil if @name == UNSET_VALUE
      end

      def validate(machine)
        errors = []
        valid_events = ["pre-import", "pre-boot", "post-boot"]
        @customizations.each do |event, _|
          if !valid_events.include?(event)
            errors << I18n.t(
              "vagrant_parallels.config.invalid_event",
              event: event.to_s,
              valid_events: valid_events.join(", "))
          end
        end
        @customizations.each do |event, command|
          if event == "pre-import" && command.index(:id)
            errors << I18n.t("vagrant_parallels.config.id_in_pre_import")
          end
        end

        { "Parallels Provider" => errors }

      end

    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
vagrant-parallels-0.1.3 lib/vagrant-parallels/config.rb
vagrant-parallels-0.1.2 lib/vagrant-parallels/config.rb
vagrant-parallels-0.1.1 lib/vagrant-parallels/config.rb
vagrant-parallels-0.1.0 lib/vagrant-parallels/config.rb
vagrant-parallels-0.0.9 lib/vagrant-parallels/config.rb
vagrant-parallels-0.0.8 lib/vagrant-parallels/config.rb
vagrant-parallels-0.0.7 lib/vagrant-parallels/config.rb
vagrant-parallels-0.0.6 lib/vagrant-parallels/config.rb
vagrant-parallels-0.0.5 lib/vagrant-parallels/config.rb