我有这个代码:
require 'octokit'
require 'csv'
client = Octokit::Client.new :login => 'github_username', :password => 'github_password'
repo = 'rubinius/rubinius'
numbers = CSV.read('/Users/Name/Downloads/numbers.csv').flatten
# at this point, essentially numbers = [642, 630, 623, 643, 626]
CSV.open('results.csv', 'w') do |csv|
for number in numbers
begin
pull = client.pull_request(repo, number)
csv << [pull.number, pull.additions, pull.deletions]
rescue
next
end
end
end
但是,有时 client.pull_request 遇到 404 然后跳过并转到下一个。但是,它仍然需要打印数组中的数字,然后为andnumbers
输入一个空白或零,然后移动到数组中的下一项,从而产生如下内容:pull.additions
pull.deletions
pull.number pull.additions pull.deletions
642, 12, 3
630, ,
623, 15, 23
...
如何才能做到这一点?