Skip to content

Instantly share code, notes, and snippets.

@roktas
Last active August 29, 2015 14:01
Show Gist options
  • Save roktas/50af220017b3f191b16f to your computer and use it in GitHub Desktop.
Save roktas/50af220017b3f191b16f to your computer and use it in GitHub Desktop.
---
description: ok
---
# head
- foo
- bar
#!/usr/bin/ruby
# encoding: utf-8
# Kurulum
#
# $ sudo apt-get install ruby-octokit
# $ https://github.com/settings/tokens/new ile org izinli token oluştur
# Sertifika hatası alırsanız şu şekilde çalıştırın
#
# $ wget https://raw.githubusercontent.com/bagder/ca-bundle/master/ca-bundle.crt -O ~/.cacert.pem
# $ SSL_CERT_FILE=~/.cacert.pem ./org
require 'octokit'
class Org
TOKEN_FILE = File.join ENV['HOME'], '.github_token'
@client = Octokit::Client.new access_token: IO.read(TOKEN_FILE)
@client.user.login
class << self
attr_reader :client
end
attr_reader :org
def initialize(org)
@org = org
end
def client
self.class.client
end
def team_members(team_name)
team = client.org_teams(org).find { |t| t[:name] == team_name }
client.team_members(team[:id]).map(&:login)
rescue
$stderr.puts 'oops'
end
end
org = Org.new '19'
puts org.team_members 'admin'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment