class BundledGem::LockfileReader
Public Class Methods
new(lockfile: LOCKFILE)
click to toggle source
# File lib/bundled_gems.rb, line 11 def initialize(lockfile: LOCKFILE) abort "No such file: #{lockfile}" unless File.exist?(lockfile) @lockfile_content = File.read(lockfile) end
Public Instance Methods
gem_listed?(gem)
click to toggle source
Check gem is listed in `Gemfile.lock`
# File lib/bundled_gems.rb, line 27 def gem_listed?(gem) lockfile_specs.map(&:name).include? gem end
get_version(gem)
click to toggle source
Get version info from `Gemfile.lock`
# File lib/bundled_gems.rb, line 22 def get_version(gem) lockfile_specs.find { |s| s.name == gem }&.version end
lockfile_specs()
click to toggle source
Parse `Gemfile.lock` and Retrieve specs
# File lib/bundled_gems.rb, line 17 def lockfile_specs lockfile.specs end
Private Instance Methods
lockfile()
click to toggle source
# File lib/bundled_gems.rb, line 32 def lockfile @lockfile ||= ::Bundler::LockfileParser.new(@lockfile_content) end