Class: Organizations
- Inherits:
-
Object
- Object
- Organizations
- Defined in:
- lib/actions/orgs.rb
Instance Attribute Summary collapse
-
#assiglist ⇒ Object
Returns the value of attribute assiglist.
-
#orgslist ⇒ Object
Returns the value of attribute orgslist.
Instance Method Summary collapse
- #add_group_to_assig(client, config, assig) ⇒ Object
- #add_repo_to_assig(client, config, assig) ⇒ Object
- #add_team_to_assig(client, config, assig, data) ⇒ Object
- #assignment_groups(client, config) ⇒ Object
- #assignment_repository(client, config, name) ⇒ Object
- #create_assig(client, config, name) ⇒ Object
- #get_assigs(client, config) ⇒ Object
- #get_single_assig(config, wanted) ⇒ Object
- #load_assig ⇒ Object
- #make_assig(client, config, assig) ⇒ Object
- #read_orgs(client) ⇒ Object
- #show_assig_info(config, assig) ⇒ Object
-
#show_assignments(client, config) ⇒ Object
client,orgs.
-
#show_organization_members_bs(client, config) ⇒ Object
————End assig.
- #show_orgs(client, config) ⇒ Object
Instance Attribute Details
#assiglist ⇒ Object
Returns the value of attribute assiglist.
11 12 13 |
# File 'lib/actions/orgs.rb', line 11 def assiglist @assiglist end |
#orgslist ⇒ Object
Returns the value of attribute orgslist.
10 11 12 |
# File 'lib/actions/orgs.rb', line 10 def orgslist @orgslist end |
Instance Method Details
#add_group_to_assig(client, config, assig) ⇒ Object
218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/actions/orgs.rb', line 218 def add_group_to_assig(client,config,assig) list=self.load_assig() groups=self.assignment_groups(client,config) if groups!="" groups.each do |i| list["orgs"].detect{|aux| aux["name"]==config["Org"]}["assigs"].detect{|aux2| aux2["name_assig"]==assig}["groups"].push(i) end Sys.new.save_assigs("#{ENV['HOME']}/.ghedsh",list) end end |
#add_repo_to_assig(client, config, assig) ⇒ Object
231 232 233 234 235 236 237 238 239 |
# File 'lib/actions/orgs.rb', line 231 def add_repo_to_assig(client,config,assig) list=self.load_assig() reponame=self.assignment_repository(client,config,assig["name_assig"]) if reponame!="" list["orgs"].detect{|aux| aux["name"]==config["Org"]}["assigs"].detect{|aux2| aux2["name_assig"]==assig}["repo"]=reponame Sys.new.save_assigs("#{ENV['HOME']}/.ghedsh",list) end end |
#add_team_to_assig(client, config, assig, data) ⇒ Object
212 213 214 215 216 |
# File 'lib/actions/orgs.rb', line 212 def add_team_to_assig(client,config,assig,data) assig=self.get_single_assig(config,assig) end |
#assignment_groups(client, config) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/actions/orgs.rb', line 80 def assignment_groups(client,config) team=Teams.new() groupslist=team.get_groupslist(config) groupsadd=[] puts "\n" puts "Add groups to your assignment (Press enter to skip): " op=gets.chomp if op=="" puts "Do you want to create a new group? (Press any key to preceed, or only enter to skip)" an=gets.chomp if an!="" time=Time.new puts "Put the name of the group (If you skip with enter, the group's name will be \"Group-#{time.ctime}\")" name=gets.chomp if name=="" name="Group-#{time.ctime}" name=name.split(" ").join("-") end puts "Put a list of Teams" list=gets.chomp list=list.split(" ") team.new_group(client,config,name,list) groupsadd.push(name) else groupsadd=[] end else groupsadd=op.split(" ") groupsadd.each do |item| if groupslist.detect{|aux| aux==item}==nil groupsadd.delete(item) end end end return groupsadd end |
#assignment_repository(client, config, name) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/actions/orgs.rb', line 48 def assignment_repository(client,config,name) ex=false until ex==true puts "\n" puts "Assignment: #{name}" puts "1) Add a repository already created " puts "2) Create a new empty repository" puts "3) Don't assign a repository yet" print "option => " op=gets.chomp if op=="3" or op=="1" or op=="2" ex=true end end case when op=="1" || op=="2" puts "Name of the repository: " reponame=gets.chomp if op==1 if client.repository?("#{config["Org"]}/#{reponame}")==false puts "The repository #{reponame} doesn't exist" reponame="" end end if op=="2" Repositories.new().create_repository(client,config,reponame,ORGS) end when op=="3" then reponame="" end return reponame end |
#create_assig(client, config, name) ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/actions/orgs.rb', line 119 def create_assig(client,config,name) list=self.load_assig() assigs=list["orgs"].detect{|aux| aux["name"]==config["Org"]} if assigs==nil list["orgs"].push({"name"=>config["Org"],"assigs"=>[]}) Sys.new.save_assigs("#{ENV['HOME']}/.ghedsh",list) end reponame=self.assignment_repository(client,config,name) groupsadd=self.assignment_groups(client,config) begin list["orgs"][list["orgs"].index{|aux| aux["name"]==config["Org"]}]["assigs"].push({"name_assig"=>name,"teams"=>[],"groups"=>groupsadd,"repo"=>reponame}) rescue Exception => e puts e end Sys.new.save_assigs("#{ENV['HOME']}/.ghedsh",list) end |
#get_assigs(client, config) ⇒ Object
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/actions/orgs.rb', line 139 def get_assigs(client,config) list=self.load_assig() assiglist=[] assig=list["orgs"].detect{|aux| aux["name"]==config["Org"]} if assig!=nil if assig["assigs"].empty? puts "No assignments are available yet" else assig["assigs"].each do |i| assiglist.push(i["name_assig"]) end end else list["orgs"].push({"name"=>config["Org"],"assigs"=>[]}) Sys.new.save_assigs("#{ENV['HOME']}/.ghedsh",list) end return assiglist end |
#get_single_assig(config, wanted) ⇒ Object
158 159 160 161 162 163 |
# File 'lib/actions/orgs.rb', line 158 def get_single_assig(config,wanted) list=self.load_assig() as=list["orgs"].detect{|aux| aux["name"]==config["Org"]} as=as["assigs"].detect{|aux| aux["name_assig"]==wanted} return as end |
#load_assig ⇒ Object
14 15 16 17 18 |
# File 'lib/actions/orgs.rb', line 14 def load_assig() @assiglist=Hash.new() @assiglist=Sys.new.load_assig_db("#{ENV['HOME']}/.ghedsh") return @assiglist end |
#make_assig(client, config, assig) ⇒ Object
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/actions/orgs.rb', line 178 def make_assig(client,config,assig) web="https://github.com/" web2="[email protected]:" repo=Repositories.new() team=Teams.new() teamlist=team.read_teamlist(client,config) assig=self.get_single_assig(config,assig) if assig["repo"]!="" system("git clone #{web2}#{config["Org"]}/#{assig["repo"]}.git") system("git-C #{assig["repo"]} remote rename origin professor") assig["groups"].each do |i| teamsforgroup=team.get_single_group(config,i) teamsforgroup.each do |y| config["TeamID"]=teamlist["#{y}"] config["Team"]=y repo.create_repository(client,config,"#{y}-#{assig["name_assig"]}",TEAM) #system("git-C #{assig["repo"]} remote rm origin") # system("git -C #{assig["repo"]} remote add origin #{web2}#{config["Org"]}/#{y}-#{assig["name_assig"]}.git") #system("git -C #{assig["repo"]} remote set-url origin #{web2}#{config["Org"]}/#{y}-#{assig["name_assig"]}.git") system("git -C #{assig["repo"]} remote add #{y} #{web2}#{config["Org"]}/#{y}-#{assig["name_assig"]}.git") system("git -C #{assig["repo"]} push #{y} --all") end end else puts "No repository is given for this assignment" end end |
#read_orgs(client) ⇒ Object
267 268 269 270 271 272 273 274 275 |
# File 'lib/actions/orgs.rb', line 267 def read_orgs(client) orgslist=[] org=client.organizations org.each do |i| o=eval(i.inspect) orgslist.push(o[:login]) end return orgslist end |
#show_assig_info(config, assig) ⇒ Object
165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/actions/orgs.rb', line 165 def show_assig_info(config,assig) assig=self.get_single_assig(config,assig) puts "\n" puts assig["name_assig"] puts "Repository: #{assig["repo"]}" print "Groups: " assig["groups"].each do |y| print y print " " end puts "\n\n" end |
#show_assignments(client, config) ⇒ Object
client,orgs
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 |
# File 'lib/actions/orgs.rb', line 20 def show_assignments(client, config) #client,orgs list=self.load_assig() assig=list["orgs"].detect{|aux| aux["name"]==config["Org"]} if assig!=nil if assig["assigs"].empty? puts "No assignments are available yet" else assig["assigs"].each do |i| puts "\n" puts i["name_assig"] puts "Repository: #{i["repo"]}" print "Groups: " i["groups"].each do |y| print y print " " end print "\n" end end else puts "No assignments are available yet" list["orgs"].push({"name"=>config["Org"],"assigs"=>[]}) Sys.new.save_assigs("#{ENV['HOME']}/.ghedsh",list) end end |
#show_organization_members_bs(client, config) ⇒ Object
————End assig. stuff————
242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/actions/orgs.rb', line 242 def show_organization_members_bs(client,config) orgslist=[] print "\n" mem=client.organization_members(config["Org"]) mem.each do |i| m=eval(i.inspect) orgslist.push(m[:login]) puts m[:login] end return orgslist end |
#show_orgs(client, config) ⇒ Object
254 255 256 257 258 259 260 261 262 263 264 265 |
# File 'lib/actions/orgs.rb', line 254 def show_orgs(client,config) orgslist=[] print "\n" org=client.organizations org.each do |i| o=eval(i.inspect) puts o[:login] orgslist.push(o[:login]) end print "\n" return orgslist end |