Class: Pike13::Configuration
- Inherits:
-
Object
- Object
- Pike13::Configuration
- Defined in:
- lib/pike13/configuration.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#base_url ⇒ Object
Returns the value of attribute base_url.
Instance Method Summary collapse
-
#account_full_url ⇒ String
Returns the normalized account base URL Extracts the domain and port from base_url.
-
#full_url ⇒ String
Returns the normalized base URL (adds https:// if missing) Infers http:// for localhost/.test domains, https:// otherwise.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#validate! ⇒ Object
Validates the configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
7 8 9 10 |
# File 'lib/pike13/configuration.rb', line 7 def initialize @access_token = nil @base_url = "https://pike13.com" end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
5 6 7 |
# File 'lib/pike13/configuration.rb', line 5 def access_token @access_token end |
#base_url ⇒ Object
Returns the value of attribute base_url.
5 6 7 |
# File 'lib/pike13/configuration.rb', line 5 def base_url @base_url end |
Instance Method Details
#account_full_url ⇒ String
Returns the normalized account base URL Extracts the domain and port from base_url
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/pike13/configuration.rb', line 26 def account_full_url # Extract domain from base_url (strip subdomain, keep domain + port) url = base_url.to_s.sub(%r{^https?://}, "") # Extract domain and port parts = url.split(".") if parts.length >= 2 # Keep last two parts (domain.tld) plus port if exists domain_parts = parts[-2..] domain_with_port = domain_parts.join(".") else # Single part (like localhost), keep as is domain_with_port = url end "#{inferred_scheme}://#{domain_with_port}" end |
#full_url ⇒ String
Returns the normalized base URL (adds https:// if missing) Infers http:// for localhost/.test domains, https:// otherwise
16 17 18 19 20 |
# File 'lib/pike13/configuration.rb', line 16 def full_url return base_url if base_url.to_s.start_with?("http://", "https://") "#{inferred_scheme}://#{base_url}" end |
#validate! ⇒ Object
Validates the configuration
47 48 49 |
# File 'lib/pike13/configuration.rb', line 47 def validate! raise Pike13::ConfigurationError, "access_token is required" unless access_token end |