class Abak::Flow::PullRequest
Attributes
link[R]
Public Class Methods
new(params)
click to toggle source
# File lib/abak-flow/pull_request.rb, line 6 def initialize(params) @_errors = Hash.new @head = params.fetch(:head) @base = params.fetch(:base) @title = params.fetch(:title) @body = params.fetch(:body) end
Public Instance Methods
errors()
click to toggle source
# File lib/abak-flow/pull_request.rb, line 24 def errors ErrorsPresenter.new(self, @_errors) end
publish()
click to toggle source
# File lib/abak-flow/pull_request.rb, line 28 def publish @_errors = Hash.new begin head_with_repo = [Manager.repository.origin.owner, @head] * ':' response = Manager.github.create_pull_request( Manager.repository.upstream.to_s, @base.to_s, head_with_repo, @title, @body) @link = response[:html_url] true rescue Exception => exception backtrace = exception.backtrace[0...10] * "\n" @_errors["exception"] = [{ field: "message", options: {backtrace: "#{exception.message}\n\n#{backtrace}"} }] false end end
valid?()
click to toggle source
# File lib/abak-flow/pull_request.rb, line 15 def valid? @_errors = Hash.new @_errors["head"] = ["invalid"] unless @head.valid? @_errors["base"] = ["invalid"] unless @base.valid? @_errors["title"] = ["blank"] if @title.empty? @_errors.empty? end