Class: LockDiff::Github::Client
- Inherits:
-
Object
- Object
- LockDiff::Github::Client
- Defined in:
- lib/lock_diff/github/client.rb
Instance Method Summary collapse
- #add_comment(repository, number, comment) ⇒ Object
- #contents(repository, options = {}) ⇒ Object
- #exist_releases?(repository) ⇒ Boolean
- #file(repository, path:, ref:) ⇒ Object
-
#initialize(access_token) ⇒ Client
constructor
A new instance of Client.
- #newer_pull_requests(repository) ⇒ Object
- #pull_request(repository, number) ⇒ Object
- #pull_request_content_path(repository, number, file_name) ⇒ Object
- #tag_names(repository, options = {}) ⇒ Object
Constructor Details
#initialize(access_token) ⇒ Client
Returns a new instance of Client.
14 15 16 |
# File 'lib/lock_diff/github/client.rb', line 14 def initialize(access_token) @client = Octokit::Client.new(access_token: access_token) end |
Instance Method Details
#add_comment(repository, number, comment) ⇒ Object
55 56 57 |
# File 'lib/lock_diff/github/client.rb', line 55 def add_comment(repository, number, comment) @client.add_comment(repository, number, comment) end |
#contents(repository, options = {}) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/lock_diff/github/client.rb', line 43 def contents(repository, = {}) return [] unless repository @client.contents(repository, ).map do |content| Content.new(content) end end |
#exist_releases?(repository) ⇒ Boolean
38 39 40 41 |
# File 'lib/lock_diff/github/client.rb', line 38 def exist_releases?(repository) return false unless repository @client.releases(repository).empty? end |
#file(repository, path:, ref:) ⇒ Object
18 19 20 21 |
# File 'lib/lock_diff/github/client.rb', line 18 def file(repository, path:, ref:) content = @client.contents(repository, path: path, ref: ref) Base64.decode64(content.content) end |
#newer_pull_requests(repository) ⇒ Object
27 28 29 30 |
# File 'lib/lock_diff/github/client.rb', line 27 def newer_pull_requests(repository) @client.pull_requests(repository). map { |pull_request| Github::PullRequest.new(pull_request) } end |
#pull_request(repository, number) ⇒ Object
23 24 25 |
# File 'lib/lock_diff/github/client.rb', line 23 def pull_request(repository, number) Github::PullRequest.new(@client.pull_request(repository, number)) end |
#pull_request_content_path(repository, number, file_name) ⇒ Object
32 33 34 35 36 |
# File 'lib/lock_diff/github/client.rb', line 32 def pull_request_content_path(repository, number, file_name) content = @client.pull_request_files(repository, number). find { |file| file.filename.include?(file_name) } content&.filename end |
#tag_names(repository, options = {}) ⇒ Object
50 51 52 53 |
# File 'lib/lock_diff/github/client.rb', line 50 def tag_names(repository, = {}) return [] unless repository @client.(repository, ).map(&:name) end |