This is really difficult to follow. Can we make a helper or something? There's a ton of expanding and contracting. 

I see `File.dirname(dependency.berksfile.filepath)` twice - maybe that could become a more semantic name, like "berksfile_directory"?