lib/tumblr/connection.rb in tumblr_client-0.6.11 vs lib/tumblr/connection.rb in tumblr_client-0.7.0

- old
+ new

@@ -2,23 +2,28 @@ require 'faraday_middleware' require 'tumblr/request/oauth' module Tumblr module Connection + def connection(options={}) + host = api_host default_options = { :headers => { - :accept => "application/json", - :user_agent => "Tumblr v1.0" + :accept => 'application/json', + :user_agent => "tumblr_client (ruby) - #{Tumblr::VERSION}" }, - :url => "http://#{api_host}/" + :url => "http://#{host}/" } - Faraday.new("http://#{api_host}/", default_options.merge(options)) do |builder| - data = { :api_host => api_host }.merge(credentials) - builder.use Tumblr::Request::TumblrOAuth, data unless credentials.empty? + Faraday.new("http://#{host}/", default_options.merge(options)) do |builder| + data = { :api_host => host }.merge(credentials) + unless credentials.empty? + builder.use Tumblr::Request::TumblrOAuth, data + end builder.use Faraday::Request::UrlEncoded - builder.use FaradayMiddleware::ParseJson, :content_type => "application/json" + builder.use FaradayMiddleware::ParseJson, :content_type => 'application/json' builder.use Faraday::Adapter::NetHttp end end + end end