Sha256: 85341b4330ca7c48dcaa881d6ea834c717ad6679272f956e55384c5785882a9d

Contents?: true

Size: 1013 Bytes

Versions: 1

Compression:

Stored size: 1013 Bytes

Contents

require 'gitlab'

module Tanuki
  module Universe
    class GitlabClient

      GITLAB_API_VERSION = 'v4'

      attr_reader :projects

      def initialize(options)
        parse_options(options)
        endpoint = "#{@opt_url}api/#{GITLAB_API_VERSION}"
        @client = Gitlab.client(endpoint: endpoint, private_token: @opt_private_token)
      end

      def parse_options(options)
        @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_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

      def get_metadata(project_id, ref)
        @client.file_contents(project_id, 'metadata.rb', ref)
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tanuki-universe-0.0.5 lib/tanuki/universe/gitlab_client.rb