github/linguist — pull request #287 by AndrewRadev (2012-11-12 18:36:26+00:00)
Title: Allow per-repo vendoring

I have a peculiar use case for language detection. A few of my Vim plugins are tested using RSpec, which is why I have a lot of ruby code in a `spec` directory. As a result, a lot of ruby code is detected in those projects. For instance, my [switch.vim](https://github.com/AndrewRadev/switch.vim) plugin has, at this time, more ruby code than VimL, which is somewhat misleading. It's completely possible to embed ruby code in VimL, so this kind of a picture could make it seem like the plugin is implemented mostly in ruby, while in reality, it's pure VimL, with ruby specs.

Now, this is *very* much an edge case, it really wouldn't make much sense to put `spec` in `vendor.yml`. Which is why I implemented per-repo vendoring using a `linguist_vendor.yml` file in the repo itself. I can put a file like that and it will tell linguist to ignore the `spec` dir in this specific project.

I'm not really sure how good of an idea this is -- maybe someone could abuse the system this way? I don't feel there's much of a risk though and it might improve the classification of code on github. Of course, feel free to reject this if you think otherwise.

The implementation extracts some logic in a new class. I could have made it without the addition of a class, but to me, once per-repo vendoring is added, it gets complex enough to devote a separate object that takes care of the logic. If you have a different idea for how the code could look, let me know and I'll see what I can do.

Another thing I'd like to do is have the file be hidden -- `.linguist_vendor.yml` -- but the current code seems to ignore hidden files. It shouldn't be difficult to change this, but it will change the behaviour a bit, so I wanted to ask first.