Class: Tempest::Config
- Inherits:
-
Object
- Object
- Tempest::Config
- Defined in:
- lib/tempest/config.rb
Defined Under Namespace
Classes: MissingValue
Constant Summary collapse
- DEFAULT_PDS_HOST =
"https://bsky.social".freeze
Instance Attribute Summary collapse
-
#app_password ⇒ Object
readonly
Returns the value of attribute app_password.
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
#pds_host ⇒ Object
readonly
Returns the value of attribute pds_host.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(identifier:, app_password:, pds_host: DEFAULT_PDS_HOST) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(identifier:, app_password:, pds_host: DEFAULT_PDS_HOST) ⇒ Config
Returns a new instance of Config.
24 25 26 27 28 |
# File 'lib/tempest/config.rb', line 24 def initialize(identifier:, app_password:, pds_host: DEFAULT_PDS_HOST) @identifier = identifier @app_password = app_password @pds_host = pds_host end |
Instance Attribute Details
#app_password ⇒ Object (readonly)
Returns the value of attribute app_password.
9 10 11 |
# File 'lib/tempest/config.rb', line 9 def app_password @app_password end |
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
9 10 11 |
# File 'lib/tempest/config.rb', line 9 def identifier @identifier end |
#pds_host ⇒ Object (readonly)
Returns the value of attribute pds_host.
9 10 11 |
# File 'lib/tempest/config.rb', line 9 def pds_host @pds_host end |
Class Method Details
.from_env(env = ENV) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/tempest/config.rb', line 11 def self.from_env(env = ENV) identifier = env["TEMPEST_IDENTIFIER"] raise MissingValue, "TEMPEST_IDENTIFIER is not set" if identifier.nil? || identifier.empty? app_password = env["TEMPEST_APP_PASSWORD"] raise MissingValue, "TEMPEST_APP_PASSWORD is not set" if app_password.nil? || app_password.empty? pds_host = env["TEMPEST_PDS_HOST"] pds_host = DEFAULT_PDS_HOST if pds_host.nil? || pds_host.empty? new(identifier: identifier, app_password: app_password, pds_host: pds_host) end |