Class: ReposHooks

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(github) ⇒ ReposHooks

Returns a new instance of ReposHooks.



4
5
6
# File 'lib/github/repos/repos_hooks.rb', line 4

def initialize(github)
  @github = github
end

Instance Attribute Details

#githubObject

Returns the value of attribute github.



2
3
4
# File 'lib/github/repos/repos_hooks.rb', line 2

def github
  @github
end

Instance Method Details

#createHook(repo, name, config, events = nil, active = TRUE, user = nil) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/github/repos/repos_hooks.rb', line 18

def createHook(repo, name, config, events=nil, active=TRUE,
    user=nil)
  username = user == nil ? @github.username : user
  params = {
      :name => name,
      :config => config,
      :events => events,
      :active => active
  }
  params = @github.removeEmptyParams(params)
  data = params.to_json
  @github.post('repos/%s/%s/hooks' % [username, repo], data)
end

#deleteHook(repo, id, user = nil) ⇒ Object



53
54
55
56
# File 'lib/github/repos/repos_hooks.rb', line 53

def deleteHook(repo, id, user=nil)
  username = user == nil ? @github.username : user
  @github.delete('repos/%s/%s/hooks/%s' % [username, repo, id])
end

#editHook(repo, id, name, config, events = nil, add_events = nil, remove_events = nil, active = TRUE, user = nil) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/github/repos/repos_hooks.rb', line 32

def editHook(repo, id, name, config, events=nil, add_events=nil,
    remove_events=nil, active=TRUE, user=nil)
  username = user == nil ? @github.username : user
  params = {
      :name => name,
      :config => config,
      :events => events,
      :add_events => add_events,
      :remove_events => remove_events,
      :active => active
  }
  params = @github.removeEmptyParams(params)
  data = params.to_json
  @github.patch('repos/%s/%s/hooks/%s' % [username, repo, id], data)
end

#getHook(repo, id, user = nil) ⇒ Object



13
14
15
16
# File 'lib/github/repos/repos_hooks.rb', line 13

def getHook(repo, id, user=nil)
  username = user == nil ? @github.username : user
  @github.get('repos/%s/%s/hooks/%s' % [username, repo, id])
end

#listHooks(repo, user = nil) ⇒ Object



8
9
10
11
# File 'lib/github/repos/repos_hooks.rb', line 8

def listHooks(repo, user=nil)
  username = user == nil ? @github.username : user
  @github.get('repos/%s/%s/hooks' % [username, repo])
end

#testHook(repo, id, user = nil) ⇒ Object



48
49
50
51
# File 'lib/github/repos/repos_hooks.rb', line 48

def testHook(repo, id, user=nil)
  username = user == nil ? @github.username : user
  @github.post('repos/%s/%s/hooks/%s/test' % [username, repo, id])
end