class Status::Github::PullRequest

Public Class Methods

new(branch) click to toggle source
# File lib/status/github/pull_request.rb, line 6
def initialize(branch)
  @branch = branch
end

Public Instance Methods

create_pull_request() click to toggle source
# File lib/status/github/pull_request.rb, line 14
def create_pull_request
  puts "No pull request found, create one? (y/n)"
  answer = gets
  answer.chomp.downcase == "y" ? new_pull_request : abort("exit")
end
get_pull_request() click to toggle source
# File lib/status/github/pull_request.rb, line 36
def get_pull_request
  Status::Request.new.get(pull_request_api)
end
new_pull_request() click to toggle source
# File lib/status/github/pull_request.rb, line 20
def new_pull_request
  response = post_pull_request
  puts response == "not found" ? response : response["url"]
end
payload() click to toggle source
# File lib/status/github/pull_request.rb, line 25
def payload
  puts "enter a description"
  body = gets

  {:title => title, :body => body, :base => "master", :head => @branch }
end
post_pull_request() click to toggle source
# File lib/status/github/pull_request.rb, line 40
def post_pull_request
  Status::Request.new.post(pull_request_api, payload)
end
pull_request_api() click to toggle source
# File lib/status/github/pull_request.rb, line 44
def pull_request_api
  "/repos/#{Status.owner}/#{Status.repo}/pulls?access_token=#{Status.token}"
end
pull_request_found?() click to toggle source
# File lib/status/github/pull_request.rb, line 10
def pull_request_found?
  !get_pull_request.select {|pull| pull["head"]["ref"] == @branch}.empty?
end
title() click to toggle source
# File lib/status/github/pull_request.rb, line 32
def title
  `git log #{@branch} -1 --pretty=format:'%s'`
end