Class: LicenseScout::DependencyManager::Cpanm

Inherits:
Base
  • Object
show all
Defined in:
lib/license_scout/dependency_manager/cpanm.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



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/license_scout/dependency_manager/cpanm.rb', line 47

def dependencies
  Dir.glob("#{cpanm_root}/latest-build/*").map do |dep_path|
    next unless File.directory?(dep_path)

    dep_data = manifest(dep_path)
    metafile = dep_data["metafile"]
    dep_name = dep_data["name"]
    dep_version = dep_data["version"]

    dependency = new_dependency(dep_name, dep_version, dep_path)

    # CPANM projects contain license metadata - include it!
    unless dep_data["license"].nil?
      Array(dep_data["license"]).each do |license|
        next if license == "unknown"

        dependency.add_license(license, metafile)
      end
    end

    dependency
  end.compact
end

#detected?Boolean

NOTE: it’s possible that projects won’t have a META.yml, but the two that we care about for Chef Server do have one. As of 2015, 84% of perl distribution packages have one: neilb.org/2015/10/18/spotters-guide.html

Returns:

  • (Boolean)


43
44
45
# File 'lib/license_scout/dependency_manager/cpanm.rb', line 43

def detected?
  File.exist?(meta_json_path) || File.exist?(meta_yml_path)
end

#install_commandObject



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

def install_command
  "cpanm --installdeps ."
end

#nameObject



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

def name
  "perl_cpanm"
end

#signatureObject



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

def signature
  File.exist?(meta_json_path) ? "META.json file" : "META.yml file"
end

#typeObject



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

def type
  "perl"
end