Class: Cp8Cli::Github::PullRequest
- Inherits:
-
Object
- Object
- Cp8Cli::Github::PullRequest
- Includes:
- Api::Client
- Defined in:
- lib/cp8_cli/github/pull_request.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(from: nil, to: "master", title: nil, body: nil, expand: 1, html_url: nil, **attributes) ⇒ PullRequest
constructor
A new instance of PullRequest.
- #open ⇒ Object
- #save ⇒ Object
Methods included from Api::Client
Constructor Details
#initialize(from: nil, to: "master", title: nil, body: nil, expand: 1, html_url: nil, **attributes) ⇒ PullRequest
Returns a new instance of PullRequest.
19 20 21 22 23 24 25 26 |
# File 'lib/cp8_cli/github/pull_request.rb', line 19 def initialize(from: nil, to: "master", title: nil, body: nil, expand: 1, html_url: nil, **attributes) @from = from @to = to @title = title @body = body @expand = @html_url = html_url end |
Class Method Details
.create(attributes = {}) ⇒ Object
9 10 11 |
# File 'lib/cp8_cli/github/pull_request.rb', line 9 def self.create(attributes = {}) new(attributes).save end |
.find_by(repo:, branch:) ⇒ Object
13 14 15 16 17 |
# File 'lib/cp8_cli/github/pull_request.rb', line 13 def self.find_by(repo:, branch:) client.pull_requests(repo.shorthand, head: "#{repo.user}:#{branch}").map do |data| new(data) end.first end |
Instance Method Details
#open ⇒ Object
28 29 30 |
# File 'lib/cp8_cli/github/pull_request.rb', line 28 def open Command.open_url(url) end |
#save ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/cp8_cli/github/pull_request.rb', line 32 def save client.create_pull_request( repo.shorthand, to, from, title, body, draft: true, accept: "application/vnd.github.shadow-cat-preview" # waiting for https://github.com/octokit/octokit.rb/pull/1114 ) end |