require 'json' module Hrw module Scanner # # Used to scan gem lock file # class Pipfile attr_reader :package_manager # Class constructor # # @param [String] root The path to the project root # @param [String] lockfile # The name for the lock file, default is `Pipfile.lock` def initialize(root = Dir.pwd, lockfile = 'Pipfile.lock') @package_manager = 'pypi' @root = root @lockfile = lockfile end # Scan the lock file # @return [Hash] Dependencies def scan deps = [] lock = JSON.parse(File.read(File.join(@root, @lockfile))) lock['default'].each_pair do |name, info| deps << { name: name, version: info['version'] } end deps end end end end