Class: Nugrant::Vagrant::V2::Action::AutoExport

Inherits:
Object
  • Object
show all
Defined in:
lib/nugrant/vagrant/v2/action/auto_export.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ AutoExport

Returns a new instance of AutoExport.



12
13
14
15
# File 'lib/nugrant/vagrant/v2/action/auto_export.rb', line 12

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

Instance Method Details

#call(env) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/nugrant/vagrant/v2/action/auto_export.rb', line 17

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