Fixes #7566 - added support for dependeces among modules

Dependences are detected from gemspec.
Support for circular deps detection included
The handler function is semantically same. Shouldn't we merge them into one?