I must admit, that I'm not totally understanding what your man loop does (I'm not to familiar with ruby). I only know, that after running it you will have this:
* man pages from `HOMEBREW_PREFIX/lib/node_modules/npm/man` linked to `HOMEBREW_PREFIX/share/man` (I want that)
* man pages in `#{share}/man` (in nodes Cellar, which I don't want, because they are conflicting if pouring them from a bottle)