Class: Tokite::Repository
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Tokite::Repository
- Defined in:
- app/models/tokite/repository.rb
Class Method Summary collapse
- .find_hook(octokit_client, repo_name) ⇒ Object
- .hook!(octokit_client, github_repo) ⇒ Object
- .hook_config ⇒ Object
- .hook_options ⇒ Object
- .hooks_url ⇒ Object
Instance Method Summary collapse
Class Method Details
.find_hook(octokit_client, repo_name) ⇒ Object
14 15 16 |
# File 'app/models/tokite/repository.rb', line 14 def self.find_hook(octokit_client, repo_name) octokit_client.hooks(repo_name).find {|hook| hook.config.url == hooks_url } end |
.hook!(octokit_client, github_repo) ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'app/models/tokite/repository.rb', line 3 def self.hook!(octokit_client, github_repo) repo_name = github_repo.full_name existing_hook = find_hook(octokit_client, repo_name) if existing_hook octokit_client.edit_hook(repo_name, existing_hook.id, "web", hook_config, ) else octokit_client.create_hook(repo_name, "web", hook_config, ) end create!(name: repo_name, url: github_repo.html_url) end |
.hook_config ⇒ Object
18 19 20 21 22 23 |
# File 'app/models/tokite/repository.rb', line 18 def self.hook_config { content_type: "json", url: hooks_url, } end |
.hook_options ⇒ Object
25 26 27 28 29 |
# File 'app/models/tokite/repository.rb', line 25 def self. { events: ["*"] } end |
Instance Method Details
#unhook!(octokit_client) ⇒ Object
35 36 37 38 39 |
# File 'app/models/tokite/repository.rb', line 35 def unhook!(octokit_client) hook = self.class.find_hook(octokit_client, name) octokit_client.remove_hook(name, hook.id) if hook destroy! end |