Sha256: c0ad4d019afce7c8d6669ff6012bfbb3056ab8e5c762c29e2c65019d38e5e417

Contents?: true

Size: 928 Bytes

Versions: 5

Compression:

Stored size: 928 Bytes

Contents

module Bibliothecary
  class PurlUtil
    # If a purl type (key) exists, it will be used in a manifest for
    # the key's value. If not, it's ignored.
    #
    # https://github.com/package-url/purl-spec/blob/master/PURL-TYPES.rst
    PURL_TYPE_MAPPING = {
      "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


    # @param purl [PackageURL]
    # @return [String] The properly namespaced package name
    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
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
bibliothecary-11.0.1 lib/bibliothecary/purl_util.rb
bibliothecary-11.0.0 lib/bibliothecary/purl_util.rb
bibliothecary-10.2.4 lib/bibliothecary/purl_util.rb
bibliothecary-10.2.3 lib/bibliothecary/purl_util.rb
bibliothecary-10.2.2 lib/bibliothecary/purl_util.rb