mirror of
https://github.com/jnunemaker/httparty
synced 2023-03-27 23:23:07 -04:00
Mitigates Style/SpaceAfterComma
This commit is contained in:
parent
2a9683c9e7
commit
2637caa582
9 changed files with 14 additions and 14 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<Object> 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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue