Sha256: 4abf88ffcfada76d77f0c7ae5606cc6bbc656909b31aa2079d9358ccbbef85ce

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

module LicenseFinder
  class PipPackage < Package
    def initialize(name, version, install_path, pypi_def)
      @name = name
      @version = version
      @install_path = install_path
      @pypi_def = pypi_def
    end

    attr_reader :name, :version

    def summary
      pypi_def.fetch("summary", "")
    end

    def description
      pypi_def.fetch("description", "")
    end

    def homepage
      pypi_def["home_page"]
    end

    def children
      [] # no way to determine child deps from pip (maybe?)
    end

    def groups
      [] # no concept of dev/test groups in pip (maybe?)
    end

    private

    attr_reader :install_path, :pypi_def

    def license_from_spec
      license = pypi_def.fetch("license", "UNKNOWN")

      if license == "UNKNOWN"
        classifiers = pypi_def.fetch("classifiers", [])
        license = classifiers.map do |c|
          if c.start_with?("License")
            c.gsub(/^License.*::\s*(.*)$/, '\1')
          end
        end.compact.first
      end

      license
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
license_finder-0.9.5.1-java lib/license_finder/package_managers/pip_package.rb
license_finder-0.9.5.1 lib/license_finder/package_managers/pip_package.rb