1
我基本上試圖用octokit github api ruby工具包獲取我的存儲庫名稱。我看了看文檔和他們的代碼文件中:使用用於github api的octokit ruby工具包獲取存儲庫名稱
# Get a single repository
#
# @see https://developer.github.com/v3/repos/#get
# @see https://developer.github.com/v3/licenses/#get-a-repositorys-license
# @param repo [Integer, String, Hash, Repository] A GitHub repository
# @return [Sawyer::Resource] Repository information
def repository(repo, options = {})
get Repository.path(repo), options
end
alias :repo :repository
# Edit a repository
#
# @see https://developer.github.com/v3/repos/#edit
# @param repo [String, Hash, Repository] A GitHub repository
# @param options [Hash] Repository information to update
# @option options [String] :name Name of the repo
# @option options [String] :description Description of the repo
# @option options [String] :homepage Home page of the repo
# @option options [String] :private `true` makes the repository private, and `false` makes it public.
# @option options [String] :has_issues `true` enables issues for this repo, `false` disables issues.
# @option options [String] :has_wiki `true` enables wiki for this repo, `false` disables wiki.
# @option options [String] :has_downloads `true` enables downloads for this repo, `false` disables downloads.
# @option options [String] :default_branch Update the default branch for this repository.
# @return [Sawyer::Resource] Repository information
據我所知,options參數是一個哈希,但對如何指定參數以獲得資源庫的名字我'還是有點困惑。這裏是我的代碼:
require 'octokit'
require 'netrc'
class Base
# attr_accessor :un, :pw
# un = username
# pw = password
def initialize
@client = Octokit::Client.new(:access_token =>
'<access_token>')
print "Username you want to search?\t"
@username = gets.chomp.to_s
@user = @client.user(@username)
puts "#{@username} email is:\t\t#{@user.email}"
puts @user.repository('converse', :options => name)
end
end
start = Base.new
我acess_token我'能得到我自己或別人github上的姓名,電子郵件,組織等,但是當我使用的方法......他們總是有選擇的參數和我我很難爲此指定正確的論點。
非常感謝建議。這幫了很多。 :) –