Sha256: fc625197407823315aa6d1ee40484504ee70fe51c83814797f6597a52ab0c024
Contents?: true
Size: 1.18 KB
Versions: 2
Compression:
Stored size: 1.18 KB
Contents
# coding: utf-8 module Abak::Flow class PullRequest attr_reader :link def initialize(params) @_errors = Hash.new @head = params.fetch(:head) @base = params.fetch(:base) @title = params.fetch(:title) @body = params.fetch(:body) end 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 def errors ErrorsPresenter.new(self, @_errors) end 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 end # class PullRequest end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
abak-flow-1.1.1 | lib/abak-flow/pull_request.rb |
abak-flow-1.1.0 | lib/abak-flow/pull_request.rb |