class Labelito::GithubClient

Public Class Methods

new(client) click to toggle source
# File lib/Labelito/github_client.rb, line 7
def initialize(client)
  @client = client
end
with_token(token) click to toggle source
# File lib/Labelito/github_client.rb, line 11
def self.with_token(token)
  GithubClient.new Octokit::Client.new(:access_token => token)
end

Public Instance Methods

labels(repository) click to toggle source
# File lib/Labelito/github_client.rb, line 15
def labels(repository)
  puts "=> Fetching labels"
  @client.labels(repository).map do |label|
    Label.from_github_label(label)
  end
end
update(labels, repository) click to toggle source
# File lib/Labelito/github_client.rb, line 22
def update(labels, repository)
  old_labels = @client.labels(repository)
  puts "=> Deleting existing labels"
  old_labels.each { |label|
    puts "==> Deleting label #{label[:name]}"
    @client.delete_label!(repository, label[:name])
  }
  labels.each do |label|
    puts "==> Creating label #{label.name}"
    @client.add_label(repository, label.name, label.color)
  end
end