Class: TeachersPet::Actions::CreateRepos
- Inherits:
-
Base
- Object
- Base
- TeachersPet::Actions::CreateRepos
show all
- Defined in:
- lib/teachers_pet/actions/create_repos.rb
Instance Attribute Summary
Attributes inherited from Base
#client, #options
Instance Method Summary
collapse
Methods inherited from Base
#execute, #init_client, #initialize, #octokit_config, #read_file, #read_members_file, #read_students_file
Instance Method Details
#create ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/teachers_pet/actions/create_repos.rb', line 14
def create
self.init_client
org_hash = self.client.organization(@organization)
abort('Organization could not be found') if org_hash.nil?
puts "Found organization at: #{org_hash[:login]}"
org_teams = self.client.get_teams_by_name(@organization)
puts "\nCreating assignment repositories for students..."
@students.keys.sort.each do |student|
unless org_teams.key?(student)
puts(" ** ERROR ** - no team for #{student}")
next
end
repo_name = "#{student}-#{@repository}"
if self.client.repository?(@organization, repo_name)
puts " --> Already exists, skipping '#{repo_name}'"
next
end
puts " --> Creating '#{repo_name}' public? #{@public_repos}"
self.client.create_repository(repo_name,
description: "#{@repository} created for #{student}",
private: !@public_repos,
has_issues: true,
has_wiki: false,
has_downloads: false,
organization: @organization,
team_id: org_teams[student][:id]
)
end
end
|
#load_files ⇒ Object
10
11
12
|
# File 'lib/teachers_pet/actions/create_repos.rb', line 10
def load_files
@students = self.read_students_file
end
|
#read_info ⇒ Object
4
5
6
7
8
|
# File 'lib/teachers_pet/actions/create_repos.rb', line 4
def read_info
@repository = self.options[:repository]
@organization = self.options[:organization]
@public_repos = self.options[:public]
end
|
#run ⇒ Object
53
54
55
56
57
|
# File 'lib/teachers_pet/actions/create_repos.rb', line 53
def run
self.read_info
self.load_files
self.create
end
|