Sha256: dcf1adff0aa4e51e5a7cbf7af0cd066a52dd79860035a0537f5052c83097eeef
Contents?: true
Size: 1.39 KB
Versions: 6
Compression:
Stored size: 1.39 KB
Contents
# frozen_string_literal: true module Licensed module Sources class Pipenv < Source def enabled? Licensed::Shell.tool_available?("pipenv") && File.exist?(@config.pwd.join("Pipfile.lock")) end def enumerate_dependencies pakages_from_pipfile_lock.map do |package_name| package = package_info(package_name) location = File.join(package["Location"], package["Name"].gsub("-", "_") + "-" + package["Version"] + ".dist-info") Dependency.new( name: package["Name"], version: package["Version"], path: location, metadata: { "type" => Pipenv.type, "summary" => package["Summary"], "homepage" => package["Home-page"] } ) end end private def pakages_from_pipfile_lock Licensed::Shell.execute("pipenv", "run", "pip", "list") .lines .drop(2) # Header .map { |line| line.strip.split.first.strip } end def package_info(package_name) p_info = Licensed::Shell.execute("pipenv", "run", "pip", "--disable-pip-version-check", "show", package_name).lines p_info.each_with_object(Hash.new(0)) { |pkg, a| k, v = pkg.split(":", 2) next if k.nil? || k.empty? a[k.strip] = v&.strip } end end end end
Version data entries
6 entries across 6 versions & 1 rubygems