Class: Ecfr::Configuration
- Inherits:
-
Object
- Object
- Ecfr::Configuration
- Defined in:
- lib/ecfr/configuration.rb
Overview
Provides configuration of various aspects of the gem
Defined Under Namespace
Classes: MissingGem, MissingUserAgent
Constant Summary collapse
- CONFIG_DEFAULTS =
{ base_url: "https://www.ecfr.gov", ofr_profile_service_base_url: "https://www.federalregister.gov/my/profile", # service url overrides admin_service_url: nil, admin_service_path: nil, diff_service_url: nil, diff_service_path: nil, ofr_profile_service_url: nil, ofr_profile_service_path: nil, prince_xml_service_url: nil, prince_xml_service_path: nil, renderer_service_url: nil, renderer_service_path: nil, search_service_url: nil, search_service_path: nil, subscriptions_service_url: nil, subscriptions_service_path: nil, varnish_cache_service_url: nil, varnish_cache_service_path: nil, versioner_service_url: nil, versioner_service_path: nil, # basic auth - some endpoints require auth ecfr_basic_auth_username: nil, ecfr_basic_auth_password: nil, # request modification request_hook: ->(req) { req }, user_agent: nil, # client modifications timeout: 10, open_timeout: 1, prince_xml_service_pdf_timeout: 10, # response modification log_http_requests: false, logger: nil, logger_options: {}, # caching cache_responses: false }
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
51 52 53 54 55 |
# File 'lib/ecfr/configuration.rb', line 51 def initialize CONFIG_DEFAULTS.each do |k, v| instance_variable_set("@#{k}", v) end end |
Instance Method Details
#validate! ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/ecfr/configuration.rb', line 57 def validate! raise MissingUserAgent, "A user agent must be provided" if user_agent.blank? if cache_responses begin Gem::Specification.find_by_name("request_store") rescue Gem::LoadError raise MissingGem, "the RequestStore gem must be installed if response caching is enabled" end end end |