Class: Async::Matrix::ApplicationService::Config
- Inherits:
-
Object
- Object
- Async::Matrix::ApplicationService::Config
- Defined in:
- lib/async/matrix/application_service/config.rb
Overview
Loads and validates an Application Service YAML configuration file.
Expected YAML structure:
homeserver:
url: "http://synapse:8008"
domain: "localhost"
appservice:
as_token: "..."
hs_token: "..."
bot_mxid: "@bot:localhost"
server:
bind: "http://0.0.0.0:9292" # optional
Instance Attribute Summary collapse
-
#as_token ⇒ Object
readonly
Returns the value of attribute as_token.
-
#bind ⇒ Object
readonly
Returns the value of attribute bind.
-
#bot_mxid ⇒ Object
readonly
Returns the value of attribute bot_mxid.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#homeserver_url ⇒ Object
readonly
Returns the value of attribute homeserver_url.
-
#hs_token ⇒ Object
readonly
Returns the value of attribute hs_token.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(data) ⇒ Config
Returns a new instance of Config.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/async/matrix/application_service/config.rb', line 30 def initialize(data) hs = data.fetch("homeserver") as = data.fetch("appservice") sv = data.fetch("server", {}) @homeserver_url = hs.fetch("url").chomp("/") @domain = hs.fetch("domain") @as_token = as.fetch("as_token") @hs_token = as.fetch("hs_token") @bot_mxid = as.fetch("bot_mxid") @bind = sv.fetch("bind", "http://0.0.0.0:9292") validate! end |
Instance Attribute Details
#as_token ⇒ Object (readonly)
Returns the value of attribute as_token.
28 29 30 |
# File 'lib/async/matrix/application_service/config.rb', line 28 def as_token @as_token end |
#bind ⇒ Object (readonly)
Returns the value of attribute bind.
28 29 30 |
# File 'lib/async/matrix/application_service/config.rb', line 28 def bind @bind end |
#bot_mxid ⇒ Object (readonly)
Returns the value of attribute bot_mxid.
28 29 30 |
# File 'lib/async/matrix/application_service/config.rb', line 28 def bot_mxid @bot_mxid end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
28 29 30 |
# File 'lib/async/matrix/application_service/config.rb', line 28 def domain @domain end |
#homeserver_url ⇒ Object (readonly)
Returns the value of attribute homeserver_url.
28 29 30 |
# File 'lib/async/matrix/application_service/config.rb', line 28 def homeserver_url @homeserver_url end |
#hs_token ⇒ Object (readonly)
Returns the value of attribute hs_token.
28 29 30 |
# File 'lib/async/matrix/application_service/config.rb', line 28 def hs_token @hs_token end |
Class Method Details
.load(path) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/async/matrix/application_service/config.rb', line 45 def self.load(path) raise Async::Matrix::NotFoundError.new("M_NOT_FOUND", "Config not found: #{path}") unless File.exist?(path) data = YAML.safe_load_file(path, permitted_classes: [Symbol]) new(data) end |