Factor gemfile locking out of installing

This patch factors generating the Gemfile.lock out of the Installer
class to make it possible to reuse independently.

I've written a LockingInstaller class to do both lockfile generation and installation, so this patch shouldn't change behaviour in any meaningful way, but it *does* alter the order of a couple of operations.