Class: GemChangelogDiff::LockfileParser

Inherits:
Object
  • Object
show all
Defined in:
lib/gem_changelog_diff/lockfile_parser.rb

Overview

Detects outdated gems by comparing Gemfile.lock specs to RubyGems.

Instance Method Summary collapse

Constructor Details

#initialize(rubygems_client: RubygemsClient.new) ⇒ LockfileParser

Returns a new instance of LockfileParser.



8
9
10
# File 'lib/gem_changelog_diff/lockfile_parser.rb', line 8

def initialize(rubygems_client: RubygemsClient.new)
  @rubygems_client = rubygems_client
end

Instance Method Details

#detect(lockfile_path: "Gemfile.lock") ⇒ Array<OutdatedGem>

Parses the lockfile and returns gems with newer versions available.

Parameters:

  • lockfile_path (String) (defaults to: "Gemfile.lock")

    path to Gemfile.lock

Returns:

Raises:

  • (Error)

    if the lockfile is not found



16
17
18
19
20
21
22
# File 'lib/gem_changelog_diff/lockfile_parser.rb', line 16

def detect(lockfile_path: "Gemfile.lock")
  content = File.read(lockfile_path)
  parser = Bundler::LockfileParser.new(content)
  find_outdated(parser.specs)
rescue Errno::ENOENT
  raise Error, "Lockfile not found: #{lockfile_path}"
end