Class: TeachersPet::Actions::CreateStudentTeams
- Defined in:
- lib/teachers_pet/actions/create_student_teams.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#execute, #init_client, #initialize, #octokit_config, #read_file, #read_members_file, #read_students_file
Constructor Details
This class inherits a constructor from TeachersPet::Actions::Base
Instance Method Details
#create_student_teams ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/teachers_pet/actions/create_student_teams.rb', line 4 def create_student_teams org_login = self.[:organization] teams_by_name = self.client.existing_teams_by_name(org_login) students_list = self.read_students_file students_list.each do |key, value| if value # Create one team per group of students team_name = key usernames = value else # Create a team with the same name as the student, with that person as the only member team_name = key usernames = [value] end team = teams_by_name[team_name] if team puts "Team @#{org_login}/#{team_name} already exists." else team = self.client.create_team(org_login, team_name) end self.client.add_users_to_team(org_login, team, usernames) end end |
#run ⇒ Object
30 31 32 33 |
# File 'lib/teachers_pet/actions/create_student_teams.rb', line 30 def run self.init_client self.create_student_teams end |