Module: Github::Hooker
- Defined in:
- lib/github-hooker.rb,
lib/github-hooker/cli.rb,
lib/github-hooker/config.rb,
lib/github-hooker/version.rb
Defined Under Namespace
Modules: Config
Classes: CLI
Constant Summary
collapse
- VERSION =
"0.1.2"
Class Method Summary
collapse
Class Method Details
.add_hook(repo, payload = {}) ⇒ Object
15
16
17
18
19
|
# File 'lib/github-hooker.rb', line 15
def self.add_hook(repo, payload={})
path = "/repos/#{repo}/hooks"
payload = payload.reverse_merge(:active => true)
github_api(:post, path, :payload => payload.to_json)
end
|
.delete_hook(repo, hook) ⇒ Object
21
22
23
24
|
# File 'lib/github-hooker.rb', line 21
def self.delete_hook(repo, hook)
path = "/repos/#{repo}/hooks/#{hook}"
github_api(:delete, path)
end
|
.github_api(method, path, options = {}) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/github-hooker.rb', line 26
def self.github_api(method, path, options={})
github_url = Github::Hooker::Config.config.fetch("api_url", "https://api.github.com")
url = github_url + path
options.reverse_merge!(
:method => method,
:url => url,
:user => Github::Hooker::Config.config["user"],
:password => Github::Hooker::Config.config["password"]
)
response = RestClient::Request.execute(options)
case response.code
when 201, 200
JSON.parse(response)
when 204, 404, 500
response
end
end
|
.hooks(repo) ⇒ Object
10
11
12
13
|
# File 'lib/github-hooker.rb', line 10
def self.hooks(repo)
path = "/repos/#{repo}/hooks"
github_api(:get, path)
end
|