class GetGithubPubKeys::Client

Public Class Methods

new(user = nil) click to toggle source
# File lib/get_github_pub_keys/client.rb, line 8
def initialize(user = nil)
  @user = user
end

Public Instance Methods

find_and_create(options = {}) click to toggle source
# File lib/get_github_pub_keys/client.rb, line 12
def find_and_create(options = {})
  response = Connection.new(options).get("users/#{@user}/keys")
  public_keys = response.body

  if public_keys.is_a? Array
    public_keys.each { |public_key| GetGithubPubKeys::File.create public_key['id'], public_key['key'] }
  else
    GetGithubPubKeys::File.create public_keys['id'], public_keys['key']
  end
end