Module: Brainiac::Plugins::Github::Config
- Defined in:
- lib/brainiac/plugins/github/config.rb
Constant Summary collapse
- CONFIG_FILE =
File.join(ENV.fetch("BRAINIAC_DIR", File.join(Dir.home, ".brainiac")), "github.json")
Class Attribute Summary collapse
-
.config ⇒ Object
readonly
Returns the value of attribute config.
Class Method Summary collapse
-
.app_id ⇒ Object
GitHub App credentials — all three must be present for App auth to work.
- .installation_id ⇒ Object
- .load! ⇒ Object
- .private_key_path ⇒ Object
- .reload! ⇒ Object
- .webhook_secret ⇒ Object
Class Attribute Details
.config ⇒ Object (readonly)
Returns the value of attribute config.
13 14 15 |
# File 'lib/brainiac/plugins/github/config.rb', line 13 def config @config end |
Class Method Details
.app_id ⇒ Object
GitHub App credentials — all three must be present for App auth to work.
35 36 37 |
# File 'lib/brainiac/plugins/github/config.rb', line 35 def app_id @config.dig("app", "id")&.to_s || ENV.fetch("GITHUB_APP_ID", nil) end |
.installation_id ⇒ Object
47 48 49 |
# File 'lib/brainiac/plugins/github/config.rb', line 47 def installation_id @config.dig("app", "installation_id")&.to_s || ENV.fetch("GITHUB_APP_INSTALLATION_ID", nil) end |
.load! ⇒ Object
15 16 17 18 |
# File 'lib/brainiac/plugins/github/config.rb', line 15 def load! @config = load_config @last_mtime = File.exist?(CONFIG_FILE) ? File.mtime(CONFIG_FILE) : nil end |
.private_key_path ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/brainiac/plugins/github/config.rb', line 39 def private_key_path path = @config.dig("app", "private_key_path") || ENV.fetch("GITHUB_APP_PRIVATE_KEY_PATH", nil) return nil unless path = File.(path) File.exist?() ? : nil end |
.reload! ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/brainiac/plugins/github/config.rb', line 20 def reload! return unless file_changed? @config = load_config @last_mtime = File.exist?(CONFIG_FILE) ? File.mtime(CONFIG_FILE) : nil AppClient.reset! if defined?(AppClient) LOG.info "[GitHub] Reloaded configuration" end |
.webhook_secret ⇒ Object
29 30 31 |
# File 'lib/brainiac/plugins/github/config.rb', line 29 def webhook_secret @config["webhook_secret"] || ENV.fetch("GITHUB_WEBHOOK_SECRET", nil) end |