Class: BraveSearch::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/brave_search/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



7
8
9
10
11
12
13
14
15
# File 'lib/brave_search/configuration.rb', line 7

def initialize
  @api_key = ENV.fetch("BRAVE_API_KEY", nil)
  @base_url = "https://api.search.brave.com/res/v1"
  @timeout = 30
  @retry_attempts = 3
  @storage_provider = :aws
  @storage_bucket = ENV.fetch("BRAVE_SEARCH_BUCKET", "brave-search-downloads")
  @storage_endpoint = nil
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



5
6
7
# File 'lib/brave_search/configuration.rb', line 5

def api_key
  @api_key
end

#base_urlObject

Returns the value of attribute base_url.



5
6
7
# File 'lib/brave_search/configuration.rb', line 5

def base_url
  @base_url
end

#retry_attemptsObject

Returns the value of attribute retry_attempts.



5
6
7
# File 'lib/brave_search/configuration.rb', line 5

def retry_attempts
  @retry_attempts
end

#storage_bucketObject

Returns the value of attribute storage_bucket.



5
6
7
# File 'lib/brave_search/configuration.rb', line 5

def storage_bucket
  @storage_bucket
end

#storage_endpointObject

Returns the value of attribute storage_endpoint.



5
6
7
# File 'lib/brave_search/configuration.rb', line 5

def storage_endpoint
  @storage_endpoint
end

#storage_providerObject

Returns the value of attribute storage_provider.



5
6
7
# File 'lib/brave_search/configuration.rb', line 5

def storage_provider
  @storage_provider
end

#timeoutObject

Returns the value of attribute timeout.



5
6
7
# File 'lib/brave_search/configuration.rb', line 5

def timeout
  @timeout
end

Instance Method Details

#storage(**options) ⇒ Object



17
18
19
# File 'lib/brave_search/configuration.rb', line 17

def storage(**options)
  Storage.for(storage_provider, bucket: storage_bucket, endpoint: storage_endpoint, **options)
end