Skip to content

Commit

Permalink
Adds hard coded plugin list so Vagrantfiles can be slimmed down by on…
Browse files Browse the repository at this point in the history
…ly passing a simple plugin name list to Bib::Vagrant.check_plugins. easybib/issues#5384
  • Loading branch information
seppsepp committed Feb 9, 2016
1 parent 64b2292 commit b4caa75
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions lib/bib/bib_vagrant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,31 @@ module Vagrant
# Checks for plugins and takes a plugin list plus optional true/false for checking some
# _esoteric_ plugin constellation, see Bib::Vagrant#check_esoteric_plugin_constellation.
#
# ==== Example
# ==== Example where given plugins are all mandatory (plugins are given as an array)
#
# Bib::Vagrant.check_plugins(['landrush', 'vagrant-hosts'])
#
# ==== Example where a plugin may be mandatory but doesn't need to (plugins are given as a hash)
#
# Bib::Vagrant.check_plugins(
# {
# 'landrush' => {
# 'url' => 'https://github.com/phinze/landrush',
# 'mandatory' => true
# },
# 'vagrant-hosts' => {
# 'url' => 'https://github.com/adrienthebo/vagrant-hosts',
# 'mandatory' => true
# 'landrush' => true,
# 'vagrant-hosts' => false
# },
# false
# true
# )
def self.check_plugins(plugins, check_esoteric_plugin_constellation = true)
complete = true

plugins.each do |plugin, info|
plugins.each do |plugin, mandatory|
next if ::Vagrant.has_plugin?(plugin)
next if ENV['VAGRANT_CI']
url = info['url']
puts "!!! - You are missing a plugin: #{plugin}"
puts '---'
puts "### - Please run: vagrant plugin install #{plugin}"
puts '---'
puts "!!! - Read more here: #{url}"
complete = false if info['mandatory']
puts "!!! - Read more here: #{plugin_list[plugin]}"
complete = false if mandatory
end

if check_esoteric_plugin_constellation
Expand Down Expand Up @@ -61,5 +59,17 @@ def self.check_esoteric_plugin_constellation

complete
end

# Returns an array which lists plugins to check where index is the name of the plugin and value
# is the url where the user can get more information about it.
def self.plugin_list
{
'landrush' => 'https://github.com/phinze/landrush',
'vagrant-hosts' => 'https://github.com/adrienthebo/vagrant-hosts',
'vagrant-faster' => 'https://github.com/rdsubhas/vagrant-faster#how-much-does-it-allocate',
'vagrant-cachier' => 'https://github.com/easybib/issues/wiki/Knowledgebase:-Global-Vagrant-setup#enable-vagrant-cachier-globally',
'bib-vagrant' => 'See https://github.com/easybiblabs/bib-vagrant/blob/master/README.md'
}
end
end
end

0 comments on commit b4caa75

Please sign in to comment.