hubmeme 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +22 -0
- data/README.md +74 -0
- data/bin/hubmeme +20 -0
- data/lib/hubmeme.rb +83 -0
- metadata +81 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a6d490ff0852e32e4724737c5f9e3c100a17e3af
|
4
|
+
data.tar.gz: a5a0694018eb2b0566bb8b3af9338d1415222de9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8c18dc88d148dd4863d3e104f1047ae666485d8e78208c85e0526fd3ed8e27cd3a0dcda0cd0b6d4868e911a524f83af3b36ac55098a479175e9f2ea1d3fca06c
|
7
|
+
data.tar.gz: fd25254bfb860ab2b1e559cec758704679286398fcfc633d867b396096ee326606eca38beede277509bcac6e3dafe978eb13fe03b7dad77df84ec9b33f94586b
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2013 Mat Brown and his cat
|
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.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
## HubMeme
|
2
|
+
|
3
|
+
HubMeme is a whimsical command-line tool to figure out how big a meme a user is
|
4
|
+
on GitHub. Meme-ness is calculated by summing over all repositories a user has
|
5
|
+
contributed to the product of their percentage contribution and the number of
|
6
|
+
stars the repository has.
|
7
|
+
|
8
|
+
### Installation
|
9
|
+
|
10
|
+
```bash
|
11
|
+
$ gem install hubmeme
|
12
|
+
```
|
13
|
+
|
14
|
+
### Running it
|
15
|
+
|
16
|
+
You'll need a [GitHub access
|
17
|
+
token](https://help.github.com/articles/creating-an-access-token-for-command-line-use).
|
18
|
+
|
19
|
+
```bash
|
20
|
+
$ GITHUB_ACCESS_TOKEN=something hubmeme username
|
21
|
+
```
|
22
|
+
|
23
|
+
### How it works
|
24
|
+
|
25
|
+
1. Tries to figure out all the repositories you've contributed to. GitHub
|
26
|
+
doesn't make this directly accessible via the API as far as I can tell, so it
|
27
|
+
checks your own repos; your organizations' repos; repos you've starred; repos
|
28
|
+
you've made pull requests to; etc.
|
29
|
+
2. Calculates your percentage contribution on each repo. The is using the
|
30
|
+
[“contributors”
|
31
|
+
endpoint](http://developer.github.com/v3/repos/#list-contributors) on the
|
32
|
+
GitHub API; I'm not even sure exactly what the “contributions” number means,
|
33
|
+
and it doesn't seem terribly accurate, but the stakes are pretty low here.
|
34
|
+
3. Sums up the product of your contribution to each repo and the number of stars
|
35
|
+
that repo has.
|
36
|
+
4. Prints all that on the screen.
|
37
|
+
|
38
|
+
Here's what it prints out for me (all my friends are more meme):
|
39
|
+
|
40
|
+
```
|
41
|
+
brewster/elastictastic 80% 73 59
|
42
|
+
brewster/shearwater 72% 2 1
|
43
|
+
cequel/cequel 96% 61 59
|
44
|
+
kreynolds/cassandra-cql 9% 71 7
|
45
|
+
mongoid/mongoid 0% 2771 1
|
46
|
+
outoftime/eager_record 64% 35 23
|
47
|
+
outoftime/get_lit 82% 1 1
|
48
|
+
outoftime/harp 100% 3 3
|
49
|
+
outoftime/native_support 100% 3 3
|
50
|
+
outoftime/noaa 33% 68 23
|
51
|
+
outoftime/ottoman 100% 6 6
|
52
|
+
outoftime/outoftime.github.com 100% 2 2
|
53
|
+
outoftime/patch_log 100% 1 1
|
54
|
+
outoftime/search-contrib 100% 1 1
|
55
|
+
outoftime/sunspot-rails-example 87% 13 11
|
56
|
+
outoftime/sunspot_rails 6% 128 8
|
57
|
+
outoftime/woodchuck 100% 1 1
|
58
|
+
sunspot/sunspot 8% 1808 145
|
59
|
+
TOTAL MEME: 354
|
60
|
+
```
|
61
|
+
|
62
|
+
### Known problems
|
63
|
+
|
64
|
+
* See items 1 and 2 under “How it works”
|
65
|
+
* Enables the worst kind of open-source navel-gazing; may end friendships
|
66
|
+
|
67
|
+
### Contributing
|
68
|
+
|
69
|
+
Go for it!
|
70
|
+
|
71
|
+
### License
|
72
|
+
|
73
|
+
Released under the MIT license copyright 2013 Mat Brown and his cat. See
|
74
|
+
attached LICENSE for details.
|
data/bin/hubmeme
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
if File.exist?(File.expand_path('../../Gemfile', __FILE__))
|
4
|
+
require 'bundler'
|
5
|
+
Bundler.require(:default)
|
6
|
+
end
|
7
|
+
|
8
|
+
require 'hubmeme'
|
9
|
+
|
10
|
+
Octokit.configure do |c|
|
11
|
+
c.access_token = ENV['GITHUB_ACCESS_TOKEN'] ||
|
12
|
+
abort("Specify a GITHUB_ACCESS_TOKEN environment variable")
|
13
|
+
end
|
14
|
+
|
15
|
+
meme = HubMeme.new(ARGV.first)
|
16
|
+
total_meme = meme.meme do |repo, contribution, repo_meme|
|
17
|
+
puts sprintf("%40s %3d%% %6d %8d",
|
18
|
+
repo.full_name, contribution * 100, repo.stargazers_count, repo_meme.round)
|
19
|
+
end
|
20
|
+
puts "TOTAL MEME: #{total_meme.round}"
|
data/lib/hubmeme.rb
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'active_support/all'
|
2
|
+
require 'octokit'
|
3
|
+
|
4
|
+
Octokit.configure do |c|
|
5
|
+
c.auto_paginate = true
|
6
|
+
end
|
7
|
+
|
8
|
+
class HubMeme
|
9
|
+
attr_reader :login
|
10
|
+
|
11
|
+
def initialize(login)
|
12
|
+
@login = login
|
13
|
+
end
|
14
|
+
|
15
|
+
def meme
|
16
|
+
contributed_repositories.sum do |repo, contribution|
|
17
|
+
(repo.stargazers_count * contribution).tap do |repo_meme|
|
18
|
+
yield repo, contribution, repo_meme if repo_meme.round > 0 && block_given?
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def contributed_repositories
|
24
|
+
return enum_for(:contributed_repositories) unless block_given?
|
25
|
+
|
26
|
+
candidate_repositories.each do |repo|
|
27
|
+
begin
|
28
|
+
contributors = Octokit.contributors(repo.full_name)
|
29
|
+
rescue Octokit::NotFound
|
30
|
+
next
|
31
|
+
end
|
32
|
+
own_contribution = 0
|
33
|
+
total_contributions = contributors.sum do |contributor|
|
34
|
+
if contributor.login == login
|
35
|
+
own_contribution = contributor.contributions
|
36
|
+
end
|
37
|
+
contributor.contributions
|
38
|
+
end
|
39
|
+
if own_contribution.nonzero?
|
40
|
+
yield repo, own_contribution.to_f / total_contributions
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def candidate_repositories
|
46
|
+
(user_repositories +
|
47
|
+
organization_repositories +
|
48
|
+
starred_repositories +
|
49
|
+
watched_repositories +
|
50
|
+
pull_requested_repositories).
|
51
|
+
reject { |repo| repo.fork || repo.private }.
|
52
|
+
uniq { |repo| repo.name }.
|
53
|
+
sort_by { |repo| repo.full_name.downcase }
|
54
|
+
end
|
55
|
+
|
56
|
+
def user_repositories
|
57
|
+
Octokit.repositories(login, :query => {:type => 'all'})
|
58
|
+
end
|
59
|
+
|
60
|
+
def organization_repositories
|
61
|
+
organizations.flat_map do |org|
|
62
|
+
Octokit.organization_repositories(org.login)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def organizations
|
67
|
+
Octokit.organizations(login, :query => {:type => 'all'})
|
68
|
+
end
|
69
|
+
|
70
|
+
def starred_repositories
|
71
|
+
Octokit.starred(login)
|
72
|
+
end
|
73
|
+
|
74
|
+
def watched_repositories
|
75
|
+
Octokit.watched(login)
|
76
|
+
end
|
77
|
+
|
78
|
+
def pull_requested_repositories
|
79
|
+
Octokit.user_public_events(login).
|
80
|
+
select { |event| event.type == 'PullRequestEvent' }.
|
81
|
+
map { |event| event.payload.pull_request.base.repo }
|
82
|
+
end
|
83
|
+
end
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hubmeme
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mat Brown
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: octokit
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: |
|
42
|
+
HubMeme is a whimsical command-line tool to figure out how big a meme a user is
|
43
|
+
on GitHub. Meme-ness is calculated by summing over all repositories a user has
|
44
|
+
contributed to the product of their percentage contribution and the number of
|
45
|
+
stars the repository has.
|
46
|
+
email: mat.a.brown@gmail.com
|
47
|
+
executables:
|
48
|
+
- hubmeme
|
49
|
+
extensions: []
|
50
|
+
extra_rdoc_files: []
|
51
|
+
files:
|
52
|
+
- bin/hubmeme
|
53
|
+
- lib/hubmeme.rb
|
54
|
+
- README.md
|
55
|
+
- LICENSE
|
56
|
+
homepage: http://github.com/outoftime/hubmeme
|
57
|
+
licenses:
|
58
|
+
- MIT
|
59
|
+
metadata: {}
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 2.1.11
|
77
|
+
signing_key:
|
78
|
+
specification_version: 4
|
79
|
+
summary: How big a meme are you on GitHub?
|
80
|
+
test_files: []
|
81
|
+
has_rdoc:
|