Class: Faraday::Conductivity::UserAgent
- Inherits:
-
Middleware
- Object
- Middleware
- Faraday::Conductivity::UserAgent
- Defined in:
- lib/faraday/conductivity/user_agent.rb
Instance Method Summary collapse
- #app ⇒ Object
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ UserAgent
constructor
A new instance of UserAgent.
- #ruby ⇒ Object
- #user_agent ⇒ Object
Constructor Details
#initialize(app, options = {}) ⇒ UserAgent
Returns a new instance of UserAgent.
8 9 10 11 12 13 |
# File 'lib/faraday/conductivity/user_agent.rb', line 8 def initialize(app, = {}) super(app) @name = .fetch(:app) { "Faraday" } @version = .fetch(:version) { "0.0" } @environment = .fetch(:environment) { Environment.new } end |
Instance Method Details
#app ⇒ Object
24 25 26 |
# File 'lib/faraday/conductivity/user_agent.rb', line 24 def app "#{@name}/#{@version} (#{@environment.hostname}; #{@environment.login}; #{@environment.pid})" end |
#call(env) ⇒ Object
15 16 17 18 |
# File 'lib/faraday/conductivity/user_agent.rb', line 15 def call(env) env[:request_headers]['User-Agent'] = user_agent @app.call(env) end |
#ruby ⇒ Object
28 29 30 |
# File 'lib/faraday/conductivity/user_agent.rb', line 28 def ruby "#{RUBY_ENGINE}/#{RUBY_VERSION} (#{RUBY_PATCHLEVEL}; #{RUBY_PLATFORM})" end |
#user_agent ⇒ Object
20 21 22 |
# File 'lib/faraday/conductivity/user_agent.rb', line 20 def user_agent [ app, ruby ].join(' ') end |