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
|
# File 'lib/octoplex/client/root.rb', line 48
def repos(*user_and_repo)
if user_and_repo.size == 2
user = user_and_repo[0]
repo = user_and_repo[1]
elsif user_and_repo.first.is_a?(String) && !user_and_repo.first.index('/').nil?
user, repo = user_and_repo[0].split('/', 2)
elsif user_and_repo.size == 1
user = user_and_repo[0]
repo = nil
else
raise ArgumentError, "Unknown arguments: #{user_and_repo.split(', ')}"
end
if repo.nil?
path = "/users/#{user}/repos"
else
path = "/repos/#{user}/#{repo}"
end
data = get(path)
if data.is_a?(Array)
data.map { |o| Octoplex::Client::Repository.new(self, o) }
else
Octoplex::Client::Repository.new(self, data)
end
end
|