Parsing a Gemfile programmatically to find out what it contains.
It's easy to look at the gems you currently have loaded in the current runtime but if you need to read some other Gemfile and inpect its contents then this works:
gems = Bundler::Definition.build('Gemfile', nil, {}).dependencies