Module: Alman::HeadersBuilder
- Defined in:
- lib/alman/apibits/headers_builder.rb
Class Method Summary collapse
Class Method Details
.build(headers) ⇒ Object
4 5 6 7 |
# File 'lib/alman/apibits/headers_builder.rb', line 4 def self.build(headers) headers ||= {} default_headers.merge(headers) end |
.default_headers ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/alman/apibits/headers_builder.rb', line 9 def self.default_headers headers = { :user_agent => "Alman/#{Alman.api_version} RubyBindings/#{Alman::VERSION}", } begin headers.update({ :x_alman_client_user_agent => JSON.generate(user_agent) }) rescue => e headers.update({ :x_alman_client_raw_user_agent => user_agent.inspect, :error => "#{e} (#{e.class})" }) end headers end |
.get_uname ⇒ Object
40 41 42 43 44 |
# File 'lib/alman/apibits/headers_builder.rb', line 40 def self.get_uname `uname -a 2>/dev/null`.strip if RUBY_PLATFORM =~ /linux|darwin/i rescue Errno::ENOMEM => ex # couldn't create subprocess "uname lookup failed" end |
.user_agent ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/alman/apibits/headers_builder.rb', line 27 def self.user_agent lang_version = "#{RUBY_VERSION} p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})" { :bindings_version => Alman::VERSION, :lang => 'ruby', :lang_version => lang_version, :platform => RUBY_PLATFORM, :publisher => 'alman', :uname => get_uname } end |