Module: Wassup::Helpers::GitHub
- Defined in:
- lib/wassup/helpers/github.rb,
lib/wassup/helpers/github.rb
Defined Under Namespace
Modules: Formatter
Classes: Repo
Class Method Summary
collapse
Class Method Details
.issues(org:, repo: nil, q: nil) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/wassup/helpers/github.rb', line 8
def self.issues(org:, repo:nil, q: nil)
q_parts = []
if repo.nil?
q_parts << "org:#{org}"
else
q_parts << "repo:#{org}/#{repo}"
end
if q
q_parts << q
end
q = q_parts.join(' ')
items = []
resp = RestClient::Request.execute(
method: :get,
url: "https://api.github.com/search/issues?q=#{q}",
user: ENV["WASSUP_GITHUB_USERNAME"],
password: ENV["WASSUP_GITHUB_ACCESS_TOKEN"],
headers: { "Accept": "application/vnd.github.v3+json", "Content-Type": "application/json" },
)
partial_items = JSON.parse(resp)["items"]
items += partial_items
return items
end
|
.pull_requests(org:, repo: nil) ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/wassup/helpers/github.rb', line 49
def self.pull_requests(org:, repo: nil)
repos = []
if repo.nil?
repos += self.repos(org: org).map do |repo|
Repo.new(org, repo["name"])
end
else
repos << Repo.new(org, repo)
end
return repos.map do |repo|
resp = RestClient::Request.execute(
method: :get,
url: "https://api.github.com/repos/#{repo.org}/#{repo.repo}/pulls?per_page=100",
user: ENV["WASSUP_GITHUB_USERNAME"],
password: ENV["WASSUP_GITHUB_ACCESS_TOKEN"]
)
JSON.parse(resp)
end.flatten(1)
end
|
.releases(org:, repo:) ⇒ Object
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/wassup/helpers/github.rb', line 71
def self.releases(org:, repo:)
resp = RestClient::Request.execute(
method: :get,
url: "https://api.github.com/repos/#{org}/#{repo}/releases",
user: ENV["WASSUP_GITHUB_USERNAME"],
password: ENV["WASSUP_GITHUB_ACCESS_TOKEN"]
)
return JSON.parse(resp)
end
|
.repos(org:) ⇒ Object
38
39
40
41
42
43
44
45
46
|
# File 'lib/wassup/helpers/github.rb', line 38
def self.repos(org:)
resp = RestClient::Request.execute(
method: :get,
url: "https://api.github.com/orgs/#{org}/repos",
user: ENV["WASSUP_GITHUB_USERNAME"],
password: ENV["WASSUP_GITHUB_ACCESS_TOKEN"]
)
return JSON.parse(resp)
end
|