Sha256: 2ef4366fda1668220510f443a08bd2a8e6f4a3b4b3659ed21a60039226c70d4c
Contents?: true
Size: 1.09 KB
Versions: 8
Compression:
Stored size: 1.09 KB
Contents
# frozen_string_literal: true module Spandx module Python module Parsers class PipfileLock < ::Spandx::Core::Parser def matches?(filename) filename.match?(/Pipfile.*\.lock/) end def parse(lockfile) results = [] dependencies_from(lockfile) do |dependency| results << dependency end results end private def dependencies_from(lockfile) json = JSON.parse(IO.read(lockfile)) each_dependency(json) do |name, version| yield ::Spandx::Core::Dependency.new( package_manager: :pypi, name: name, version: version, meta: json ) end end def each_dependency(json, groups: %w[default develop]) groups.each do |group| json[group].each do |name, value| yield name, canonicalize(value['version']) end end end def canonicalize(version) version.gsub(/==/, '') end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems