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上的姓名,电子邮件,组织等,但是当我使用的方法......他们总是有选择的参数和我我很难为此指定正确的论点。
非常感谢建议。这帮了很多。 :) –