Class: Ninny::Repository::Gitlab
- Inherits:
-
Object
- Object
- Ninny::Repository::Gitlab
- Defined in:
- lib/ninny/repository/gitlab.rb
Instance Attribute Summary collapse
-
#gitlab ⇒ Object
readonly
Returns the value of attribute gitlab.
-
#project_id ⇒ Object
readonly
Returns the value of attribute project_id.
Instance Method Summary collapse
- #create_merge_request_note(id, body) ⇒ Object
- #current_pull_request ⇒ Object
-
#initialize ⇒ Gitlab
constructor
A new instance of Gitlab.
- #open_pull_requests ⇒ Object
- #pull_request(id) ⇒ Object
- #pull_request_label ⇒ Object
Constructor Details
#initialize ⇒ Gitlab
Returns a new instance of Gitlab.
8 9 10 11 12 13 14 |
# File 'lib/ninny/repository/gitlab.rb', line 8 def initialize @gitlab = ::Gitlab.client( endpoint: Ninny.project_config.gitlab_endpoint, private_token: Ninny.user_config.gitlab_private_token ) @project_id = Ninny.project_config.gitlab_project_id end |
Instance Attribute Details
#gitlab ⇒ Object (readonly)
Returns the value of attribute gitlab.
6 7 8 |
# File 'lib/ninny/repository/gitlab.rb', line 6 def gitlab @gitlab end |
#project_id ⇒ Object (readonly)
Returns the value of attribute project_id.
6 7 8 |
# File 'lib/ninny/repository/gitlab.rb', line 6 def project_id @project_id end |
Instance Method Details
#create_merge_request_note(id, body) ⇒ Object
41 42 43 |
# File 'lib/ninny/repository/gitlab.rb', line 41 def create_merge_request_note(id, body) gitlab.create_merge_request_note(project_id, id, body) end |
#current_pull_request ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ninny/repository/gitlab.rb', line 16 def current_pull_request to_pr( gitlab.merge_requests( project_id, { source_branch: Ninny.git.current_branch.name, target_branch: Ninny.project_config.deploy_branch, state: 'opened' } ).auto_paginate.last ) end |
#open_pull_requests ⇒ Object
33 34 35 |
# File 'lib/ninny/repository/gitlab.rb', line 33 def open_pull_requests gitlab.merge_requests(project_id, { state: 'opened' }).auto_paginate.map { |mr| to_pr(mr) } end |
#pull_request(id) ⇒ Object
37 38 39 |
# File 'lib/ninny/repository/gitlab.rb', line 37 def pull_request(id) to_pr(gitlab.merge_request(project_id, id)) end |
#pull_request_label ⇒ Object
29 30 31 |
# File 'lib/ninny/repository/gitlab.rb', line 29 def pull_request_label 'Merge Request' end |