class Preparer
Constants
- AUTH_FILE
Public Instance Methods
run()
click to toggle source
# File lib/committer-tools.rb, line 146 def run HTTPHelper.token = get_auth() pr = get_pr() get_github_pr(pr) end
Private Instance Methods
get_auth()
click to toggle source
# File lib/committer-tools.rb, line 154 def get_auth begin auth = File.read("#{ENV['HOME']}/#{AUTH_FILE}") JSON.parse(auth)['token'] rescue raise "Unable to load authentication information" end end
get_github_pr(pr)
click to toggle source
# File lib/committer-tools.rb, line 163 def get_github_pr(pr) HTTPHelper.get_json( "https://api.github.com/repos/#{pr[:org]}/#{pr[:repo]}/pulls/#{pr[:id]}" ) end
get_pr()
click to toggle source
# File lib/committer-tools.rb, line 169 def get_pr if ENV['BOT'] && ENV['BOT'] == 'bot' pr_id = ENV['COMMITTER_TOOLS_PR_ID'] else puts "Please enter PR ID:" pr_id = gets.strip! end begin org, repo_and_id = pr_id.split('/') repo, id = repo_and_id.split('#') { org: org, repo: repo, id: id } rescue raise "Invalid PR ID: #{pr_id}" end end