Sha256: 31b4a5fe6f3518932fbb2ab1182b356fb69f4ec9be28e0aea93337118e7c53e3

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

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

EnvExporter = Nugrant::Helper::Env::Exporter

module Nugrant
  module Vagrant
    module V2
      module Action
        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 '#{format}'", :prefix => false)
                next
              end

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nugrant-2.1.0 lib/nugrant/vagrant/v2/action/auto_export.rb