class GithubScouter::Scouter

Public Class Methods

atk_base(repo) click to toggle source
# 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) click to toggle source
# 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
new(name) click to toggle source
# File lib/github_scouter.rb, line 36
def initialize(name)
  @name = name
end

Public Instance Methods

agi() click to toggle source
# 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() click to toggle source
# File lib/github_scouter.rb, line 60
def atk
  repos.map { |repo| Scouter.atk_base(repo) }.sum
end
client() click to toggle source
# File lib/github_scouter.rb, line 40
def client
  options = {
             auto_paginate: true,
             access_token: ENV['GITHUB_ACCESS_TOKEN'],
            }
  @client ||= Octokit::Client.new(options)
end
int() click to toggle source
# 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() click to toggle source
# File lib/github_scouter.rb, line 56
def orgs
  @args ||= client.organizations(@name)
end
repos() click to toggle source
# File lib/github_scouter.rb, line 48
def repos
  @repos ||= client.repositories(@name)
end
starred() click to toggle source
# File lib/github_scouter.rb, line 52
def starred
  @starred ||= client.starred(@name)
end