Sha256: f54b6a6ae16a79404c9966c0e8bb185e8803e50279c3e72c5c493c2f01573a69

Contents?: true

Size: 683 Bytes

Versions: 6

Compression:

Stored size: 683 Bytes

Contents

# frozen_string_literal: true

require 'date'

module Geet
  module Gitlab
    class Label
      attr_reader :name, :color

      def initialize(name, color)
        @name = name
        @color = color
      end

      # Returns a flat list of names in string form.
      def self.list(api_interface)
        api_path = "projects/#{api_interface.path_with_namespace(encoded: true)}/labels"
        response = api_interface.send_request(api_path, multipage: true)

        response.map do |label_entry|
          name = label_entry.fetch('name')
          color = label_entry.fetch('color').sub('#', '') # normalize

          new(name, color)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
geet-0.3.2 lib/geet/gitlab/label.rb
geet-0.3.1 lib/geet/gitlab/label.rb
geet-0.3.0 lib/geet/gitlab/label.rb
geet-0.2.1 lib/geet/gitlab/label.rb
geet-0.2.0 lib/geet/gitlab/label.rb
geet-0.1.12 lib/geet/gitlab/label.rb