Last active
June 19, 2019 02:39
-
-
Save drwl/f54e07d706e0cdd6aac726daa3897371 to your computer and use it in GitHub Desktop.
Get all explicitly defined gems and those gem's depencies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bundler' | |
GEMFILE_LOCK_PATH = 'Gemfile.lock'.freeze | |
lockfile_text = File.read(GEMFILE_LOCK_PATH) | |
lockfile = Bundler::LockfileParser.new(lockfile_text) | |
explicit_gems = lockfile.dependencies.values | |
implicit_gems = lockfile.specs.reduce([]) { |gems, spec| gems += spec.dependencies }.uniq(&:name) | |
all_gems = (explicit_gems + implicit_gems).uniq(&:name).sort_by(&:name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment