Sha256: 7c876a569d91dc0d17c343c601d0bdb6cf4e08e5eea6bddef8d48f26fe661f43

Contents?: true

Size: 749 Bytes

Versions: 3

Compression:

Stored size: 749 Bytes

Contents

# coding: utf-8

module GetGithubPubKeys

  class Client
    include Connection
    include GetGithubPubKeys::Files

    def initialize(user=nil) 
      @user = user
    end

    def find_and_create( options = {} )
      response = Connection.new(options).get("users/#{@user}/keys")   
      public_keys = response.body

      # FIXME:response.raise_errorが正しく動作するのかを確認する
      # 登録されていないUserだとfile_nameがとれない
      if public_keys.is_a? Array
        public_keys.each do |public_key| 
          GetGithubPubKeys::Files.create public_key["id"], public_key["key"]
        end
      else
        GetGithubPubKeys::Files.create public_keys["id"], public_keys["key"]
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
get_github_pub_keys-0.0.6 lib/get_github_pub_keys/client.rb
get_github_pub_keys-0.0.5 lib/get_github_pub_keys/client.rb
get_github_pub_keys-0.0.4 lib/get_github_pub_keys/client.rb