Class: Mpql::Configuration
- Inherits:
-
Object
- Object
- Mpql::Configuration
- Defined in:
- lib/mpql/configuration.rb
Constant Summary collapse
- REGIONS =
{ "us" => "https://mixpanel.com", "eu" => "https://eu.mixpanel.com", "in" => "https://in.mixpanel.com" }.freeze
- DATA_REGIONS =
{ "us" => "https://data.mixpanel.com", "eu" => "https://data-eu.mixpanel.com", "in" => "https://data-in.mixpanel.com" }.freeze
Instance Attribute Summary collapse
-
#project_id ⇒ Object
Returns the value of attribute project_id.
-
#region ⇒ Object
Returns the value of attribute region.
-
#secret ⇒ Object
Returns the value of attribute secret.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #base_url ⇒ Object
- #data_base_url ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
21 22 23 24 25 26 27 28 29 |
# File 'lib/mpql/configuration.rb', line 21 def initialize @username = nil @secret = nil @project_id = nil @region = "us" load_config_file load_env end |
Instance Attribute Details
#project_id ⇒ Object
Returns the value of attribute project_id.
19 20 21 |
# File 'lib/mpql/configuration.rb', line 19 def project_id @project_id end |
#region ⇒ Object
Returns the value of attribute region.
19 20 21 |
# File 'lib/mpql/configuration.rb', line 19 def region @region end |
#secret ⇒ Object
Returns the value of attribute secret.
19 20 21 |
# File 'lib/mpql/configuration.rb', line 19 def secret @secret end |
#username ⇒ Object
Returns the value of attribute username.
19 20 21 |
# File 'lib/mpql/configuration.rb', line 19 def username @username end |
Instance Method Details
#base_url ⇒ Object
31 32 33 |
# File 'lib/mpql/configuration.rb', line 31 def base_url REGIONS.fetch(@region, REGIONS["us"]) end |
#data_base_url ⇒ Object
35 36 37 |
# File 'lib/mpql/configuration.rb', line 35 def data_base_url DATA_REGIONS.fetch(@region, DATA_REGIONS["us"]) end |
#validate! ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/mpql/configuration.rb', line 39 def validate! errors = [] errors << "MIXPANEL_USERNAME is not set" unless @username errors << "MIXPANEL_SECRET is not set" unless @secret errors << "project_id is not set" unless @project_id raise ConfigurationError, errors.join(", ") unless errors.empty? end |