Skip to content

Commit

Permalink
Make base_uri mandatory and custom user_agent (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
tagliala authored Jan 17, 2025
1 parent 173126c commit ee8445a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions lib/colore/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,16 @@ def self.uri_parser
# Constructor.
#
# @param base_uri [String] The base URI of the Colore service that you wish to attach to
# @param app [String] The name of your application (all documents will be stored under this name)
# @param logger [Logger] An optional logger, which will log all requests and responses
# @param backtrace [Bool] Used for debugging purposes, to extract backtraces from Colore
def initialize(app:, base_uri: 'http://localhost:9240/', logger: Logger.new(nil), backtrace: false)
# @param app [String] The name of your application. All documents will be stored under this name
# @param logger [Logger] An optional logger, which will log all requests and responses. Defaults to `Logger.new(nil)`
# @param backtrace [Bool] Used for debugging purposes, to extract backtraces from Colore. Defaults to `false`
# @param user_agent [String] User Agent header that will be sent to Colore. Defaults to `Colore Client`
def initialize(app:, base_uri:, logger: Logger.new(nil), backtrace: false, user_agent: 'Colore Client')
@base_uri = base_uri
@app = app
@backtrace = backtrace
@logger = logger
@connection = Faraday.new(headers: { 'User-Agent' => "Colore Client #{Colore::Client::VERSION} (#{app})" })
@connection = Faraday.new(headers: { 'User-Agent' => user_agent })
end

# Generates a document id that is reasonably guaranteed to be unique for your app.
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/colore/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'spec_helper'

RSpec.describe Colore::Client, :vcr do
let(:client) { described_class.new app: 'client_test' }
let(:client) { described_class.new app: 'client_test', base_uri: 'http://localhost:9240/' }
let(:filename) { fixture('quickfox.jpg') }

describe '.generate_doc_id' do
Expand Down

0 comments on commit ee8445a

Please sign in to comment.