ghedsh 1.1.15 → 1.1.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +10 -14
- data/lib/actions/help.rb +1 -0
- data/lib/actions/orgs.rb +74 -10
- data/lib/actions/repo.rb +15 -1
- data/lib/actions/system.rb +25 -6
- data/lib/interface.rb +67 -11
- data/lib/version.rb +1 -1
- metadata +2 -3
- data/lib/db/assignments.json +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7bed6aad874d5f0faf8a0b387eba24d5b4a9353
|
4
|
+
data.tar.gz: 519dafec3cc338ede392b2dd1bf38f6c1e864efc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ec45575411bc1e8062f486fa71664fa3f0932c5a203afc3970181ee7124959629a90fa3fa35f1a506b480ba260fe65ad4ff03639f0a6ba21a1deffe5275e81c
|
7
|
+
data.tar.gz: 1c53cedf872f4fcc6c544456ab357ea07d8faa4651a6299823a7c58e3b06e45d961288c7dea7958baccc74f9c1a25802bee824609758ca1428a0487944e1e5fe
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -9,25 +9,21 @@ This program give you an interaction with Github like you was using your command
|
|
9
9
|
|
10
10
|
Following the philosophy of Github Education, you can use this application to managing your own organization as a classroom where you can make assignments to your students using repository strategies.
|
11
11
|
|
12
|
-
##
|
12
|
+
##Installing GHEDSH
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
[Link to create a new personal access token](https://github.com/settings/tokens/new?description=ghedsh)
|
17
|
-
|
18
|
-
You need to tick all options, unless admin:gpg_key scopes.
|
14
|
+
You can download the gem **ghdesh** from rubygem.
|
19
15
|
|
16
|
+
``gem install ghdesh``
|
20
17
|
|
21
|
-
|
18
|
+
To run the app you need to call the binary file "ghedsh" in your command line after install it. Configuration files are being set in a hidden directory called *.ghedsh*, in your Home path.
|
22
19
|
|
23
|
-
|
20
|
+
###First step: Oauth requirements.
|
24
21
|
|
25
|
-
|
26
|
-
Instead of download the program from the repository, you can download the gem **ghdesh** from rubygem.
|
22
|
+
Ir order to run this program, you need to make an **Access token** from Github with create and edit scope. When you run the program, it asks you the access token to identify yourself with no need to use your user and password.
|
27
23
|
|
28
|
-
|
24
|
+
[Link to create a new personal access token](https://github.com/settings/tokens/new?description=ghedsh)
|
29
25
|
|
30
|
-
|
26
|
+
You need to tick all options, unless admin:gpg_key scopes.
|
31
27
|
|
32
28
|
###ghedsh executable options
|
33
29
|
|
@@ -152,7 +148,7 @@ issues
|
|
152
148
|
Muestra los issues del repositorio en el que se encuentre el usuario.
|
153
149
|
|
154
150
|
|
155
|
-
|
156
|
-
|
157
151
|
##Aditional information
|
152
|
+
[GHEDSH extended info](https://alu0100505023.gitbooks.io/ghedsh/content/en/)
|
153
|
+
|
158
154
|
[Github Education](https://education.github.com/)
|
data/lib/actions/help.rb
CHANGED
@@ -64,6 +64,7 @@ class HelpM
|
|
64
64
|
|
65
65
|
def common_opt()
|
66
66
|
puts "\nList of commands\n"
|
67
|
+
print "\tdo\t\t\trun a script in ghedsh execute path\n"
|
67
68
|
print "\texit\t\t\texit from this program\n"
|
68
69
|
print "\thelp\t\t\tlist of commands available\n"
|
69
70
|
print "\tcd\t\t\tgo to the path\n"
|
data/lib/actions/orgs.rb
CHANGED
@@ -12,28 +12,92 @@ class Organizations
|
|
12
12
|
|
13
13
|
def load_assig()
|
14
14
|
@assiglist=Hash.new()
|
15
|
-
@assiglist=Sys.new.load_assig_db()
|
15
|
+
@assiglist=Sys.new.load_assig_db("#{ENV['HOME']}/.ghedsh")
|
16
16
|
return @assiglist
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
20
|
-
|
21
|
-
puts org["name"]
|
19
|
+
def show_assignments(client, config) #client,orgs
|
20
|
+
list=self.load_assig()
|
22
21
|
|
23
|
-
|
24
|
-
|
22
|
+
assig=list["orgs"].detect{|aux| aux["name"]==config["Org"]}
|
23
|
+
if assig!=nil
|
24
|
+
if assig["assigs"].empty?
|
25
|
+
puts "No assignments are available yet"
|
26
|
+
else
|
27
|
+
assig["assigs"].each do |i|
|
28
|
+
puts "\n"
|
29
|
+
puts i["name_assig"]
|
30
|
+
puts "Repository: #{i["repo"]}"
|
31
|
+
puts "Groups: "
|
32
|
+
puts "Teams: "
|
33
|
+
# i["teams"].each do |j|
|
34
|
+
# puts "\t#{j}"
|
35
|
+
# end
|
36
|
+
end
|
25
37
|
end
|
26
|
-
|
38
|
+
else
|
39
|
+
puts "No assignments are available yet"
|
40
|
+
list["orgs"].push({"name"=>config["Org"],"assigs"=>[]})
|
41
|
+
Sys.new.save_assigs("#{ENV['HOME']}/.ghedsh",list)
|
27
42
|
end
|
43
|
+
|
28
44
|
end
|
29
|
-
|
30
|
-
|
45
|
+
|
46
|
+
def create_assig(client,config,name)
|
47
|
+
list=self.load_assig()
|
48
|
+
assigs=list["orgs"].detect{|aux| aux["name"]==config["Org"]}
|
49
|
+
|
50
|
+
if assigs==nil
|
51
|
+
list["orgs"].push({"name"=>config["Org"],"assigs"=>[]})
|
52
|
+
Sys.new.save_assigs("#{ENV['HOME']}/.ghedsh",list)
|
53
|
+
end
|
54
|
+
|
55
|
+
begin
|
56
|
+
list["orgs"][list["orgs"].index{|aux| aux["name"]==config["Org"]}]["assigs"].push({"name_assig"=>name,"teams"=>[],"groups"=>[],"repo"=>nil})
|
57
|
+
rescue Exception => e
|
58
|
+
puts e
|
59
|
+
end
|
60
|
+
Sys.new.save_assigs("#{ENV['HOME']}/.ghedsh",list)
|
61
|
+
|
31
62
|
end
|
32
63
|
|
33
|
-
|
64
|
+
|
65
|
+
def get_assigs(client,config)
|
66
|
+
list=self.load_assig()
|
67
|
+
assiglist=[]
|
68
|
+
assig=list["orgs"].detect{|aux| aux["name"]==config["Org"]}
|
69
|
+
if assig!=nil
|
70
|
+
if assig["assigs"].empty?
|
71
|
+
puts "No assignments are available yet"
|
72
|
+
else
|
73
|
+
assig["assigs"].each do |i|
|
74
|
+
assiglist.push(i["name_assig"])
|
75
|
+
end
|
76
|
+
end
|
77
|
+
else
|
78
|
+
list["orgs"].push({"name"=>config["Org"],"assigs"=>[]})
|
79
|
+
Sys.new.save_assigs("#{ENV['HOME']}/.ghedsh",list)
|
80
|
+
end
|
81
|
+
return assiglist
|
34
82
|
end
|
35
83
|
|
84
|
+
|
85
|
+
|
36
86
|
def add_team_to_assig(client,config,data)
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
def add_group_to_assig(client,config,data)
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
def add_repo_to_assig(client,config,data)
|
95
|
+
options=Hash.new
|
96
|
+
options[:organization]=config["Org"]
|
97
|
+
options[:auto_init]=true
|
98
|
+
|
99
|
+
client.create_repository(data,options)
|
100
|
+
|
37
101
|
end
|
38
102
|
#------------End assig. stuff------------
|
39
103
|
|
data/lib/actions/repo.rb
CHANGED
@@ -49,9 +49,23 @@ class Repositories
|
|
49
49
|
#print i[:sha],"\n",i[:commit][:author][:name],"\n",i[:commit][:author][:date],"\n",i[:commit][:message],"\n\n"
|
50
50
|
puts "##{i[:number]} state: #{i[:state]} -> #{i[:title]} "
|
51
51
|
end
|
52
|
+
return mem
|
52
53
|
puts "\n"
|
53
54
|
end
|
54
55
|
|
56
|
+
def get_issues(client,config,scope)
|
57
|
+
case
|
58
|
+
when scope==USER_REPO
|
59
|
+
if config["Repo"].split("/").size == 1
|
60
|
+
mem=client.list_issues(config["User"]+"/"+config["Repo"],{:state=>"all"})
|
61
|
+
else
|
62
|
+
mem=client.list_issues(config["Repo"],{:state=>"all"})
|
63
|
+
end
|
64
|
+
when scope==ORGS_REPO || scope==TEAM_REPO
|
65
|
+
mem=client.list_issues(config["Org"]+"/"+config["Repo"],{:state=>"all"})
|
66
|
+
end
|
67
|
+
return mem
|
68
|
+
end
|
55
69
|
#Show repositories and return a list of them
|
56
70
|
#exp = regular expression
|
57
71
|
def show_repos(client,config,scope,exp)
|
@@ -380,7 +394,7 @@ class Repositories
|
|
380
394
|
if show!=false
|
381
395
|
self.show_files(list)
|
382
396
|
else
|
383
|
-
return list
|
397
|
+
return list
|
384
398
|
end
|
385
399
|
else
|
386
400
|
puts "#{path} is not a directory. If you want to open a file try to use cat <path>"
|
data/lib/actions/system.rb
CHANGED
@@ -9,7 +9,8 @@ require 'version'
|
|
9
9
|
class Sys
|
10
10
|
attr_reader :client
|
11
11
|
attr_reader :memory
|
12
|
-
LIST = ['repos', 'exit', 'orgs','help', 'people','teams', 'cd ', 'cd repo ','commits','forks', 'add_team_member ','new_team ','rm_team ','new_repository ','new_assignment ','clone ', 'issues',
|
12
|
+
LIST = ['repos', 'exit', 'orgs','help', 'people','teams', 'cd ', 'cd repo ','commits','forks', 'add_team_member ','new_team ','rm_team ','new_repository ','new_assignment ','clone ', 'issues',
|
13
|
+
'version', 'cat ', 'groups', 'files', 'assignments'].sort
|
13
14
|
|
14
15
|
def initialize()
|
15
16
|
@memory=[]
|
@@ -165,13 +166,27 @@ class Sys
|
|
165
166
|
|
166
167
|
def load_assig_db(path)
|
167
168
|
if (File.exist?(path))==true
|
168
|
-
|
169
|
+
if File.exist?("#{path}/assignments.json")
|
170
|
+
json = File.read("#{path}/assignments.json")
|
171
|
+
else
|
172
|
+
#{"Organization":[{"name":null,"assignments":[{"name":null,"teams":{"teamid":null}}]}]}
|
173
|
+
con={:orgs=>[]}
|
174
|
+
File.write("#{path}/assignments.json",con.to_json)
|
175
|
+
json = File.read("#{path}/assignments.json")
|
176
|
+
end
|
177
|
+
end
|
178
|
+
config=JSON.parse(json)
|
179
|
+
return config
|
180
|
+
end
|
181
|
+
|
182
|
+
def load_script(path)
|
183
|
+
if (File.exist?(path))==true
|
184
|
+
script = File.read("#{path}")
|
185
|
+
return script.split("\n")
|
169
186
|
else
|
170
|
-
|
171
|
-
|
187
|
+
puts "No script is found with that name"
|
188
|
+
return []
|
172
189
|
end
|
173
|
-
config=JSON.parse(json)
|
174
|
-
return config
|
175
190
|
end
|
176
191
|
|
177
192
|
def load_groups(path)
|
@@ -195,6 +210,10 @@ class Sys
|
|
195
210
|
File.write("#{path}/groups.json",data.to_json)
|
196
211
|
end
|
197
212
|
|
213
|
+
def save_assigs(path,data)
|
214
|
+
File.write("#{path}/assignments.json",data.to_json)
|
215
|
+
end
|
216
|
+
|
198
217
|
#creates all ghedsh local stuff
|
199
218
|
def create_config(configure_path)
|
200
219
|
con={:User=>nil,:Org=>nil,:Repo=>nil,:Team=>nil,:TeamID=>nil}
|
data/lib/interface.rb
CHANGED
@@ -17,6 +17,7 @@ ORGS=2
|
|
17
17
|
USER_REPO=10
|
18
18
|
ORGS_REPO=3
|
19
19
|
TEAM=4
|
20
|
+
ASSIG=6
|
20
21
|
TEAM_REPO=5
|
21
22
|
|
22
23
|
class Interface
|
@@ -25,7 +26,7 @@ class Interface
|
|
25
26
|
attr_accessor :client
|
26
27
|
attr_accessor :deep
|
27
28
|
attr_accessor :memory
|
28
|
-
attr_reader :orgs_list,:repos_list, :teamlist, :orgs_repos, :teams_repos, :repo_path
|
29
|
+
attr_reader :orgs_list,:repos_list, :teamlist, :orgs_repos, :teams_repos, :repo_path, :assig_path, :issues_list
|
29
30
|
|
30
31
|
def initialize
|
31
32
|
@sysbh=Sys.new()
|
@@ -46,7 +47,7 @@ class Interface
|
|
46
47
|
raise
|
47
48
|
rescue Exception => e
|
48
49
|
puts "exit"
|
49
|
-
|
50
|
+
puts e
|
50
51
|
end
|
51
52
|
end
|
52
53
|
end
|
@@ -61,6 +62,7 @@ class Interface
|
|
61
62
|
return @config["User"]+">"+ "\e[31m#{@config["Repo"]}\e[0m"+"> "
|
62
63
|
end
|
63
64
|
when @deep == ORGS then return @config["User"]+">"+ "\e[34m#{@config["Org"]}\e[0m"+"> "
|
65
|
+
when @deep == ASSIG then return @config["User"]+">"+ "\e[34m#{@config["Org"]}\e[0m"+">"+"\e[35m#{@assig_path}\e[0m"+"> "
|
64
66
|
when @deep == TEAM then return @config["User"]+">"+"\e[34m#{@config["Org"]}\e[0m"+">"+"\e[32m#{@config["Team"]}\e[0m"+"> "
|
65
67
|
when @deep == TEAM_REPO
|
66
68
|
if @repo_path!=""
|
@@ -134,6 +136,9 @@ class Interface
|
|
134
136
|
@config["TeamID"]=nil
|
135
137
|
@teams_repos=[]
|
136
138
|
@deep=2
|
139
|
+
when @deep == ASSIG
|
140
|
+
@deep=ORGS
|
141
|
+
@assig_path=""
|
137
142
|
when @deep == TEAM_REPO
|
138
143
|
if @repo_path==""
|
139
144
|
@config["Repo"]=nil
|
@@ -155,7 +160,7 @@ class Interface
|
|
155
160
|
@config["TeamID"]=nil
|
156
161
|
@deep=1
|
157
162
|
@orgs_repos=[]; @teams_repos=[]
|
158
|
-
@repo_path=""
|
163
|
+
@repo_path=""; @assig_path="";
|
159
164
|
end
|
160
165
|
end
|
161
166
|
|
@@ -189,7 +194,9 @@ class Interface
|
|
189
194
|
@deep=TEAM
|
190
195
|
else
|
191
196
|
puts "\nNo team is available with that name"
|
192
|
-
|
197
|
+
if cdassig(path)==false
|
198
|
+
self.set(path)
|
199
|
+
end
|
193
200
|
end
|
194
201
|
when @deep == TEAM
|
195
202
|
self.set(path)
|
@@ -221,6 +228,7 @@ class Interface
|
|
221
228
|
end
|
222
229
|
else
|
223
230
|
puts "\nNo organization is available with that name"
|
231
|
+
self.set(path)
|
224
232
|
end
|
225
233
|
when @deep==ORGS
|
226
234
|
if aux[path_split[0]]!=nil
|
@@ -294,6 +302,20 @@ class Interface
|
|
294
302
|
end
|
295
303
|
end
|
296
304
|
|
305
|
+
def cdassig(path)
|
306
|
+
o=Organizations.new()
|
307
|
+
list=o.get_assigs(@client,@config)
|
308
|
+
if list.one?{|aux| aux==path}
|
309
|
+
@deep=ASSIG
|
310
|
+
@assig_path=path
|
311
|
+
puts "Set in #{@config["Org"]} assignment: #{path}\n\n"
|
312
|
+
return true
|
313
|
+
else
|
314
|
+
puts "No assignment is available with that name"
|
315
|
+
return false
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
297
319
|
def orgs()
|
298
320
|
case
|
299
321
|
when @deep==USER
|
@@ -396,10 +418,11 @@ class Interface
|
|
396
418
|
#Main program
|
397
419
|
def run(config_path, argv_token,user)
|
398
420
|
ex=1
|
421
|
+
opscript=[]
|
399
422
|
|
400
423
|
@sysbh.write_initial_memory()
|
401
424
|
HelpM.new.welcome()
|
402
|
-
|
425
|
+
o=Organizations.new
|
403
426
|
t=Teams.new
|
404
427
|
r=Repositories.new
|
405
428
|
s=Sys.new
|
@@ -424,8 +447,15 @@ class Interface
|
|
424
447
|
|
425
448
|
while ex != 0
|
426
449
|
|
427
|
-
|
428
|
-
|
450
|
+
if opscript.empty?
|
451
|
+
op=Readline.readline(self.prompt,true)
|
452
|
+
opcd=op.split
|
453
|
+
else
|
454
|
+
op=opscript[0]
|
455
|
+
opcd=op.split
|
456
|
+
opscript.delete(opscript[0])
|
457
|
+
end
|
458
|
+
|
429
459
|
case
|
430
460
|
when op == "exit" then ex=0
|
431
461
|
s.save_cache(config_path,@config)
|
@@ -440,7 +470,7 @@ class Interface
|
|
440
470
|
when op == "commits" then self.commits()
|
441
471
|
when op == "issues"
|
442
472
|
if @deep==ORGS_REPO || @deep==USER_REPO || @deep==TEAM_REPO
|
443
|
-
r.show_issues(@client,@config,@deep)
|
473
|
+
@issues_list=r.show_issues(@client,@config,@deep)
|
444
474
|
end
|
445
475
|
when op == "col" then self.collaborators()
|
446
476
|
when op == "forks" then self.show_forks()
|
@@ -450,10 +480,32 @@ class Interface
|
|
450
480
|
end
|
451
481
|
when op == "version"
|
452
482
|
puts "GitHub Education Shell v#{Ghedsh::VERSION}"
|
483
|
+
when op == "assignments"
|
484
|
+
if @deep==ORGS
|
485
|
+
o.show_assignments(@cliente,@config)
|
486
|
+
end
|
487
|
+
end
|
488
|
+
|
489
|
+
if opcd[0]=="issue" and opcd.size>1
|
490
|
+
issfound=0
|
491
|
+
@issues_list=r.get_issues(@client,@config,@deep)
|
492
|
+
if @issues_list!=nil
|
493
|
+
@issues_list.each do |i|
|
494
|
+
if i[:number]==opcd[1].to_i
|
495
|
+
puts "##{i[:number]} state: #{i[:state]} -> #{i[:title]} \n"
|
496
|
+
puts "#{i[:body]}"
|
497
|
+
issfound=1
|
498
|
+
end
|
499
|
+
end
|
500
|
+
end
|
501
|
+
if issfound==0
|
502
|
+
puts "Issue not found"
|
503
|
+
end
|
504
|
+
puts "\n"
|
453
505
|
end
|
454
506
|
|
455
507
|
if opcd[0]=="cd" and opcd[1]!=".."
|
456
|
-
if opcd[1]=="/"
|
508
|
+
if opcd[1]=="/" or opcd.size==1
|
457
509
|
self.cdback(true)
|
458
510
|
else
|
459
511
|
if opcd[1]=="repo" and opcd.size>2
|
@@ -463,6 +515,9 @@ class Interface
|
|
463
515
|
end
|
464
516
|
end
|
465
517
|
end
|
518
|
+
if opcd[0]=="do" and opcd.size>1
|
519
|
+
opscript=s.load_script(opcd[1])
|
520
|
+
end
|
466
521
|
if opcd[0]=="set"
|
467
522
|
self.set(opcd[1])
|
468
523
|
end
|
@@ -520,10 +575,11 @@ class Interface
|
|
520
575
|
if opcd[0]=="new_repository" and opcd.size==2
|
521
576
|
r.create_repository(@client,@config,opcd[1],@deep)
|
522
577
|
end
|
523
|
-
if opcd[0]=="new_assignment" and opcd.size>2
|
578
|
+
if opcd[0]=="new_assignment" and opcd.size>1 #2
|
524
579
|
case
|
525
580
|
when @deep==ORGS
|
526
|
-
r.create_repository_by_teamlist(@client,@config,opcd[1],opcd[2,opcd.size],self.get_teamlist(opcd[2,opcd.size]))
|
581
|
+
#r.create_repository_by_teamlist(@client,@config,opcd[1],opcd[2,opcd.size],self.get_teamlist(opcd[2,opcd.size]))
|
582
|
+
o.create_assig(@client,@config,opcd[1])
|
527
583
|
end
|
528
584
|
end
|
529
585
|
if opcd[0]=="new_group" and opcd.size>2
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ghedsh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Javier Clemente
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-06-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: octokit
|
@@ -87,7 +87,6 @@ files:
|
|
87
87
|
- lib/actions/system.rb
|
88
88
|
- lib/actions/teams.rb
|
89
89
|
- lib/actions/user.rb
|
90
|
-
- lib/db/assignments.json
|
91
90
|
- lib/interface.rb
|
92
91
|
- lib/version.rb
|
93
92
|
- spec/spec.rb
|
data/lib/db/assignments.json
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"Organization":[{"name":null,"assignements":[{"name":null,"teams":{"teamid":null}}]}]}
|