Class: Abak::Flow::PullRequest
- Inherits:
-
Object
- Object
- Abak::Flow::PullRequest
- Defined in:
- lib/abak-flow/pull_request.rb
Instance Attribute Summary collapse
-
#link ⇒ Object
readonly
Returns the value of attribute link.
Instance Method Summary collapse
- #errors ⇒ Object
-
#initialize(params) ⇒ PullRequest
constructor
A new instance of PullRequest.
- #publish ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(params) ⇒ PullRequest
Returns a new instance of PullRequest.
6 7 8 9 10 11 12 13 |
# 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 |
Instance Attribute Details
#link ⇒ Object (readonly)
Returns the value of attribute link.
4 5 6 |
# File 'lib/abak-flow/pull_request.rb', line 4 def link @link end |
Instance Method Details
#errors ⇒ Object
24 25 26 |
# File 'lib/abak-flow/pull_request.rb', line 24 def errors ErrorsPresenter.new(self, @_errors) end |
#publish ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# 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.}\n\n#{backtrace}"} }] false end end |
#valid? ⇒ Boolean
15 16 17 18 19 20 21 22 |
# 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 |