lib/tanuki/universe/gitlab_client.rb in tanuki-universe-0.0.4 vs lib/tanuki/universe/gitlab_client.rb in tanuki-universe-0.0.5

- old
+ new

@@ -4,26 +4,29 @@ module Universe class GitlabClient GITLAB_API_VERSION = 'v4' - attr_reader :group, :private_token, :url, :projects + attr_reader :projects def initialize(options) parse_options(options) - endpoint = "#{@url}api/#{GITLAB_API_VERSION}" - @client = Gitlab.client(endpoint: endpoint, private_token: @private_token) - get_projects + endpoint = "#{@opt_url}api/#{GITLAB_API_VERSION}" + @client = Gitlab.client(endpoint: endpoint, private_token: @opt_private_token) end def parse_options(options) - @group = ENV['GITLAB_COOKBOOKS_GROUP'] || options['group'] - @private_token = ENV['GITLAB_API_PRIVATE_TOKEN'] || options['private_token'] - @url = ENV['GITLAB_API_ENDPOINT'] || options['url'] + @opt_group = ENV['GITLAB_COOKBOOKS_GROUP'] || options['group'] + @opt_private_token = ENV['GITLAB_API_PRIVATE_TOKEN'] || options['private_token'] + @opt_url = ENV['GITLAB_API_ENDPOINT'] || options['url'] end - def get_projects - @projects = @client.project_search(@group) + def get_groups + @opt_groups = @client.group_search(@opt_group) + end + + def get_projects(group_id) + @projects = @client.group(group_id) end def get_git_tags(project_id) @client.tags(project_id) end