Class: LastResort::Config
- Inherits:
-
Object
- Object
- LastResort::Config
- Defined in:
- lib/last-resort/config.rb
Overview
The configuration class is used to build up contact and scheduling information for Last Resort.
Instances of this class power the schedule.rb’s DSL. By default it will attempt to load in and evaluate a schedule.rb file upon construction, but it can also be manually configured.
Constant Summary collapse
- DOT_ENV_PATH =
".env"
- CONFIG_PATH =
"schedule.rb"
Instance Attribute Summary collapse
-
#contacts ⇒ Object
The host provided to services for webhooks.
-
#contextio_account ⇒ Object
The host provided to services for webhooks.
-
#contextio_key ⇒ Object
The host provided to services for webhooks.
-
#contextio_secret ⇒ Object
The host provided to services for webhooks.
-
#host ⇒ Object
The host provided to services for webhooks.
-
#local_utc_offset_in_seconds ⇒ Object
The host provided to services for webhooks.
-
#matchers ⇒ Object
The host provided to services for webhooks.
-
#schedules ⇒ Object
The host provided to services for webhooks.
-
#twilio_auth_token ⇒ Object
The host provided to services for webhooks.
-
#twilio_sid ⇒ Object
The host provided to services for webhooks.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(skip_schedule_load = false) ⇒ Config
constructor
If skip_schedule_load is true, the config instance will not attempt to load schedule.rb.
Constructor Details
#initialize(skip_schedule_load = false) ⇒ Config
If skip_schedule_load is true, the config instance will not attempt to load schedule.rb. Useful for unit testing or programmatic configuration.
23 24 25 26 27 28 |
# File 'lib/last-resort/config.rb', line 23 def initialize skip_schedule_load = false @contacts = {} @matchers = [] @schedules = [] run_config_in_context unless skip_schedule_load end |
Instance Attribute Details
#contacts ⇒ Object
The host provided to services for webhooks
13 14 15 |
# File 'lib/last-resort/config.rb', line 13 def contacts @contacts end |
#contextio_account ⇒ Object
The host provided to services for webhooks
13 14 15 |
# File 'lib/last-resort/config.rb', line 13 def contextio_account @contextio_account end |
#contextio_key ⇒ Object
The host provided to services for webhooks
13 14 15 |
# File 'lib/last-resort/config.rb', line 13 def contextio_key @contextio_key end |
#contextio_secret ⇒ Object
The host provided to services for webhooks
13 14 15 |
# File 'lib/last-resort/config.rb', line 13 def contextio_secret @contextio_secret end |
#host ⇒ Object
The host provided to services for webhooks
13 14 15 |
# File 'lib/last-resort/config.rb', line 13 def host @host end |
#local_utc_offset_in_seconds ⇒ Object
The host provided to services for webhooks
13 14 15 |
# File 'lib/last-resort/config.rb', line 13 def local_utc_offset_in_seconds @local_utc_offset_in_seconds end |
#matchers ⇒ Object
The host provided to services for webhooks
13 14 15 |
# File 'lib/last-resort/config.rb', line 13 def matchers @matchers end |
#schedules ⇒ Object
The host provided to services for webhooks
13 14 15 |
# File 'lib/last-resort/config.rb', line 13 def schedules @schedules end |
#twilio_auth_token ⇒ Object
The host provided to services for webhooks
13 14 15 |
# File 'lib/last-resort/config.rb', line 13 def twilio_auth_token @twilio_auth_token end |
#twilio_sid ⇒ Object
The host provided to services for webhooks
13 14 15 |
# File 'lib/last-resort/config.rb', line 13 def twilio_sid @twilio_sid end |
Class Method Details
.populate_env_if_required ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/last-resort/config.rb', line 87 def populate_env_if_required # Check if ENV is already populated return if ENV.has_key? 'LAST_RESORT_HOST' # Raises an exception if a .env can't be found raise "No .env file found in working directory" unless File.exists? DOT_ENV_PATH # Set the environment variables open(DOT_ENV_PATH).lines.each do |line| parts = line.split('=') ENV[parts[0]] = parts[1] end end |