Skip to content

Instantly share code, notes, and snippets.

@bestie
Created November 28, 2017 14:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bestie/4bd56205f4866719f1bfaaaaf5befd82 to your computer and use it in GitHub Desktop.
Save bestie/4bd56205f4866719f1bfaaaaf5befd82 to your computer and use it in GitHub Desktop.
Parse the Gemfile.lock file and print the list of Gems that Bundler would install
require "bundler"
bundle = Bundler::LockfileParser.new(Bundler.read_file(Bundler.default_lockfile))
gem_name_version_map = bundle.specs.map { |spec|
[
spec.name,
spec.version.to_s,
]
}
STDOUT.puts gem_name_version_map.map { |pair| pair.join(" ") }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment