Class: LicenseScout::DependencyManager::Habitat

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

Constant Summary collapse

DEFAULT_CHANNEL =
"stable".freeze
FALLBACK_CHANNEL_FOR_FQ =
"unstable".freeze

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



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/license_scout/dependency_manager/habitat.rb', line 46

def dependencies
  tdeps = Set.new(pkg_deps)

  if pkg_deps.any?
    pkg_deps.each do |pkg_dep|
      unless pkg_info(pkg_dep).nil?
        pkg_info(pkg_dep)["tdeps"].each { |dep| tdeps << to_ident(dep) }
      end
    end

    tdeps.delete(nil)

    tdeps.sort.map do |tdep|
      o, n, v, r = tdep.split("/")
      dep_name = "#{o}/#{n}"
      dep_version = "#{v}-#{r}"

      dependency = new_dependency(dep_name, dep_version, nil)

      if pkg_info(tdep).nil?
        LicenseScout::Log.warn("Could not find information for #{tdep} -- skipping")
      else
        license_from_manifest(pkg_info(tdep)["manifest"]).each do |spdx|
          # We hard code the channel to "unstable" because a package could be
          # demoted from any given channel except unstable in the future and
          # we want the url metadata to be stable in order to give end users
          # the ability to self-audit licenses
          # tl;dr, we want a permalink not a nowlink
          dependency.add_license(spdx, "https://bldr.habitat.sh/v1/depot/channels/#{o}/unstable/pkgs/#{n}/#{v}/#{r}")
        end
      end

      dependency
    end.compact
  end
end

#detected?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/license_scout/dependency_manager/habitat.rb', line 42

def detected?
  File.exist?(plan_sh_path) || File.exist?(habitat_plan_sh_path)
end

#install_commandObject



38
39
40
# File 'lib/license_scout/dependency_manager/habitat.rb', line 38

def install_command
  ""
end

#nameObject



26
27
28
# File 'lib/license_scout/dependency_manager/habitat.rb', line 26

def name
  "habitat"
end

#signatureObject



34
35
36
# File 'lib/license_scout/dependency_manager/habitat.rb', line 34

def signature
  File.exist?(habitat_plan_sh_path) ? "habitat/plan.sh file" : "plan.sh file"
end

#typeObject



30
31
32
# File 'lib/license_scout/dependency_manager/habitat.rb', line 30

def type
  "habitat"
end