Sha256: c162604ba66f3f15bb8e3c696f9dbcb53b97ec5b7c9f7ad7f7692365d2030e07

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 KB

Contents

require 'nugrant'
require 'nugrant/helper/env/exporter'
require 'nugrant/parameters'

module Nugrant
  module Vagrant
    module V2
      module Action
        EnvExporter = Nugrant::Helper::Env::Exporter

        class AutoExport
          def initialize(app, env)
            @app = app
            @config = env[:machine].env.vagrantfile.config
          end

          def call(env)
            return @app.call(env) if not @config.user.auto_export

            options = {
              :type => :export,
              :script_path => @config.user.auto_export_script_path
            }

            Array(@config.user.auto_export).each do |exporter|
              if exporter == :terminal or not EnvExporter.valid?(exporter)
                env[:ui].warn("ERROR: Invalid config.user.auto_export value '#{exporter}'", :prefix => false)
                next
              end

              env[:ui].info("Configuration exported '#{exporter}'", :prefix => false)

              case
              when exporter == :script
                EnvExporter.script_exporter(@config.user.__all, options)
              when exporter == :autoenv
                EnvExporter.autoenv_exporter(@config.user.__all, options)
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nugrant-2.1.3 lib/nugrant/vagrant/v2/action/auto_export.rb
nugrant-2.1.2 lib/nugrant/vagrant/v2/action/auto_export.rb
nugrant-2.1.1 lib/nugrant/vagrant/v2/action/auto_export.rb