Sha256: 141c9346f086e8411f58b6ee9a79e98021d988eb5eca255fbcf3886e1ed74fa0

Contents?: true

Size: 862 Bytes

Versions: 12

Compression:

Stored size: 862 Bytes

Contents

module LicenseFinder
  class PipPackage < Package
    LICENSE_FORMAT = /^License.*::\s*(.*)$/
    INVALID_LICENSES = ["", "UNKNOWN"].to_set

    def self.license_names_from_spec(spec)
      license = spec["license"].to_s.strip

      return [license] unless INVALID_LICENSES.include?(license)

      spec
        .fetch("classifiers", [])
        .select { |c| c =~ LICENSE_FORMAT }
        .map { |c| c.gsub(LICENSE_FORMAT, '\1') }
    end

    def initialize(name, version, spec, options={})
      super(
        name,
        version,
        options.merge(
          authors: spec["author"],
          summary: spec["summary"],
          description: spec["description"],
          homepage: spec["home_page"],
          spec_licenses: self.class.license_names_from_spec(spec)
        )
      )
    end

    def package_manager
      'Pip'
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
license_finder-3.0.4 lib/license_finder/package_managers/pip_package.rb
license_finder-3.0.2 lib/license_finder/package_managers/pip_package.rb
license_finder-3.0.1 lib/license_finder/package_managers/pip_package.rb
license_finder-3.0.0 lib/license_finder/package_managers/pip_package.rb
license_finder-2.1.2 lib/license_finder/package_managers/pip_package.rb
license_finder-2.1.1 lib/license_finder/package_managers/pip_package.rb
license_finder-2.1.0 lib/license_finder/package_managers/pip_package.rb
license_finder-2.1.0.rc9 lib/license_finder/package_managers/pip_package.rb
license_finder-2.1.0.rc8 lib/license_finder/package_managers/pip_package.rb
license_finder-2.1.0.rc7 lib/license_finder/package_managers/pip_package.rb
license_finder-2.1.0.rc6 lib/license_finder/package_managers/pip_package.rb
license_finder-2.1.0.rc5 lib/license_finder/package_managers/pip_package.rb