Class: Pronto::Github

Inherits:
Object
  • Object
show all
Defined in:
lib/pronto/github.rb

Defined Under Namespace

Classes: Comment

Instance Method Summary collapse

Constructor Details

#initialize(repo) ⇒ Github

Returns a new instance of Github.



3
4
5
6
7
# File 'lib/pronto/github.rb', line 3

def initialize(repo)
  @repo = repo
  @comment_cache = {}
  @pull_id_cache = {}
end

Instance Method Details

#commit_comments(sha) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/pronto/github.rb', line 17

def commit_comments(sha)
  @comment_cache["#{sha}"] ||= begin
    client.commit_comments(slug, sha).map do |comment|
      Comment.new(sha, comment.body, comment.path, comment.position)
    end
  end
end

#create_commit_comment(comment) ⇒ Object



25
26
27
28
# File 'lib/pronto/github.rb', line 25

def create_commit_comment(comment)
  client.create_commit_comment(slug, comment.sha, comment.body,
                               comment.path, nil, comment.position)
end

#create_pull_comment(comment) ⇒ Object



30
31
32
33
# File 'lib/pronto/github.rb', line 30

def create_pull_comment(comment)
  client.create_pull_comment(slug, pull_id, comment.body,
                             comment.sha, comment.path, comment.position)
end

#pull_comments(sha) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/pronto/github.rb', line 9

def pull_comments(sha)
  @comment_cache["#{pull_id}/#{sha}"] ||= begin
    client.pull_comments(slug, pull_id).map do |comment|
      Comment.new(sha, comment.body, comment.path, comment.position)
    end
  end
end