Fixes #7566 - added support for dependeces among modules

Dependences are detected from gemspec.
Support for circular deps detection included
Good point, I changed the algorithm and this situation will be avoided.