Sha256: e1fff38c8003fcb587e3b954c02b9565e628c9cf136677e1a6658b1c779a6bc0

Contents?: true

Size: 808 Bytes

Versions: 2

Compression:

Stored size: 808 Bytes

Contents

require 'json'
require 'httparty'

module LicenseFinder
  class Pip < PackageManager
    def current_packages
      output = `#{LicenseFinder::BIN_PATH.join("license_finder_pip.py")}`
      JSON(output).map do |package|
        PipPackage.new(
          package["name"],
          package["version"],
          File.join(package["location"], package["name"]),
          pypi_def(package["name"], package["version"]),
          logger: logger
        )
      end
    end

    private

    def package_path
      project_path.join('requirements.txt')
    end

    def pypi_def(name, version)
      response = HTTParty.get("https://pypi.python.org/pypi/#{name}/#{version}/json")
      if response.code == 200
        JSON.parse(response.body).fetch("info", {})
      else
        {}
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
license_finder-2.0.1 lib/license_finder/package_managers/pip.rb
license_finder-2.0.0 lib/license_finder/package_managers/pip.rb