Module: Brainiac::Plugins::Zoho::Config
- Defined in:
- lib/brainiac/plugins/zoho/config.rb
Constant Summary collapse
- CONFIG_FILE =
File.join(ENV.fetch("BRAINIAC_DIR", File.join(Dir.home, ".brainiac")), "zoho.json")
Class Attribute Summary collapse
-
.config ⇒ Object
readonly
Returns the value of attribute config.
Class Method Summary collapse
- .api_configured? ⇒ Boolean
- .api_section ⇒ Object
- .default_notify_target ⇒ Object
- .fallback ⇒ Object
- .hook_secret ⇒ Object
- .load! ⇒ Object
- .notify_as ⇒ Object
- .notify_channel ⇒ Object
- .reload! ⇒ Object
- .rules ⇒ Object
- .save_config! ⇒ Object
- .save_hook_secret(secret) ⇒ Object
- .triage_agent_assignment ⇒ Object
- .triage_board_id ⇒ Object
- .triage_project_tags ⇒ Object
Class Attribute Details
.config ⇒ Object (readonly)
Returns the value of attribute config.
13 14 15 |
# File 'lib/brainiac/plugins/zoho/config.rb', line 13 def config @config end |
Class Method Details
.api_configured? ⇒ Boolean
80 81 82 83 |
# File 'lib/brainiac/plugins/zoho/config.rb', line 80 def api_configured? api = api_section api["client_id"] && api["client_secret"] && api["refresh_token"] && api["account_id"] end |
.api_section ⇒ Object
76 77 78 |
# File 'lib/brainiac/plugins/zoho/config.rb', line 76 def api_section @config["api"] || {} end |
.default_notify_target ⇒ Object
38 39 40 |
# File 'lib/brainiac/plugins/zoho/config.rb', line 38 def default_notify_target @config["default_notify_target"] end |
.fallback ⇒ Object
54 55 56 |
# File 'lib/brainiac/plugins/zoho/config.rb', line 54 def fallback @config["fallback"] end |
.hook_secret ⇒ Object
28 29 30 |
# File 'lib/brainiac/plugins/zoho/config.rb', line 28 def hook_secret @config["hook_secret"] end |
.load! ⇒ Object
15 16 17 18 |
# File 'lib/brainiac/plugins/zoho/config.rb', line 15 def load! @config = load_config @last_mtime = File.exist?(CONFIG_FILE) ? File.mtime(CONFIG_FILE) : nil end |
.notify_as ⇒ Object
46 47 48 |
# File 'lib/brainiac/plugins/zoho/config.rb', line 46 def notify_as @config["notify_as"] end |
.notify_channel ⇒ Object
42 43 44 |
# File 'lib/brainiac/plugins/zoho/config.rb', line 42 def notify_channel @config["notify_channel"] || "discord" end |
.reload! ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/brainiac/plugins/zoho/config.rb', line 20 def reload! return unless file_changed? @config = load_config @last_mtime = File.exist?(CONFIG_FILE) ? File.mtime(CONFIG_FILE) : nil LOG.info "[Zoho] Reloaded configuration" end |
.rules ⇒ Object
50 51 52 |
# File 'lib/brainiac/plugins/zoho/config.rb', line 50 def rules @config["rules"] || [] end |
.save_config! ⇒ Object
85 86 87 |
# File 'lib/brainiac/plugins/zoho/config.rb', line 85 def save_config! File.write(CONFIG_FILE, JSON.pretty_generate(@config)) end |
.save_hook_secret(secret) ⇒ Object
32 33 34 35 36 |
# File 'lib/brainiac/plugins/zoho/config.rb', line 32 def save_hook_secret(secret) @config["hook_secret"] = secret File.write(CONFIG_FILE, JSON.pretty_generate(@config)) LOG.info "[Zoho] Saved hook_secret to #{CONFIG_FILE}" end |
.triage_agent_assignment ⇒ Object
69 70 71 72 73 74 |
# File 'lib/brainiac/plugins/zoho/config.rb', line 69 def triage_agent_assignment rules = @config["triage_agent_assignment"] return "Assign to the default agent." unless rules&.any? rules.map { |r| " - #{r}" }.join("\n") end |
.triage_board_id ⇒ Object
58 59 60 |
# File 'lib/brainiac/plugins/zoho/config.rb', line 58 def triage_board_id @config["triage_board_id"] end |
.triage_project_tags ⇒ Object
62 63 64 65 66 67 |
# File 'lib/brainiac/plugins/zoho/config.rb', line 62 def = @config["triage_project_tags"] return "Use your best judgement to identify the relevant project." unless &.any? .map { |t| " - `#{t["tag"]}` — #{t["description"]}" }.join("\n") end |