Module: OctoRanker
- Defined in:
- lib/octo_ranker.rb,
lib/octo_ranker/user.rb,
lib/octo_ranker/version.rb,
lib/octo_ranker/repository.rb
Defined Under Namespace
Classes: Repository, User
Constant Summary collapse
- VERSION =
"0.1.0"
Class Method Summary collapse
-
.rank_members(organization) ⇒ Object
Rank the members of
organization
according to their scores.
Class Method Details
.rank_members(organization) ⇒ Object
Rank the members of organization
according to their scores. The score for a user on a repo is computed by some function of the number of commits the user has on the repo and the number of stars the repo has (contributions to more popular repos should be significant). See OctoRanker::User#add_repo for how this function is defined. The user’s total score is the sum of the user’s score on each repo owned by organization
.
Returns an array of OctoRanker::User objects.
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/octo_ranker.rb', line 18 def rank_members(organization) users = Hash.new { |h, k| h[k] = OctoRanker::User.new } Octokit.organization_repositories(organization).each do |repo| stars = Octokit.stargazers(repo.full_name).size ranker_repo = OctoRanker::Repository.new(stars) Octokit.contributor_stats(repo.full_name).each do |contributor_stat| user = users[contributor_stat..id] user.login = contributor_stat..login user.add_repo(contributor_stat.total, ranker_repo) end end users.values.sort_by { |u| -u.score } end |