Class: Astroapi::Configuration
- Inherits:
-
Object
- Object
- Astroapi::Configuration
- Defined in:
- lib/astroapi/configuration.rb
Overview
Configuration for the Astroapi client
Defined Under Namespace
Classes: RetryConfig
Constant Summary collapse
- DEFAULT_BASE_URL =
'https://api.astrology-api.io'- DEFAULT_TIMEOUT =
10- DEFAULT_RETRY_STATUS_CODES =
[408, 425, 429, 500, 502, 503, 504].freeze
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#retry ⇒ Object
readonly
Returns the value of attribute retry.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
15 16 17 18 19 20 21 22 23 |
# File 'lib/astroapi/configuration.rb', line 15 def initialize @api_key = ENV.fetch('ASTROLOGY_API_KEY', nil) @base_url = ENV.fetch('ASTROLOGY_API_BASE_URL', DEFAULT_BASE_URL) @timeout = DEFAULT_TIMEOUT @debug = parse_boolean(ENV.fetch('ASTROLOGY_DEBUG', nil)) @logger = Logger.new($stdout) @logger.level = Logger::INFO @retry = RetryConfig.new end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
12 13 14 |
# File 'lib/astroapi/configuration.rb', line 12 def api_key @api_key end |
#base_url ⇒ Object
Returns the value of attribute base_url.
12 13 14 |
# File 'lib/astroapi/configuration.rb', line 12 def base_url @base_url end |
#debug ⇒ Object
Returns the value of attribute debug.
12 13 14 |
# File 'lib/astroapi/configuration.rb', line 12 def debug @debug end |
#logger ⇒ Object
Returns the value of attribute logger.
12 13 14 |
# File 'lib/astroapi/configuration.rb', line 12 def logger @logger end |
#retry ⇒ Object (readonly)
Returns the value of attribute retry.
13 14 15 |
# File 'lib/astroapi/configuration.rb', line 13 def retry @retry end |
#timeout ⇒ Object
Returns the value of attribute timeout.
12 13 14 |
# File 'lib/astroapi/configuration.rb', line 12 def timeout @timeout end |