Sha256: d45461251f7256cf5ffbb56e655d69c1cc69086f6589056957d810b01af4f907

Contents?: true

Size: 803 Bytes

Versions: 3

Compression:

Stored size: 803 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
      Pathname.new('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

3 entries across 3 versions & 1 rubygems

Version Path
license_finder-2.0.0.rc2 lib/license_finder/package_managers/pip.rb
license_finder-1.2 lib/license_finder/package_managers/pip.rb
license_finder-1.2-java lib/license_finder/package_managers/pip.rb