assemblymade/coderwall — pull request #203 by just3ws (2014-09-11 17:46:31+00:00)
Title: DO NOT MERGE - GitHub Refactoring Preview PR

*DO NOT MERGE THIS PR!*

This is a preview of a work in progress that refactors most of the GitHub integration into a modular and consistent structure.

Notice the new directory `app/coderwall` this is the new home for all code that is not strictly coupled to the Rails infrastructure. Inside the directory you'll find the `Coderwall` namespace which is to be considered the root of all application specific code. Inside the directory there's the `app/coderwall/git_hub` directory which contains all the new implementation and current refactoring of our GitHub integration under the namespace `Coderwall::GitHub`.

`Coderwall::GitHub` is intentionally cased with a capital H because (that's how GitHub is spelled) and to differentiate and avoid collision with existing `Github` models. Eventually this will be reconciled. `Coderwall::GitHub` currently primarily exists to host the `Coderwall::GitHub::Queries` namespace with has queries divided between `Coderwall::GitHub::Queries::Repo` for repo specific queries and `Coderwall::GitHub::Queries::GitHubUser` for GitHub user specific queries.

All the queries follow the same pattern and inherit from a shared `Queries::Base` class.

```
# client = Coderwall::GitHub::Client.new(ENV['GITHUB_ACCESS_TOKEN']).client
# or
client = Coderwall::GitHub::Client.instance # picks up the env token automatically
contributors = Coderwall::GitHub::Queries::Repo::ContributorsFor.new(client, 'assemblymade', 'coderwall').fetch
# => array of hashes representing the response from GitHub
```

My reason for doing this was that working inside the existing codebase has been very difficult to clear out old pieces of legacy code, get them under test, and clear out the cruft. Much of this is existing logic that has been pulled out then refactored for consistency and maintainability. The tests are passing but there are still aspects of the existing app that use this code that are not themselves under test. I'm working to clear this up and finish the integration as soon as possible then start looking at moving other pieces of the application to refactor under the `Coderwall` namespace.

Thanks.
Mike