-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.rb
46 lines (38 loc) · 1.43 KB
/
init.rb
1
2
3
4
5
6
7
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
37
38
39
40
41
42
43
44
45
46
# frozen_string_literal: true
require 'redmine'
require_relative 'lib/issue_details_hook_listener'
def check_env
ENV['GITHUB_WEBHOOK_SECRET'].present? ||
ENV['GITHUB_ACCESS_TOKEN'].present? ||
ENV['SEMAPHORE_WEBHOOK_SECRET'].present? ||
ENV['GITHUB_ORGANIZATION_NAME'].present?
end
# :nocov:
if !check_env && !Rails.env.test?
yaml_data = if Rails.root.join('plugins/gnosis/config/application.yml').exist?
YAML.safe_load(ERB.new(Rails.root.join('plugins/gnosis/config/application.yml').read).result)
else
Rails.logger.warn 'application.yml not found'
YAML.safe_load(ERB.new(Rails.root.join('plugins/gnosis/config/application.example.yml').read).result)
end
ENV.merge!(ActiveSupport::HashWithIndifferentAccess.new(yaml_data))
end
# :nocov:
raise 'GITHUB_ACCESS_TOKEN is not set' if ENV['GITHUB_ACCESS_TOKEN'].blank? && !Rails.env.test?
Redmine::Plugin.register :gnosis do
name 'Gnosis plugin'
author 'Anes Hodza'
description 'This Plugin allows you to see the status of issues in a project'
version '1.0.0'
url 'https://github.com/aneshodza/gnosis/'
author_url 'https://www.aneshodza.ch/'
settings default: { }, partial: 'settings/gnosis_settings'
project_module :gnosis do
permission :view_list, {}
end
project_module :gnosis do
permission :sync_pull_requests, {
sync: %i[sync_pull_requests]
}, require: :loggedin
end
end