octo_ranker 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +95 -0
- data/Rakefile +2 -0
- data/bin/console +10 -0
- data/bin/setup +7 -0
- data/lib/octo_ranker.rb +32 -0
- data/lib/octo_ranker/repository.rb +15 -0
- data/lib/octo_ranker/user.rb +19 -0
- data/lib/octo_ranker/version.rb +3 -0
- data/octo_ranker.gemspec +25 -0
- metadata +114 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 56903e716a82093411c13569ed05470410800ab3
|
4
|
+
data.tar.gz: 0f6e20d96db40a0219015c0b31cf8a26fe2d8866
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 230a8e1208cc653d3a90653836548ba5a32ced5f3ac7cf15822c2c9a76740394b856d659d3f47af27be9a9513dd691f2828f4577246c2032817a144fb9ef1c3c
|
7
|
+
data.tar.gz: aa08f1bf80cfe97d1eb0eb2db949260e0c76cea13ea2fab4f7ea0e7fc14fd7063859e8061d1133313447bf0b267b15e7469058568dac92d213a3490e49546559
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Andrew Mason
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
# OctoRanker
|
2
|
+
|
3
|
+
Git ranked.
|
4
|
+
|
5
|
+
OctoRanker can rank the members of an organization based on their contributions
|
6
|
+
to the organization's public repositories. You should probably read the whole
|
7
|
+
README, but at the very least, please read the
|
8
|
+
[organizational usage](#organizational).
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'octo_ranker'
|
16
|
+
```
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install octo_ranker
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
### Programmatic
|
29
|
+
|
30
|
+
Using OctoRanker is very straightforward. It goes like this:
|
31
|
+
```ruby
|
32
|
+
require 'octo_ranker'
|
33
|
+
OctoRanker.rank_members('name-of-my-org')
|
34
|
+
```
|
35
|
+
This will give you an array of [`OctoRanker::User`](lib/octo_ranker/user.rb)
|
36
|
+
objects. You can read the docs to find out how the rankings are calculated.
|
37
|
+
|
38
|
+
#### Rate Limiting
|
39
|
+
GitHub uses rate limiting. You can read about their policies
|
40
|
+
[here](https://developer.github.com/v3/rate_limit/). Depending on the size of
|
41
|
+
your organization, this may cause some errors to be thrown once GitHub starts
|
42
|
+
responding with 429s.
|
43
|
+
|
44
|
+
To increase your rate limit, you can configure
|
45
|
+
[octokit](https://github.com/octokit/octokit.rb) (which is what OctoRanker
|
46
|
+
uses to get data from GitHub) to authorize with your GitHub credentials like so:
|
47
|
+
```ruby
|
48
|
+
require 'octo_ranker'
|
49
|
+
Octokit.configure do |c|
|
50
|
+
c.login = 'ajm188'
|
51
|
+
c.password = 'password' # Obviously not my real password (or is it?), but you get the idea.
|
52
|
+
end
|
53
|
+
# Now make your queries as normal
|
54
|
+
OctoRanker.rank_members('name-of-my-org')
|
55
|
+
```
|
56
|
+
|
57
|
+
If your organization is so large that you're maxing out the authenticated rate
|
58
|
+
limit (wow, good for you!), create an issue in here, and I'll try to come up
|
59
|
+
with a good batch processing solution.
|
60
|
+
|
61
|
+
### Organizational
|
62
|
+
|
63
|
+
OctoRanker is intended to be a fun way to encourage members of your organization
|
64
|
+
to contribute to your repos. The rankings should provide **friendly** competition
|
65
|
+
and motivation to get more involved with your organization's open source software.
|
66
|
+
|
67
|
+
Things you **should not do** if your organization uses rankings:
|
68
|
+
* "Dood, you suck. You have, like, the worst ranking in our org."
|
69
|
+
* Make a bunch of really small commits to boost your ranking. That's not the point.
|
70
|
+
|
71
|
+
Things you should do instead:
|
72
|
+
* Be kind and encouraging to your fellow teammates. You're on the same team after all.
|
73
|
+
* Focus on making contributions to your organization, and not on your ranking. After all,
|
74
|
+
the more you focus on making contributions, the better your ranking will be as a result.
|
75
|
+
|
76
|
+
## Contributing
|
77
|
+
|
78
|
+
1. Fork it ( https://github.com/ajm188/octo_ranker/fork )
|
79
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
80
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
81
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
82
|
+
5. Create a new Pull Request
|
83
|
+
|
84
|
+
## Potential Features
|
85
|
+
These are some things I'm considering adding to the project. If you want to
|
86
|
+
work on one (or any) of them, feel free. Just let me know so I don't
|
87
|
+
duplicate your effort (duplicated effort is lame). Also see
|
88
|
+
[contributing](#contributing) for the workflow.
|
89
|
+
|
90
|
+
1. Batch processing of org repos. See [rate limiting](#rate-limiting).
|
91
|
+
1. Option to count private repos. Note that this will require authentication
|
92
|
+
from a member of the organization.
|
93
|
+
1. Add some tests. I've seen the code work, but why should you trust me?
|
94
|
+
1. This isn't a "feature" per se, but I might as well stick this here and hope
|
95
|
+
someone else does it for me.
|
data/Rakefile
ADDED
data/bin/console
ADDED
data/bin/setup
ADDED
data/lib/octo_ranker.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'octo_ranker/version'
|
2
|
+
require 'octo_ranker/user'
|
3
|
+
require 'octo_ranker/repository'
|
4
|
+
|
5
|
+
require 'octokit'
|
6
|
+
|
7
|
+
module OctoRanker
|
8
|
+
class << self
|
9
|
+
# Rank the members of +organization+ according to their scores.
|
10
|
+
# The score for a user on a repo is computed by some function of
|
11
|
+
# the number of commits the user has on the repo and the number of
|
12
|
+
# stars the repo has (contributions to more popular repos should be
|
13
|
+
# significant). See OctoRanker::User#add_repo for how this function
|
14
|
+
# is defined. The user's total score is the sum of the user's score
|
15
|
+
# on each repo owned by +organization+.
|
16
|
+
#
|
17
|
+
# Returns an array of OctoRanker::User objects.
|
18
|
+
def rank_members(organization)
|
19
|
+
users = Hash.new { |h, k| h[k] = OctoRanker::User.new }
|
20
|
+
Octokit.organization_repositories(organization).each do |repo|
|
21
|
+
stars = Octokit.stargazers(repo.full_name).size
|
22
|
+
ranker_repo = OctoRanker::Repository.new(stars)
|
23
|
+
Octokit.contributor_stats(repo.full_name).each do |contributor_stat|
|
24
|
+
user = users[contributor_stat.author.id]
|
25
|
+
user.login = contributor_stat.author.login
|
26
|
+
user.add_repo(contributor_stat.total, ranker_repo)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
users.values.sort_by { |u| -u.score }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module OctoRanker
|
2
|
+
class Repository
|
3
|
+
def initialize(stars)
|
4
|
+
@stars = stars
|
5
|
+
end
|
6
|
+
|
7
|
+
# Defines how heavily a repository should be counted when determining
|
8
|
+
# scores for a user. Currently defined to be the number of stars on the
|
9
|
+
# repository (plus 1, because users should still get points for
|
10
|
+
# contributing, even if the repo has no stars).
|
11
|
+
def weight
|
12
|
+
@stars + 1
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module OctoRanker
|
2
|
+
class User
|
3
|
+
attr_reader :score
|
4
|
+
attr_writer :login
|
5
|
+
|
6
|
+
def initialize(login = nil)
|
7
|
+
@login, @score = login, 0
|
8
|
+
end
|
9
|
+
|
10
|
+
# Add the score for +repo+ to the score for this user.
|
11
|
+
# Currently, the score for a repo is defined as the product
|
12
|
+
# of the number of commits the user has on the repo and the
|
13
|
+
# weight of that repo. See OctoRanker::Repository for how
|
14
|
+
# the weight is defined.
|
15
|
+
def add_repo(commits, repo)
|
16
|
+
@score += commits * repo.weight
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/octo_ranker.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'octo_ranker/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "octo_ranker"
|
8
|
+
spec.version = OctoRanker::VERSION
|
9
|
+
spec.authors = ["Andrew Mason"]
|
10
|
+
spec.email = ["mason@case.edu"]
|
11
|
+
|
12
|
+
spec.summary = %q{Rank your organization members by their contributions to your public repositories on GitHub}
|
13
|
+
spec.homepage = "https://github.com/ajm188/octo_ranker"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.8"
|
21
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
22
|
+
spec.add_development_dependency "pry"
|
23
|
+
|
24
|
+
spec.add_runtime_dependency "octokit"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: octo_ranker
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andrew Mason
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.8'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: octokit
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- mason@case.edu
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- bin/console
|
83
|
+
- bin/setup
|
84
|
+
- lib/octo_ranker.rb
|
85
|
+
- lib/octo_ranker/repository.rb
|
86
|
+
- lib/octo_ranker/user.rb
|
87
|
+
- lib/octo_ranker/version.rb
|
88
|
+
- octo_ranker.gemspec
|
89
|
+
homepage: https://github.com/ajm188/octo_ranker
|
90
|
+
licenses:
|
91
|
+
- MIT
|
92
|
+
metadata: {}
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 2.4.5
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: Rank your organization members by their contributions to your public repositories
|
113
|
+
on GitHub
|
114
|
+
test_files: []
|