Sha256: 7e49f707bfbadf0513096227a1adf667f8fcbba2b00b136da0f41621c3198468

Contents?: true

Size: 1.36 KB

Versions: 2

Compression:

Stored size: 1.36 KB

Contents

module VagrantPlugins
  module PluginBundler
    module Action
      # This middleware checks if reqiured plugins are present
      class Check

        def initialize(app, env)
          @app    = app
          @installed_plugins = {}
        end

        def call(env)
          
          # check plugins
          #output = `D:/Repos/_github/bills-kitchen/target/build/tools/vagrant/HashiCorp/Vagrant/bin/vagrant plugin list`
          output = `vagrant plugin list`
          
          output.each_line do |line|
            name, version = line.match(/\s*(\S+)\s*\((\S+)\)/).captures
            @installed_plugins[name]=version
          end

          env[:machine].config.plugin.dependencies.each do |plugin, required_version|

            installed_version = @installed_plugins[plugin]
            
            unless installed_version
              raise Errors::PluginNotFoundError, 
                :required_version => required_version, 
                :plugin => plugin
            end
            
            if required_version != installed_version
              raise Errors::PluginVersionError, 
                :required_version => required_version, 
                :plugin => plugin,
                :installed_version => installed_version
            end
          end       

          # continue if ok
          @app.call(env)

        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vagrant-plugin-bundler-0.1.1 lib/vagrant-plugin-bundler/action/check.rb
vagrant-plugin-bundler-0.1.0 lib/vagrant-plugin-bundler/action/check.rb