diff --git a/bin/httparty b/bin/httparty index a367bb0..6098c3a 100755 --- a/bin/httparty +++ b/bin/httparty @@ -73,7 +73,7 @@ end def dump_headers(response) resp_type = Net::HTTPResponse::CODE_TO_OBJ[response.code.to_s] puts "#{response.code} #{resp_type.to_s.sub(/^Net::HTTP/, '')}" - response.headers.each do |n,v| + response.headers.each do |n, v| puts "#{n}: #{v}" end puts @@ -81,7 +81,7 @@ end if opts[:verbose] puts "#{opts[:action].to_s.upcase} #{ARGV.first}" - opts[:headers].each do |n,v| + opts[:headers].each do |n, v| puts "#{n}: #{v}" end puts diff --git a/features/steps/mongrel_helper.rb b/features/steps/mongrel_helper.rb index 8841c8e..8f6105f 100644 --- a/features/steps/mongrel_helper.rb +++ b/features/steps/mongrel_helper.rb @@ -17,7 +17,7 @@ class BasicMongrelHandler < Mongrel::HttpHandler def reply_with(response, code, response_body) response.start(code) do |head, body| head["Content-Type"] = content_type - custom_headers.each { |k,v| head[k] = v } + custom_headers.each { |k, v| head[k] = v } body.write(response_body) end end diff --git a/lib/httparty/cookie_hash.rb b/lib/httparty/cookie_hash.rb index 674696e..5d20163 100644 --- a/lib/httparty/cookie_hash.rb +++ b/lib/httparty/cookie_hash.rb @@ -8,7 +8,7 @@ class HTTParty::CookieHash < Hash #:nodoc: merge!(value) when String value.split('; ').each do |cookie| - array = cookie.split('=',2) + array = cookie.split('=', 2) self[array[0].to_sym] = array[1] end else diff --git a/lib/httparty/hash_conversions.rb b/lib/httparty/hash_conversions.rb index 23c632d..cecaa1f 100644 --- a/lib/httparty/hash_conversions.rb +++ b/lib/httparty/hash_conversions.rb @@ -12,7 +12,7 @@ module HTTParty # }.to_params # #=> "name=Bob&address[city]=Ruby Central&address[phones][]=111-111-1111&address[phones][]=222-222-2222&address[street]=111 Ruby Ave." def self.to_params(hash) - hash.to_hash.map { |k,v| normalize_param(k,v) }.join.chop + hash.to_hash.map { |k, v| normalize_param(k, v) }.join.chop end # @param key The key for the param. @@ -28,7 +28,7 @@ module HTTParty if value.respond_to?(:to_ary) param << value.to_ary.map { |element| normalize_param("#{key}[]", element) }.join elsif value.respond_to?(:to_hash) - stack << [key,value.to_hash] + stack << [key, value.to_hash] else param << "#{key}=#{ERB::Util.url_encode(value.to_s)}&" end diff --git a/lib/httparty/response.rb b/lib/httparty/response.rb index b041683..8e8a55e 100644 --- a/lib/httparty/response.rb +++ b/lib/httparty/response.rb @@ -1,7 +1,7 @@ module HTTParty class Response < BasicObject def self.underscore(string) - string.gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').gsub(/([a-z])([A-Z])/,'\1_\2').downcase + string.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').gsub(/([a-z])([A-Z])/, '\1_\2').downcase end attr_reader :request, :response, :body, :headers diff --git a/spec/httparty/request_spec.rb b/spec/httparty/request_spec.rb index 12794d9..8b8650c 100644 --- a/spec/httparty/request_spec.rb +++ b/spec/httparty/request_spec.rb @@ -338,9 +338,9 @@ RSpec.describe HTTParty::Request do end it 'should handle csv automatically' do - csv = ['"id","Name"','"1234","Foo Bar!"'].join("\n") + csv = ['"id","Name"', '"1234","Foo Bar!"'].join("\n") @request.options[:format] = :csv - expect(@request.send(:parse_response, csv)).to eq([%w(id Name),["1234","Foo Bar!"]]) + expect(@request.send(:parse_response, csv)).to eq([%w(id Name), ["1234", "Foo Bar!"]]) end it 'should handle json automatically' do diff --git a/spec/httparty_spec.rb b/spec/httparty_spec.rb index e692d10..2e0d623 100644 --- a/spec/httparty_spec.rb +++ b/spec/httparty_spec.rb @@ -373,9 +373,9 @@ RSpec.describe HTTParty do it "should process a request with a connection from the adapter" do connection_adapter_options = {foo: :bar} - expect(connection_adapter).to receive(:call) { |u,o| + expect(connection_adapter).to receive(:call) { |u, o| expect(o[:connection_adapter_options]).to eq(connection_adapter_options) - HTTParty::ConnectionAdapter.call(u,o) + HTTParty::ConnectionAdapter.call(u, o) }.with(URI.parse(uri), kind_of(Hash)) FakeWeb.register_uri(:get, uri, body: 'stuff') @klass.connection_adapter connection_adapter, connection_adapter_options @@ -737,7 +737,7 @@ RSpec.describe HTTParty do profile = HTTParty.get('http://twitter.com/statuses/profile.csv') expect(profile.size).to eq(2) expect(profile[0]).to eq(%w(name url id description protected screen_name followers_count profile_image_url location)) - expect(profile[1]).to eq(["Magic 8 Bot",nil,"17656026","ask me a question","false","magic8bot","90","http://s3.amazonaws.com/twitter_production/profile_images/65565851/8ball_large_normal.jpg",nil]) + expect(profile[1]).to eq(["Magic 8 Bot", nil, "17656026", "ask me a question", "false", "magic8bot", "90", "http://s3.amazonaws.com/twitter_production/profile_images/65565851/8ball_large_normal.jpg", nil]) end it "should not get undefined method add_node for nil class for the following xml" do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ca1e160..8b18fd0 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -9,7 +9,7 @@ def file_fixture(filename) open(File.join(File.dirname(__FILE__), 'fixtures', "#{filename.to_s}")).read end -Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f} +Dir[File.expand_path(File.join(File.dirname(__FILE__), 'support', '**', '*.rb'))].each {|f| require f} RSpec.configure do |config| config.include HTTParty::StubResponse diff --git a/spec/support/ssl_test_server.rb b/spec/support/ssl_test_server.rb index de038a7..17ec3a7 100644 --- a/spec/support/ssl_test_server.rb +++ b/spec/support/ssl_test_server.rb @@ -49,7 +49,7 @@ class SSLTestServer def thread_main until @stopping_mutex.synchronize { @stopping } - (rr,_,_) = select([@ssl_server.to_io], nil, nil, 0.1) + (rr, _, _) = select([@ssl_server.to_io], nil, nil, 0.1) next unless rr && rr.include?(@ssl_server.to_io)