Class: LicenseScout::DependencyManager::Berkshelf

Inherits:
Base
  • Object
show all
Defined in:
lib/license_scout/dependency_manager/berkshelf.rb

Instance Attribute Summary

Attributes inherited from Base

#directory

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from LicenseScout::DependencyManager::Base

Instance Method Details

#dependenciesObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/license_scout/dependency_manager/berkshelf.rb', line 44

def dependencies
  unless berkshelf_available?
    raise LicenseScout::Exceptions::Error.new("Project at '#{directory}' is a Berkshelf project but berkshelf gem is not available in your bundle. Add berkshelf to your bundle in order to collect licenses for this project.")
  end

  cookbook_dependencies = []

  Dir.chdir(directory) do
    berksfile = ::Berkshelf::Berksfile.from_file("./Berksfile")

    # Berkshelf should not give an error when there are cookbooks in the
    # lockfile that are no longer in the berksfile. It handles this case in
    # the Installer class which we are not using here. So we handle this
    # case in the same way Installer does.
    berksfile.lockfile.reduce!

    cookbook_dependencies = berksfile.list
  end

  cookbook_dependencies.map do |dep|
    new_dependency(dep.name, dep.cached_cookbook.version, dep.cached_cookbook.path.to_s)
  end.compact
end

#detected?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/license_scout/dependency_manager/berkshelf.rb', line 40

def detected?
  File.exist?(berksfile_path) && File.exist?(lockfile_path)
end

#install_commandObject



36
37
38
# File 'lib/license_scout/dependency_manager/berkshelf.rb', line 36

def install_command
  "berks install"
end

#nameObject



24
25
26
# File 'lib/license_scout/dependency_manager/berkshelf.rb', line 24

def name
  "chef_berkshelf"
end

#signatureObject



32
33
34
# File 'lib/license_scout/dependency_manager/berkshelf.rb', line 32

def signature
  "Berksfile and Berksfile.lock files"
end

#typeObject



28
29
30
# File 'lib/license_scout/dependency_manager/berkshelf.rb', line 28

def type
  "chef_cookbook"
end