class TeachersPet::ClientDecorator
Public Instance Methods
add_users_to_team(organization, team, usernames)
click to toggle source
# File lib/teachers_pet/client_decorator.rb, line 46 def add_users_to_team(organization, team, usernames) # Minor optimization, mostly for testing if usernames.any? team_members = self.get_team_member_logins(team[:id]) usernames.each do |username| if team_members.include?(username) puts " -> @#{username} is already on @#{organization}/#{team[:name]}" else # https://github.com/octokit/octokit.rb/pull/518 self.add_team_membership(team[:id], username, accept: 'application/vnd.github.the-wasp-preview+json') puts " -> @#{username} has been added to @#{organization}/#{team[:name]}" end end end end
create_team(organization, name)
click to toggle source
Calls superclass method
# File lib/teachers_pet/client_decorator.rb, line 38 def create_team(organization, name) puts "Creating team @#{organization}/#{name} ..." super(organization, name: name, permission: 'push' ) end
existing_teams_by_name(organization)
click to toggle source
# File lib/teachers_pet/client_decorator.rb, line 28 def existing_teams_by_name(organization) results = Hash.new teams = self.organization_teams(organization) teams.each do |team| results[team[:name]] = team end results end
get_team_member_logins(team_id)
click to toggle source
# File lib/teachers_pet/client_decorator.rb, line 22 def get_team_member_logins(team_id) self.team_members(team_id).map do |member| member[:login] end end
get_teams_by_name(organization)
click to toggle source
# File lib/teachers_pet/client_decorator.rb, line 13 def get_teams_by_name(organization) org_teams = self.organization_teams(organization) teams = Hash.new org_teams.each do |team| teams[team[:name]] = team end return teams end
repository?(organization, repo_name)
click to toggle source
# File lib/teachers_pet/client_decorator.rb, line 5 def repository?(organization, repo_name) begin self.repository("#{organization}/#{repo_name}") rescue return false end end