Sha256: 08f99f26646750ea3f41aa521164018e6287bf5f350753284ee0470ec84f4a1f

Contents?: true

Size: 851 Bytes

Versions: 1

Compression:

Stored size: 851 Bytes

Contents

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hrw-0.2.2 lib/hrw/scanner/pipfile.rb