Class: Uploadcare::Internal::UserAgent

Inherits:
Object
  • Object
show all
Defined in:
lib/uploadcare/internal/user_agent.rb

Overview

User-Agent string builder for Uploadcare API requests.

Generates a standardized User-Agent header that identifies the Ruby gem version, public key, Ruby version, and optional framework information.

Examples:

Uploadcare::Internal::UserAgent.call(config: config)
# => "UploadcareRuby/5.0.0.rc1/demopublickey (Ruby/3.3.0)"

Class Method Summary collapse

Class Method Details

.call(config: Uploadcare.configuration) ⇒ String

Build a User-Agent string.

Parameters:

  • config (Uploadcare::Configuration) (defaults to: Uploadcare.configuration)

    Configuration with public key and framework data

Returns:

  • (String)

    Formatted User-Agent string



16
17
18
19
20
21
# File 'lib/uploadcare/internal/user_agent.rb', line 16

def self.call(config: Uploadcare.configuration)
  framework_data = config.framework_data.to_s
  framework_suffix = framework_data.empty? ? '' : "; #{framework_data}"
  public_key = config.public_key
  "UploadcareRuby/#{Uploadcare::VERSION}/#{public_key} (Ruby/#{RUBY_VERSION}#{framework_suffix})"
end