Reworking of CodeMatcher refactor from @house9, originally #13

In #13, @house9 submitted lots of changes, including a refactor of the code matching into a separate class, `CodeMatcher`. At around the same time, @avdi moved many of the core files to make it mountable on a rails app. This meant that #13 was no longer automatically merge-able, so this is a manual merge and tidy up.

There are no new features, just some moved files, merged conflict fixes and the fixing of a broken spec.

I've submitted it as a PR due to the size of the change. Could someone please review and test before merging into master?

Thanks.