Module: HubHelper

Included in:
Hubstats::GithubAPI
Defined in:
lib/hub_helper.rb

Class Method Summary collapse

Class Method Details

.comment_setup(comment, repo_id, kind) ⇒ Object



14
15
16
17
18
19
# File 'lib/hub_helper.rb', line 14

def self.comment_setup(comment, repo_id, kind)
  comment[:repo_id] = repo_id
  comment[:pull_number] = get_pull_number(comment)
  comment[:kind] = kind
  return comment
end

.get_pull_number(comment) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
# File 'lib/hub_helper.rb', line 2

def self.get_pull_number(comment)
  if comment[:pull_request]
    return comment[:pull_request][:number]
  elsif comment[:issue_url]
    return comment[:issue_url].split('/')[-1]
  elsif comment[:pull_request_url]
    return comment[:pull_request_url].split('/')[-1]
  else
    return nil
  end
end

.pull_setup(pull_request) ⇒ Object



21
22
23
24
# File 'lib/hub_helper.rb', line 21

def self.pull_setup(pull_request)
  pull_request[:repository] = pull_request[:base][:repo]
  return pull_request
end