Class: Vx::ServiceConnector::Github::Hooks
- Inherits:
-
Struct
- Object
- Struct
- Vx::ServiceConnector::Github::Hooks
- Defined in:
- lib/vx/service_connector/github/hooks.rb
Instance Attribute Summary collapse
-
#repo ⇒ Object
Returns the value of attribute repo.
-
#session ⇒ Object
Returns the value of attribute session.
Instance Method Summary collapse
Instance Attribute Details
#repo ⇒ Object
Returns the value of attribute repo
4 5 6 |
# File 'lib/vx/service_connector/github/hooks.rb', line 4 def repo @repo end |
#session ⇒ Object
Returns the value of attribute session
4 5 6 |
# File 'lib/vx/service_connector/github/hooks.rb', line 4 def session @session end |
Instance Method Details
#all ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/vx/service_connector/github/hooks.rb', line 6 def all begin session.hooks(repo.full_name) rescue Octokit::NotFound [] end end |
#create(url, token) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/vx/service_connector/github/hooks.rb', line 14 def create(url, token) config = { url: url, secret: token, content_type: "json" } = { events: %w{ push pull_request } } begin session.create_hook(repo.full_name, "web", config, ) true rescue ::Octokit::NotFound nil end end |
#destroy(url_mask) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/vx/service_connector/github/hooks.rb', line 29 def destroy(url_mask) all.select do |hook| if url = hook.config.rels[:self] url.href =~ /#{Regexp.escape url_mask}/ end end.map do |hook| session.remove_hook(repo.full_name, hook.id) end end |