Class: GithubScouter::Scouter
- Inherits:
-
Object
- Object
- GithubScouter::Scouter
- Defined in:
- lib/github_scouter.rb
Class Method Summary collapse
Instance Method Summary collapse
- #agi ⇒ Object
- #atk ⇒ Object
- #client ⇒ Object
-
#initialize(name) ⇒ Scouter
constructor
A new instance of Scouter.
- #int ⇒ Object
- #orgs ⇒ Object
- #repos ⇒ Object
- #starred ⇒ Object
Constructor Details
#initialize(name) ⇒ Scouter
Returns a new instance of Scouter.
36 37 38 |
# File 'lib/github_scouter.rb', line 36 def initialize(name) @name = name end |
Class Method Details
.atk_base(repo) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/github_scouter.rb', line 12 def self.atk_base(repo) return 0 if repo.private fork = repo.forks_count start = repo.stargazers_count if repo.fork (fork + start).to_f / 10 else 1 + (fork + 2) * + start end end |
.language_rank(repos) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/github_scouter.rb', line 24 def self.language_rank(repos) repos .map(&:language) .delete_if(&:nil?) .reduce(Hash.new(0)) { |a,lang| a[lang] += 1 a }.sort_by { |key,value| -value } end |
Instance Method Details
#agi ⇒ Object
75 76 77 78 79 80 81 82 |
# File 'lib/github_scouter.rb', line 75 def agi orgs.map do |org_id| org = client.organization(org_id.login) repo = org.public_repos members = client.organization_members(org.login).count (repo.to_f + members) end.sum end |
#atk ⇒ Object
60 61 62 |
# File 'lib/github_scouter.rb', line 60 def atk repos.map { |repo| Scouter.atk_base(repo) }.sum end |
#client ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/github_scouter.rb', line 40 def client = { auto_paginate: true, access_token: ENV['GITHUB_ACCESS_TOKEN'], } @client ||= Octokit::Client.new() end |
#int ⇒ Object
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/github_scouter.rb', line 64 def int rank = Scouter.language_rank(repos) lang = rank.size sum = 0 rank.each_with_index do |h,i| value = h[1] sum += value / (lang - i) end lang * sum end |
#orgs ⇒ Object
56 57 58 |
# File 'lib/github_scouter.rb', line 56 def orgs @args ||= client.organizations(@name) end |
#repos ⇒ Object
48 49 50 |
# File 'lib/github_scouter.rb', line 48 def repos @repos ||= client.repositories(@name) end |
#starred ⇒ Object
52 53 54 |
# File 'lib/github_scouter.rb', line 52 def starred @starred ||= client.starred(@name) end |