gem paths fixes and refactor

this is based on @ph PR #2200.
this has been tested using JRuby as the default interpreter with
```sh
rake bootstrap
rake plugin:install-defaults
./bin/logstash rspec vendor/plugins/jruby/1.9/gems/logstash-*/spec/{input,output,filter,codec}s/*_spec.rb --order rand
```

this has not been tested with MRI as the default interpreter.
this will have to be wrapped in an ensure block or force the removal before each bundler:cli command. Otherwise a failed installation will leave a tools/.bundle/config in the disk