Class: Vagrant::Puppetfile::Evaluator::Librarian

Inherits:
Base
  • Object
show all
Defined in:
lib/vagrant/puppetfile.rb

Constant Summary collapse

SUPPORTED_PUPPETFILE_NAMES =
%w{Puppetfile Modulefile metadata.json}

Constants inherited from Base

Base::ENV_CLEAN_KEYS

Instance Attribute Summary

Attributes inherited from Base

#logger, #path

Instance Method Summary collapse

Methods inherited from Base

#command, #initialize, #run, #with_clean_env

Constructor Details

This class inherits a constructor from Vagrant::Puppetfile::Evaluator::Base

Instance Method Details

#available?Boolean

Returns:

  • (Boolean)


233
234
235
236
237
# File 'lib/vagrant/puppetfile.rb', line 233

def available?
  command('version').last.success?
rescue SystemCallError
  false
end

#install(puppetfile) ⇒ Object



239
240
241
242
243
244
245
# File 'lib/vagrant/puppetfile.rb', line 239

def install(puppetfile)
  validate(puppetfile)
  dir = File.dirname(puppetfile)
  Dir.chdir(dir) do
    run('install', '--verbose')
  end
end

#validate(puppetfile) ⇒ Object



224
225
226
227
228
229
230
231
# File 'lib/vagrant/puppetfile.rb', line 224

def validate(puppetfile)
  super
  unless SUPPORTED_PUPPETFILE_NAMES.include? File.basename(puppetfile)
    logger.error("The 'librarian-puppet' evaluator cannot install from a file named #{puppetfile.inspect}")
    logger.error("Please use one of these names instead: #{SUPPORTED_PUPPETFILE_NAMES.map(&:inspect).join(', ')}")
    fail ConfigurationError, puppetfile
  end
end