Sha256: 3a0d3af48210ae167eb23975719d9db678c06896a9fbe2518c4e3b2e2eb54b68

Contents?: true

Size: 809 Bytes

Versions: 24

Compression:

Stored size: 809 Bytes

Contents

# frozen_string_literal: true

require 'license_finder/package'

module LicenseFinder
  class GoPackage < Package
    def package_manager
      'Go'
    end

    def package_url
      "https://pkg.go.dev/#{CGI.escape(name)}@#{CGI.escape(version)}"
    end

    class << self
      def from_dependency(hash, prefix, full_version)
        name = hash['ImportPath']
        install_path = hash['InstallPath']
        install_path ||= install_path(prefix.join(name))
        version = full_version ? hash['Rev'].gsub('+incompatible', '') : hash['Rev'][0..6]
        homepage = hash['Homepage']
        new(name, version, install_path: install_path, package_manager: 'Go', homepage: homepage)
      end

      private

      def install_path(path)
        Pathname(path).cleanpath.to_s
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 2 rubygems

Version Path
license_finder-6.6.1 lib/license_finder/packages/go_package.rb
license_finder-6.6.0 lib/license_finder/packages/go_package.rb
license_finder-6.5.0 lib/license_finder/packages/go_package.rb
license_finder-6.4.0 lib/license_finder/packages/go_package.rb