Sha256: 4392d4fd21144e8a5aff227cd1cc121df538849edd80e5f95250a9daaa9461f0

Contents?: true

Size: 1.56 KB

Versions: 16

Compression:

Stored size: 1.56 KB

Contents

module VagrantPlugins
  module Invade
    module Builder
      module Plugin

        require 'erubis'

        class HostManager

          attr_reader :result
          attr_accessor :machine_name, :ui, :hostmanager_data

          def initialize(machine_name, ui, hostmanager_data, result: nil)
            @machine_name = machine_name
            @hostmanager_data = hostmanager_data
            @ui = ui
            @result = result
          end

          def build

            unless Vagrant.has_plugin?('vagrant-hostmanager')
              @ui.error("[Invade] Plugin 'vagrant-hostmanager' not installed but defined. Use 'vagrant plugin install vagrant-hostmanager' to install it.")
              @result = ""
            else

              b = binding
              template_file = "#{TEMPLATE_PATH}/plugin/hostmanager.erb"

              begin

                # Get machine name
                machine_name = @machine_name

                # Values for hostmanager section
                enabled = @hostmanager_data['enabled']
                manage_host = @hostmanager_data['manage_host']
                ignore_private_ip = @hostmanager_data['ignore_private_ip']
                include_offline =@hostmanager_data['include_offline']
                aliases = @hostmanager_data['aliases']

                eruby = Erubis::Eruby.new(File.read(template_file))
                @result = eruby.result b
              rescue TypeError, SyntaxError, SystemCallError => e
                raise(e)
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
vagrant-invade-0.5.5 lib/vagrant-invade/builder/plugin/hostmanager.rb
vagrant-invade-0.5.4 lib/vagrant-invade/builder/plugin/hostmanager.rb
vagrant-invade-0.5.3 lib/vagrant-invade/builder/plugin/hostmanager.rb
vagrant-invade-0.5.2 lib/vagrant-invade/builder/plugin/hostmanager.rb
vagrant-invade-0.5.1 lib/vagrant-invade/builder/plugin/hostmanager.rb
vagrant-invade-0.5.0 lib/vagrant-invade/builder/plugin/hostmanager.rb
vagrant-invade-0.4.8 lib/vagrant-invade/builder/plugin/hostmanager.rb
vagrant-invade-0.4.7 lib/vagrant-invade/builder/plugin/hostmanager.rb
vagrant-invade-0.4.6 lib/vagrant-invade/builder/plugin/hostmanager.rb
vagrant-invade-0.4.5 lib/vagrant-invade/builder/plugin/hostmanager.rb
vagrant-invade-0.4.4 lib/vagrant-invade/builder/plugin/hostmanager.rb
vagrant-invade-0.4.3 lib/vagrant-invade/builder/plugin/hostmanager.rb
vagrant-invade-0.4.2 lib/vagrant-invade/builder/plugin/hostmanager.rb
vagrant-invade-0.4.1 lib/vagrant-invade/builder/plugin/hostmanager.rb
vagrant-invade-0.4.0 lib/vagrant-invade/builder/plugin/hostmanager.rb
vagrant-invade-0.4.0.pre.alpha lib/vagrant-invade/builder/plugin/hostmanager.rb