ghedsh 1.1.2 → 1.1.3
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/lib/actions/system.rb +32 -34
- data/lib/interface.rb +82 -77
- data/lib/version.rb +1 -1
- metadata +2 -3
- data/lib/configure/configure_template.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: c8b0a139348f10866fd417e1e2f24711bdddb996
|
4
|
+
data.tar.gz: 6cc32b2b29fcd318259fd5531782a228fd461e9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59cc7bb5ee72870148df73d215baa69cf9710b0c71fca8d7ebbb7dc126fbaa2ab1f25b2d7e0f58bbb47a3d1a6160a6b821af9a842e7e7e177f6f34439fc0c4e8
|
7
|
+
data.tar.gz: 6d3269bc28cd6a270be3c5d4ccd1cbca7fd45d85d4508fdf6586879724be1ed8613f0f2cf6019fac6a45766080251d7ef0a18b51f4b2a6550d1e16197fc4953b
|
data/.gitignore
CHANGED
data/lib/actions/system.rb
CHANGED
@@ -1,30 +1,36 @@
|
|
1
1
|
require 'readline'
|
2
|
+
require 'fileutils'
|
2
3
|
require 'octokit'
|
3
4
|
require 'json'
|
4
5
|
require 'actions/system'
|
5
6
|
require 'version'
|
6
7
|
|
7
8
|
class Sys
|
9
|
+
attr_accessor :client
|
8
10
|
|
9
11
|
def load_config(configure_path)
|
10
|
-
if
|
11
|
-
|
12
|
+
if File.exist?(configure_path)
|
13
|
+
token=File.read("#{configure_path}/ghedsh-token")
|
14
|
+
json = File.read("#{configure_path}/ghedsh-cache.json")
|
12
15
|
config=JSON.parse(json)
|
13
16
|
|
14
|
-
if
|
15
|
-
|
16
|
-
|
17
|
+
if token!=""
|
18
|
+
@client=self.login(token)
|
19
|
+
config["User"]=@client.login
|
17
20
|
return config
|
21
|
+
else
|
22
|
+
return self.set_loguin_data_sh(config,configure_path)
|
18
23
|
end
|
19
24
|
else
|
20
|
-
configure_path
|
21
|
-
if (File.exist?(configure_path))==false
|
22
|
-
self.create_config(configure_path)
|
23
|
-
end
|
25
|
+
self.create_config(configure_path)
|
24
26
|
load_config(configure_path)
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
30
|
+
def save_token(path,token)
|
31
|
+
File.write(path,token)
|
32
|
+
end
|
33
|
+
|
28
34
|
def login(token)
|
29
35
|
user=Octokit::Client.new(:access_token =>token)
|
30
36
|
if user==false
|
@@ -34,56 +40,48 @@ class Sys
|
|
34
40
|
end
|
35
41
|
end
|
36
42
|
|
37
|
-
def set_loguin_data_sh(config)
|
43
|
+
def set_loguin_data_sh(config,configure_path)
|
38
44
|
puts "Insert you Access Token: "
|
39
45
|
token = gets.chomp
|
40
46
|
us=self.login(token)
|
41
47
|
if us!=nil
|
42
48
|
puts "Login succesful as #{us.login}"
|
43
49
|
config["User"]=us.login
|
44
|
-
config["Token"]=token
|
50
|
+
File.write("#{configure_path}/ghedsh-token",token) #config["Token"]=token
|
51
|
+
@client=us
|
45
52
|
return config
|
46
53
|
end
|
47
54
|
end
|
48
55
|
|
49
|
-
def load_assig_db
|
50
|
-
path='./lib/db/assignments.json'
|
56
|
+
def load_assig_db(path)
|
51
57
|
if (File.exist?(path))==true
|
52
|
-
json = File.read(path)
|
58
|
+
json = File.read("#{path}/db/assignments.json")
|
53
59
|
else
|
54
|
-
path="
|
55
|
-
json = File.read(path)
|
60
|
+
#path="/db/assignments.json"
|
61
|
+
#json = File.read(path)
|
56
62
|
end
|
57
63
|
config=JSON.parse(json)
|
58
64
|
return config
|
59
65
|
end
|
60
66
|
|
61
|
-
def create_config(
|
62
|
-
|
63
|
-
|
67
|
+
def create_config(configure_path)
|
68
|
+
con={:User=>nil,:Org=>nil,:Repo=>nil,:Team=>nil,:TeamID=>nil}
|
69
|
+
FileUtils.mkdir_p(configure_path)
|
70
|
+
File.new("#{configure_path}/ghedsh-token","w")
|
71
|
+
File.write("#{configure_path}/ghedsh-cache.json",con.to_json)
|
64
72
|
end
|
65
73
|
|
66
|
-
def save_config(data)
|
67
|
-
if (File.exist?('./lib/configure/configure.json'))==true
|
68
|
-
File.write('./lib/configure/configure.json', data.to_json)
|
69
|
-
else
|
70
|
-
File.write("#{ENV['GEM_HOME']}/gems/ghedsh-#{Ghedsh::VERSION}/lib/configure/configure.json", data.to_json)
|
71
|
-
end
|
72
|
-
end
|
73
74
|
|
74
|
-
def
|
75
|
-
|
76
|
-
File.write('./lib/db/assignments.json', data.to_json)
|
77
|
-
else
|
78
|
-
File.write("#{ENV['GEM_HOME']}/gems/ghedsh-#{Ghedsh::VERSION}/lib/db/assignments.json", data.to_json)
|
79
|
-
end
|
75
|
+
def save_cache(path,data)
|
76
|
+
File.write('./.ghedsh/ghedsh-cache.json',data.to_json)
|
80
77
|
end
|
81
78
|
|
82
|
-
def
|
83
|
-
#
|
79
|
+
def save_db(path,data)
|
80
|
+
File.write("#{path}/db/assignments.json", data.to_json)
|
84
81
|
end
|
85
82
|
|
86
83
|
|
84
|
+
|
87
85
|
def search_rexp(list,exp)
|
88
86
|
list= list.select{|o| o.match(/#{exp}/)}
|
89
87
|
#puts list
|
data/lib/interface.rb
CHANGED
@@ -231,96 +231,101 @@ class Interface
|
|
231
231
|
HelpM.new.welcome()
|
232
232
|
t=Teams.new
|
233
233
|
r=Repositories.new
|
234
|
-
|
234
|
+
s=Sys.new
|
235
235
|
# orden de búsqueda: ~/.ghedsh.json ./ghedsh.json ENV["ghedsh"] --configpath path/to/file.json
|
236
|
-
config_path = './lib/configure/configure.json'
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
236
|
+
#config_path = './lib/configure/configure.json'
|
237
|
+
config_path = './.ghedsh'
|
238
|
+
# if self.load_config(config_path) == true
|
239
|
+
#self.load_config(config_path)
|
240
|
+
@config=s.load_config(config_path)
|
241
|
+
@client=s.client
|
242
|
+
@deep=1
|
243
|
+
#@client=Sys.new.login(@config["Token"])
|
244
|
+
self.add_history_str(2,Organizations.new.read_orgs(@client))
|
245
|
+
|
246
|
+
while ex != 0
|
247
|
+
op=Readline.readline(self.prompt,true)
|
248
|
+
opcd=op.split
|
249
|
+
case
|
250
|
+
when op == "exit" then ex=0
|
251
|
+
when op == "help" then self.help()
|
248
252
|
#when op == "repos" then self.repos()
|
249
253
|
#when op == "ls -l" then self.lsl()
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
254
|
+
when op == "orgs" then self.orgs()
|
255
|
+
when op == "cd .." then self.cdback()
|
256
|
+
when op == "members" then self.members()
|
257
|
+
when op == "teams" #then self.teams()
|
258
|
+
if @deep==2
|
259
|
+
Teams.new.show_teams_bs(@client,@config)
|
260
|
+
end
|
261
|
+
when op == "commits" then self.commits()
|
262
|
+
when op == "col" then self.collaborators()
|
263
|
+
when op == "forks" then self.show_forks()
|
264
|
+
end
|
265
|
+
if opcd[0]=="cd" and opcd[1]!=".."
|
266
|
+
self.cd(opcd[1])
|
263
267
|
#else
|
264
268
|
# self.cdback()
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
when @deep==2
|
277
|
-
r.show_repos_smart(@client,@config,opcd[1],2)
|
278
|
-
when @deep==3
|
279
|
-
r.show_repos_smart(@client,@config,opcd[1],3)
|
280
|
-
end
|
281
|
-
end
|
282
|
-
if opcd[0]=="add_team_member"
|
283
|
-
t.add_to_team(@client,@config,opcd[1])
|
284
|
-
end
|
285
|
-
if opcd[0]=="create_team" and opcd.size==2
|
286
|
-
t.create_team(@client,@config,opcd[1])
|
287
|
-
@teamlist=t.read_teamlist(@client,@config)
|
288
|
-
self.add_history_str(1,@teamlist)
|
289
|
-
end
|
290
|
-
if opcd[0]=="delete_team"
|
291
|
-
t.delete_team(@client,@teamlist[opcd[1]])
|
292
|
-
self.quit_history(@teamlist[opcd[1]])
|
293
|
-
@teamlist=t.read_teamlist(@client,@config)
|
294
|
-
self.add_history_str(1,@teamlist)
|
295
|
-
end
|
296
|
-
if opcd[0]=="create_team" and opcd.size>2
|
297
|
-
t.create_team_with_members(@client,@config,opcd[1],opcd[2..opcd.size])
|
298
|
-
@teamlist=t.read_teamlist(@client,@config)
|
299
|
-
self.add_history_str(1,@teamlist)
|
300
|
-
end
|
301
|
-
if opcd[0]=="create_repository" and opcd.size==2
|
302
|
-
r.create_repository(@client,@config,opcd[1],@deep)
|
303
|
-
end
|
304
|
-
if opcd[0]=="create_repository" and opcd.size>2
|
305
|
-
case
|
269
|
+
end
|
270
|
+
if opcd[0]=="set"
|
271
|
+
self.set(opcd[1])
|
272
|
+
end
|
273
|
+
if opcd[0]=="repos" and opcd.size==1
|
274
|
+
self.repos()
|
275
|
+
end
|
276
|
+
if opcd[0]=="repos" and opcd.size>1
|
277
|
+
case
|
278
|
+
when @deep==1
|
279
|
+
r.show_repos_smart(@client,@config,opcd[1],1)
|
306
280
|
when @deep==2
|
307
|
-
r.
|
308
|
-
|
281
|
+
r.show_repos_smart(@client,@config,opcd[1],2)
|
282
|
+
when @deep==3
|
283
|
+
r.show_repos_smart(@client,@config,opcd[1],3)
|
309
284
|
end
|
310
|
-
|
311
|
-
|
312
|
-
|
285
|
+
end
|
286
|
+
if opcd[0]=="add_team_member"
|
287
|
+
t.add_to_team(@client,@config,opcd[1])
|
288
|
+
end
|
289
|
+
if opcd[0]=="create_team" and opcd.size==2
|
290
|
+
t.create_team(@client,@config,opcd[1])
|
291
|
+
@teamlist=t.read_teamlist(@client,@config)
|
292
|
+
self.add_history_str(1,@teamlist)
|
293
|
+
end
|
294
|
+
if opcd[0]=="delete_team"
|
295
|
+
t.delete_team(@client,@teamlist[opcd[1]])
|
296
|
+
self.quit_history(@teamlist[opcd[1]])
|
297
|
+
@teamlist=t.read_teamlist(@client,@config)
|
298
|
+
self.add_history_str(1,@teamlist)
|
299
|
+
end
|
300
|
+
if opcd[0]=="create_team" and opcd.size>2
|
301
|
+
t.create_team_with_members(@client,@config,opcd[1],opcd[2..opcd.size])
|
302
|
+
@teamlist=t.read_teamlist(@client,@config)
|
303
|
+
self.add_history_str(1,@teamlist)
|
304
|
+
end
|
305
|
+
if opcd[0]=="create_repository" and opcd.size==2
|
306
|
+
r.create_repository(@client,@config,opcd[1],@deep)
|
307
|
+
end
|
308
|
+
if opcd[0]=="create_repository" and opcd.size>2
|
309
|
+
case
|
310
|
+
when @deep==2
|
311
|
+
r.create_repository_by_teamlist(@client,@config,opcd[1],opcd[2,opcd.size],self.get_teamlist(opcd[2,opcd.size]))
|
313
312
|
end
|
313
|
+
end
|
314
314
|
|
315
|
-
|
315
|
+
if opcd[0]=="clone_repo" and opcd.size==2
|
316
|
+
r.clone_repo(@client,@config,opcd[1],@deep)
|
317
|
+
end
|
318
|
+
|
319
|
+
if opcd[0]=="clone_repo" and opcd.size>2
|
316
320
|
#r.clone_repo(@client,@config,opcd[1])
|
317
|
-
end
|
318
321
|
end
|
319
|
-
else
|
320
|
-
Sys.new.set_loguin_data_sh()
|
321
322
|
end
|
323
|
+
# else
|
324
|
+
# Sys.new.set_loguin_data_sh()
|
325
|
+
# end
|
322
326
|
|
323
|
-
Sys.new.save_config(@config)
|
327
|
+
#Sys.new.save_config(@config)
|
328
|
+
s.save_cache(config_path,@config)
|
324
329
|
end
|
325
330
|
|
326
331
|
end
|
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.3
|
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-04-
|
12
|
+
date: 2016-04-18 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/configure/configure_template.json
|
91
90
|
- lib/db/assignments.json
|
92
91
|
- lib/interface.rb
|
93
92
|
- lib/version.rb
|
@@ -1 +0,0 @@
|
|
1
|
-
{"User":null,"Token":null,"Org":null,"Repo":null,"Team":null,"TeamID":null}
|