Sha256: 813700d84188feb1e0b5c7b67107e38406779b0a9e8af23b59d846c96f43550e
Contents?: true
Size: 780 Bytes
Versions: 1
Compression:
Stored size: 780 Bytes
Contents
require 'octokit' module PublicKeys class Github UnauthorizedError = Class.new(StandardError) def initialize(*args) @client = Octokit::Client.new(*args) end def user_keys(user) @client.user_keys(user).map { |user| user['key'] } end def team_keys(organization, team_name) team_id = @client.organization_teams(organization).find { |team| team['name'] == team_name }['id'] @client.team_members(team_id).flat_map { |member| user_keys(member['login']) } rescue Octokit::Unauthorized raise UnauthorizedError.new('You have to authenticate to get team keys.') end def organization_keys(organization) @client.organization_members(organization).flat_map { |member| user_keys(member['login']) } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
public_keys-0.0.1 | lib/public_keys/github.rb |