|
|
|
@ -0,0 +1,63 @@ |
|
|
|
class Gitlab::Project |
|
|
|
include ActiveModel::Model |
|
|
|
|
|
|
|
attr_accessor :id, :description, :default_branch, :tag_list, :public, |
|
|
|
:archived, :visibility_level, :ssh_url_to_repo, :http_url_to_repo, |
|
|
|
:web_url, :name, :name_with_namespace, :path, :path_with_namespace, |
|
|
|
:issues_enabled, :merge_requests_enabled, :wiki_enabled, :builds_enabled, |
|
|
|
:snippets_enabled, :created_at, :last_activity_at, |
|
|
|
:shared_runners_enabled, :creator_id, :namespace, :owner, :avatar_url, |
|
|
|
:star_count, :forks_count, :open_issues_count, :public_builds, |
|
|
|
:permissions |
|
|
|
|
|
|
|
def self.all |
|
|
|
all = Array.new; |
|
|
|
|
|
|
|
api_base_uri = Rails.configuration.x.gitlab['api_base_uri'] |
|
|
|
auth_token = Rails.configuration.x.gitlab['auth_token'] |
|
|
|
|
|
|
|
links = { |
|
|
|
'next' => api_base_uri + 'projects?visibility=public', |
|
|
|
'first' => nil, |
|
|
|
'last' => nil |
|
|
|
} |
|
|
|
|
|
|
|
uri = URI.parse(links['next']) |
|
|
|
http = Net::HTTP.new(uri.host, uri.port) |
|
|
|
http.use_ssl = true # TODO make this aware of http/https |
|
|
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE |
|
|
|
|
|
|
|
while true |
|
|
|
request = Net::HTTP::Get.new(uri.request_uri) |
|
|
|
request['PRIVATE-TOKEN'] = auth_token |
|
|
|
|
|
|
|
response = http.request(request) |
|
|
|
|
|
|
|
JSON.parse(response.body).each do |project| |
|
|
|
all.push(Gitlab::Project.new(project)) |
|
|
|
end |
|
|
|
|
|
|
|
links = response['link'].split(',').map! { |a| |
|
|
|
_tmp = a.strip.split(';').map! { |a| |
|
|
|
a.strip |
|
|
|
} |
|
|
|
{_tmp[1][5...-1] => _tmp[0][1...-1]} |
|
|
|
}.reduce({}, :merge) |
|
|
|
|
|
|
|
break unless links['next'] |
|
|
|
uri = URI.parse(links['next']) |
|
|
|
end |
|
|
|
|
|
|
|
return all |
|
|
|
end |
|
|
|
|
|
|
|
def self.find |
|
|
|
end |
|
|
|
|
|
|
|
def deliver |
|
|
|
if valid? |
|
|
|
# deliver email |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
# vim: set ts=2 sw=2: |