Class: MediaWikiVagrant::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/mediawiki-vagrant/middleware.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ Middleware

Returns a new instance of Middleware



5
6
7
8
# File 'lib/mediawiki-vagrant/middleware.rb', line 5

def initialize(app, env)
  @app = app
  @mwv = Environment.new(env[:root_path])
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/mediawiki-vagrant/middleware.rb', line 10

def call(env)
  if @mwv.valid?
    @mwv.prune_roles

    # Add the name of the current provider to our puppet facts
    env[:machine].config.vm.provisioners.each do |provisioner|
      # Note that `VagrantPlugins::Kernel_V2::VagrantConfigProvisioner`
      # `#name` in Vagrant <= 1.6 is `#type` in Vagrant > 1.6 :/
      if (provisioner.name || provisioner.type) == :puppet
        provisioner.config.facter['provider_name'] = env[:machine].provider_name
      end
    end
  end

  @app.call(env)
end