Sha256: d67b86e78e1ffc683bb152c7245d06aee9e36f4f01898b2b784c82b845ad643c

Contents?: true

Size: 953 Bytes

Versions: 1

Compression:

Stored size: 953 Bytes

Contents

require 'gitlab'

module Tanuki
  module Universe
    class GitlabClient

      GITLAB_API_VERSION = 'v4'

      attr_reader :group, :private_token, :url, :projects

      def initialize(options)
        parse_options(options)
        endpoint = "#{@url}api/#{GITLAB_API_VERSION}"
        @client = Gitlab.client(endpoint: endpoint, private_token: @private_token)
        get_projects
      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']
      end
      
      def get_projects
        @projects = @client.project_search(@group)
      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.4 lib/tanuki/universe/gitlab_client.rb