Class: Kitchen::Provisioner::Chef::Librarian
- Inherits:
-
Object
- Object
- Kitchen::Provisioner::Chef::Librarian
- Includes:
- Logging
- Defined in:
- lib/kitchen/provisioner/chef/librarian.rb
Overview
Chef cookbook resolver that uses Librarian-Chef and a Cheffile to calculate # dependencies.
Instance Attribute Summary collapse
-
#cheffile ⇒ Object
readonly
Returns the value of attribute cheffile.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(cheffile, path, logger = Kitchen.logger) ⇒ Librarian
constructor
A new instance of Librarian.
- #resolve ⇒ Object
Constructor Details
#initialize(cheffile, path, logger = Kitchen.logger) ⇒ Librarian
Returns a new instance of Librarian.
37 38 39 40 41 |
# File 'lib/kitchen/provisioner/chef/librarian.rb', line 37 def initialize(cheffile, path, logger = Kitchen.logger) @cheffile = cheffile @path = path @logger = logger end |
Instance Attribute Details
#cheffile ⇒ Object (readonly)
Returns the value of attribute cheffile.
59 60 61 |
# File 'lib/kitchen/provisioner/chef/librarian.rb', line 59 def cheffile @cheffile end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
59 60 61 |
# File 'lib/kitchen/provisioner/chef/librarian.rb', line 59 def logger @logger end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
59 60 61 |
# File 'lib/kitchen/provisioner/chef/librarian.rb', line 59 def path @path end |
Class Method Details
.load!(logger = Kitchen.logger) ⇒ Object
43 44 45 |
# File 'lib/kitchen/provisioner/chef/librarian.rb', line 43 def self.load!(logger = Kitchen.logger) load_librarian!(logger) end |
.load_librarian!(logger) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/kitchen/provisioner/chef/librarian.rb', line 61 def self.load_librarian!(logger) first_load = require 'librarian/chef/environment' require 'librarian/action/resolve' require 'librarian/action/install' version = ::Librarian::Chef::VERSION if first_load logger.debug("Librarian-Chef #{version} library loaded") else logger.debug("Librarian-Chef #{version} previously loaded") end rescue LoadError => e logger.fatal("The `librarian-chef' gem is missing and must be installed" + " or cannot be properly activated. Run" + " `gem install librarian-chef` or add the following to your" + " Gemfile if you are using Bundler: `gem 'librarian-chef'`.") raise UserError, "Could not load or activate Librarian-Chef (#{e.message})" end |
Instance Method Details
#resolve ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/kitchen/provisioner/chef/librarian.rb', line 47 def resolve version = ::Librarian::Chef::VERSION info("Resolving cookbook dependencies with Librarian-Chef #{version}...") debug("Using Cheffile from #{cheffile}") env = ::Librarian::Chef::Environment.new( :project_path => File.dirname(cheffile)) env.config_db.local["path"] = path ::Librarian::Action::Resolve.new(env).run ::Librarian::Action::Install.new(env).run end |