Class: Dependabot::Bundler::CachedLockfileParser

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/bundler/cached_lockfile_parser.rb

Class Method Summary collapse

Class Method Details

.parse(lockfile_content) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/dependabot/bundler/cached_lockfile_parser.rb', line 15

def self.parse(lockfile_content)
  lockfile_hash = Digest::SHA2.hexdigest(lockfile_content)
  @cache ||= T.let({}, T.nilable(T::Hash[String, ::Bundler::LockfileParser]))
  return T.must(@cache[lockfile_hash]) if @cache.key?(lockfile_hash)

  @cache[lockfile_hash] = ::Bundler::LockfileParser.new(lockfile_content)
end