Class: Bibliothecary::PurlUtil

Inherits:
Object
  • Object
show all
Defined in:
lib/bibliothecary/purl_util.rb

Constant Summary collapse

PURL_TYPE_MAPPING =

If a purl type (key) exists, it will be used in a manifest for the key’s value. If not, it’s ignored.

github.com/package-url/purl-spec/blob/master/PURL-TYPES.rst

{
  "golang" => :go,
  "maven" => :maven,
  "npm" => :npm,
  "cargo" => :cargo,
  "composer" => :packagist,
  "conda" => :conda,
  "cran" => :cran,
  "gem" => :rubygems,
  "hackage" => :hackage,
  "hex" => :hex,
  "nuget" => :nuget,
  "pypi" => :pypi,
  "swift" => :swift_pm,
}.freeze

Class Method Summary collapse

Class Method Details

.full_name(purl) ⇒ String

Returns The properly namespaced package name.

Parameters:

  • purl (PackageURL)

Returns:

  • (String)

    The properly namespaced package name



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/bibliothecary/purl_util.rb', line 26

def self.full_name(purl)
  return nil if purl.nil?

  parts = [purl.namespace, purl.name].compact

  case purl.type
  when "maven"
    parts.join(":")
  else
    parts.join("/")
  end
end