httparty 0.13.1 → 0.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of httparty might be problematic. Click here for more details.

Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/Guardfile +3 -3
  3. data/History +74 -11
  4. data/README.md +4 -1
  5. data/Rakefile +1 -2
  6. data/bin/httparty +4 -4
  7. data/examples/README.md +64 -0
  8. data/examples/aaws.rb +3 -3
  9. data/examples/basic.rb +5 -5
  10. data/examples/crack.rb +1 -1
  11. data/examples/delicious.rb +5 -5
  12. data/examples/headers_and_user_agents.rb +1 -1
  13. data/examples/logging.rb +38 -0
  14. data/examples/rubyurl.rb +1 -1
  15. data/examples/stackexchange.rb +1 -1
  16. data/examples/tripit_sign_in.rb +5 -5
  17. data/examples/twitter.rb +5 -5
  18. data/examples/whoismyrep.rb +1 -1
  19. data/features/steps/httparty_steps.rb +2 -2
  20. data/httparty.gemspec +2 -0
  21. data/lib/httparty.rb +35 -17
  22. data/lib/httparty/connection_adapter.rb +4 -2
  23. data/lib/httparty/cookie_hash.rb +1 -1
  24. data/lib/httparty/hash_conversions.rb +12 -12
  25. data/lib/httparty/logger/apache_logger.rb +1 -1
  26. data/lib/httparty/logger/logger.rb +1 -1
  27. data/lib/httparty/net_digest_auth.rb +4 -1
  28. data/lib/httparty/request.rb +41 -21
  29. data/lib/httparty/version.rb +1 -1
  30. data/spec/httparty/connection_adapter_spec.rb +52 -36
  31. data/spec/httparty/cookie_hash_spec.rb +8 -8
  32. data/spec/httparty/logger/apache_logger_spec.rb +29 -14
  33. data/spec/httparty/net_digest_auth_spec.rb +11 -0
  34. data/spec/httparty/parser_spec.rb +10 -10
  35. data/spec/httparty/request_spec.rb +209 -30
  36. data/spec/httparty/response_spec.rb +41 -41
  37. data/spec/httparty/ssl_spec.rb +4 -4
  38. data/spec/httparty_spec.rb +78 -59
  39. data/spec/support/ssl_test_helper.rb +6 -6
  40. data/spec/support/stub_response.rb +2 -2
  41. data/website/index.html +3 -3
  42. metadata +15 -14
  43. data/spec/spec.opts +0 -2
@@ -17,7 +17,7 @@ describe HTTParty::Request do
17
17
  end
18
18
 
19
19
  it "should work when no trusted CA list is specified, when the verify option is set to false" do
20
- ssl_verify_test(nil, nil, "selfsigned.crt", :verify => false).should == {'success' => true}
20
+ ssl_verify_test(nil, nil, "selfsigned.crt", verify: false).should == {'success' => true}
21
21
  end
22
22
 
23
23
  it "should fail when no trusted CA list is specified, with a bogus hostname, by default" do
@@ -27,7 +27,7 @@ describe HTTParty::Request do
27
27
  end
28
28
 
29
29
  it "should work when no trusted CA list is specified, even with a bogus hostname, when the verify option is set to true" do
30
- ssl_verify_test(nil, nil, "bogushost.crt", :verify => false).should == {'success' => true}
30
+ ssl_verify_test(nil, nil, "bogushost.crt", verify: false).should == {'success' => true}
31
31
  end
32
32
 
33
33
  it "should work when using ssl_ca_file with a self-signed CA" do
@@ -40,11 +40,11 @@ describe HTTParty::Request do
40
40
 
41
41
  it "should work when using ssl_ca_path with a certificate authority" do
42
42
  http = Net::HTTP.new('www.google.com', 443)
43
- response = stub(Net::HTTPResponse, :[] => '', :body => '', :to_hash => {})
43
+ response = stub(Net::HTTPResponse, :[] => '', body: '', to_hash: {})
44
44
  http.stub(:request).and_return(response)
45
45
  Net::HTTP.should_receive(:new).with('www.google.com', 443).and_return(http)
46
46
  http.should_receive(:ca_path=).with('/foo/bar')
47
- HTTParty.get('https://www.google.com', :ssl_ca_path => '/foo/bar')
47
+ HTTParty.get('https://www.google.com', ssl_ca_path: '/foo/bar')
48
48
  end
49
49
 
50
50
  it "should fail when using ssl_ca_file and the server uses an unrecognized certificate authority" do
@@ -140,8 +140,8 @@ describe HTTParty do
140
140
  describe "headers" do
141
141
  def expect_headers(header={})
142
142
  HTTParty::Request.should_receive(:new) \
143
- .with(anything, anything, hash_including({ :headers => header })) \
144
- .and_return(mock("mock response", :perform => nil))
143
+ .with(anything, anything, hash_including({ headers: header })) \
144
+ .and_return(mock("mock response", perform: nil))
145
145
  end
146
146
 
147
147
  it "should default to empty hash" do
@@ -149,46 +149,53 @@ describe HTTParty do
149
149
  end
150
150
 
151
151
  it "should be able to be updated" do
152
- init_headers = {:foo => 'bar', :baz => 'spax'}
152
+ init_headers = {foo: 'bar', baz: 'spax'}
153
153
  @klass.headers init_headers
154
154
  @klass.headers.should == init_headers
155
155
  end
156
156
 
157
157
  it "uses the class headers when sending a request" do
158
- expect_headers(:foo => 'bar')
159
- @klass.headers(:foo => 'bar')
158
+ expect_headers(foo: 'bar')
159
+ @klass.headers(foo: 'bar')
160
160
  @klass.get('')
161
161
  end
162
162
 
163
163
  it "merges class headers with request headers" do
164
- expect_headers(:baz => 'spax', :foo => 'bar')
165
- @klass.headers(:foo => 'bar')
166
- @klass.get('', :headers => {:baz => 'spax'})
164
+ expect_headers(baz: 'spax', foo: 'bar')
165
+ @klass.headers(foo: 'bar')
166
+ @klass.get('', headers: {baz: 'spax'})
167
167
  end
168
168
 
169
169
  it 'overrides class headers with request headers' do
170
- expect_headers(:baz => 'spax', :foo => 'baz')
171
- @klass.headers(:foo => 'bar')
172
- @klass.get('', :headers => {:baz => 'spax', :foo => 'baz'})
170
+ expect_headers(baz: 'spax', foo: 'baz')
171
+ @klass.headers(foo: 'bar')
172
+ @klass.get('', headers: {baz: 'spax', foo: 'baz'})
173
173
  end
174
174
 
175
175
  context "with cookies" do
176
176
  it 'utilizes the class-level cookies' do
177
- expect_headers(:foo => 'bar', 'cookie' => 'type=snickerdoodle')
178
- @klass.headers(:foo => 'bar')
179
- @klass.cookies(:type => 'snickerdoodle')
177
+ expect_headers(foo: 'bar', 'cookie' => 'type=snickerdoodle')
178
+ @klass.headers(foo: 'bar')
179
+ @klass.cookies(type: 'snickerdoodle')
180
180
  @klass.get('')
181
181
  end
182
182
 
183
183
  it 'adds cookies to the headers' do
184
- expect_headers(:foo => 'bar', 'cookie' => 'type=snickerdoodle')
185
- @klass.headers(:foo => 'bar')
186
- @klass.get('', :cookies => {:type => 'snickerdoodle'})
184
+ expect_headers(foo: 'bar', 'cookie' => 'type=snickerdoodle')
185
+ @klass.headers(foo: 'bar')
186
+ @klass.get('', cookies: {type: 'snickerdoodle'})
187
+ end
188
+
189
+ it 'doesnt modify default_options' do
190
+ @klass.headers.should == {}
191
+ expect_headers('cookie' => 'type=snickerdoodle')
192
+ @klass.get('', cookies: {type: 'snickerdoodle'})
193
+ @klass.default_options[:headers].should == {}
187
194
  end
188
195
 
189
196
  it 'adds optional cookies to the optional headers' do
190
- expect_headers(:baz => 'spax', 'cookie' => 'type=snickerdoodle')
191
- @klass.get('', :cookies => {:type => 'snickerdoodle'}, :headers => {:baz => 'spax'})
197
+ expect_headers(baz: 'spax', 'cookie' => 'type=snickerdoodle')
198
+ @klass.get('', cookies: {type: 'snickerdoodle'}, headers: {baz: 'spax'})
192
199
  end
193
200
  end
194
201
  end
@@ -196,12 +203,12 @@ describe HTTParty do
196
203
  describe "cookies" do
197
204
  def expect_cookie_header(s)
198
205
  HTTParty::Request.should_receive(:new) \
199
- .with(anything, anything, hash_including({ :headers => { "cookie" => s } })) \
200
- .and_return(mock("mock response", :perform => nil))
206
+ .with(anything, anything, hash_including({ headers: { "cookie" => s } })) \
207
+ .and_return(mock("mock response", perform: nil))
201
208
  end
202
209
 
203
210
  it "should not be in the headers by default" do
204
- HTTParty::Request.stub!(:new).and_return(stub(nil, :perform => nil))
211
+ HTTParty::Request.stub!(:new).and_return(stub(nil, perform: nil))
205
212
  @klass.get("")
206
213
  @klass.headers.keys.should_not include("cookie")
207
214
  end
@@ -214,12 +221,12 @@ describe HTTParty do
214
221
 
215
222
  it "should allow a cookie to be specified with a one-off request" do
216
223
  expect_cookie_header "type=snickerdoodle"
217
- @klass.get("", :cookies => { :type => "snickerdoodle" })
224
+ @klass.get("", cookies: { type: "snickerdoodle" })
218
225
  end
219
226
 
220
227
  describe "when a cookie is set at the class level" do
221
228
  before(:each) do
222
- @klass.cookies({ :type => "snickerdoodle" })
229
+ @klass.cookies({ type: "snickerdoodle" })
223
230
  end
224
231
 
225
232
  it "should include that cookie in the request" do
@@ -237,7 +244,7 @@ describe HTTParty do
237
244
  it "should allow the class defaults to be overridden" do
238
245
  expect_cookie_header "type=chocolate_chip"
239
246
 
240
- @klass.get("", :cookies => { :type => "chocolate_chip" })
247
+ @klass.get("", cookies: { type: "chocolate_chip" })
241
248
  end
242
249
  end
243
250
 
@@ -245,11 +252,11 @@ describe HTTParty do
245
252
  before(:each) do
246
253
  @klass.instance_eval do
247
254
  def first_method
248
- get("first_method", :cookies => { :first_method_cookie => "foo" })
255
+ get("first_method", cookies: { first_method_cookie: "foo" })
249
256
  end
250
257
 
251
258
  def second_method
252
- get("second_method", :cookies => { :second_method_cookie => "foo" })
259
+ get("second_method", cookies: { second_method_cookie: "foo" })
253
260
  end
254
261
  end
255
262
  end
@@ -270,7 +277,7 @@ describe HTTParty do
270
277
  end
271
278
 
272
279
  it "should be able to be updated" do
273
- new_defaults = {:foo => 'bar', :baz => 'spax'}
280
+ new_defaults = {foo: 'bar', baz: 'spax'}
274
281
  @klass.default_params new_defaults
275
282
  @klass.default_params.should == new_defaults
276
283
  end
@@ -307,21 +314,21 @@ describe HTTParty do
307
314
  describe "basic http authentication" do
308
315
  it "should work" do
309
316
  @klass.basic_auth 'foobar', 'secret'
310
- @klass.default_options[:basic_auth].should == {:username => 'foobar', :password => 'secret'}
317
+ @klass.default_options[:basic_auth].should == {username: 'foobar', password: 'secret'}
311
318
  end
312
319
  end
313
320
 
314
321
  describe "digest http authentication" do
315
322
  it "should work" do
316
323
  @klass.digest_auth 'foobar', 'secret'
317
- @klass.default_options[:digest_auth].should == {:username => 'foobar', :password => 'secret'}
324
+ @klass.default_options[:digest_auth].should == {username: 'foobar', password: 'secret'}
318
325
  end
319
326
  end
320
327
 
321
328
  describe "parser" do
322
329
  class CustomParser
323
330
  def self.parse(body)
324
- return {:sexy => true}
331
+ return {sexy: true}
325
332
  end
326
333
  end
327
334
 
@@ -336,7 +343,7 @@ describe HTTParty do
336
343
 
337
344
  it "should be able parse response with custom parser" do
338
345
  @klass.parser parser
339
- FakeWeb.register_uri(:get, 'http://twitter.com/statuses/public_timeline.xml', :body => 'tweets')
346
+ FakeWeb.register_uri(:get, 'http://twitter.com/statuses/public_timeline.xml', body: 'tweets')
340
347
  custom_parsed_response = @klass.get('http://twitter.com/statuses/public_timeline.xml')
341
348
  custom_parsed_response[:sexy].should == true
342
349
  end
@@ -369,7 +376,7 @@ describe HTTParty do
369
376
  end
370
377
 
371
378
  it "should set the connection_adapter_options when provided" do
372
- options = {:foo => :bar}
379
+ options = {foo: :bar}
373
380
  @klass.connection_adapter connection_adapter, options
374
381
  @klass.default_options[:connection_adapter_options].should be options
375
382
  end
@@ -380,12 +387,12 @@ describe HTTParty do
380
387
  end
381
388
 
382
389
  it "should process a request with a connection from the adapter" do
383
- connection_adapter_options = {:foo => :bar}
390
+ connection_adapter_options = {foo: :bar}
384
391
  connection_adapter.should_receive(:call) do |u,o|
385
392
  o[:connection_adapter_options].should == connection_adapter_options
386
393
  HTTParty::ConnectionAdapter.call(u,o)
387
394
  end.with(URI.parse(uri), kind_of(Hash))
388
- FakeWeb.register_uri(:get, uri, :body => 'stuff')
395
+ FakeWeb.register_uri(:get, uri, body: 'stuff')
389
396
  @klass.connection_adapter connection_adapter, connection_adapter_options
390
397
  @klass.get(uri).should == 'stuff'
391
398
  end
@@ -461,6 +468,18 @@ describe HTTParty do
461
468
  @klass.default_options[:maintain_method_across_redirects].should be_false
462
469
  end
463
470
  end
471
+
472
+ describe "#resend_on_redirect" do
473
+ it "sets resend_on_redirect to true by default" do
474
+ @klass.resend_on_redirect
475
+ @klass.default_options[:resend_on_redirect].should be_true
476
+ end
477
+
478
+ it "sets resend_on_redirect option to false" do
479
+ @klass.resend_on_redirect false
480
+ @klass.default_options[:resend_on_redirect].should be_false
481
+ end
482
+ end
464
483
 
465
484
  describe ".follow_redirects" do
466
485
  it "sets follow redirects to true by default" do
@@ -484,63 +503,63 @@ describe HTTParty do
484
503
 
485
504
  describe "with explicit override of automatic redirect handling" do
486
505
  before do
487
- @request = HTTParty::Request.new(Net::HTTP::Get, 'http://api.foo.com/v1', :format => :xml, :no_follow => true)
506
+ @request = HTTParty::Request.new(Net::HTTP::Get, 'http://api.foo.com/v1', format: :xml, no_follow: true)
488
507
  @redirect = stub_response 'first redirect', 302
489
508
  @redirect['location'] = 'http://foo.com/bar'
490
- HTTParty::Request.stub(:new => @request)
509
+ HTTParty::Request.stub(new: @request)
491
510
  end
492
511
 
493
512
  it "should fail with redirected GET" do
494
513
  lambda do
495
- @error = @klass.get('/foo', :no_follow => true)
514
+ @error = @klass.get('/foo', no_follow: true)
496
515
  end.should raise_error(HTTParty::RedirectionTooDeep) {|e| e.response.body.should == 'first redirect'}
497
516
  end
498
517
 
499
518
  it "should fail with redirected POST" do
500
519
  lambda do
501
- @klass.post('/foo', :no_follow => true)
520
+ @klass.post('/foo', no_follow: true)
502
521
  end.should raise_error(HTTParty::RedirectionTooDeep) {|e| e.response.body.should == 'first redirect'}
503
522
  end
504
523
 
505
524
  it "should fail with redirected PATCH" do
506
525
  lambda do
507
- @klass.patch('/foo', :no_follow => true)
526
+ @klass.patch('/foo', no_follow: true)
508
527
  end.should raise_error(HTTParty::RedirectionTooDeep) {|e| e.response.body.should == 'first redirect'}
509
528
  end
510
529
 
511
530
  it "should fail with redirected DELETE" do
512
531
  lambda do
513
- @klass.delete('/foo', :no_follow => true)
532
+ @klass.delete('/foo', no_follow: true)
514
533
  end.should raise_error(HTTParty::RedirectionTooDeep) {|e| e.response.body.should == 'first redirect'}
515
534
  end
516
535
 
517
536
  it "should fail with redirected MOVE" do
518
537
  lambda do
519
- @klass.move('/foo', :no_follow => true)
538
+ @klass.move('/foo', no_follow: true)
520
539
  end.should raise_error(HTTParty::RedirectionTooDeep) {|e| e.response.body.should == 'first redirect'}
521
540
  end
522
541
 
523
542
  it "should fail with redirected COPY" do
524
543
  lambda do
525
- @klass.copy('/foo', :no_follow => true)
544
+ @klass.copy('/foo', no_follow: true)
526
545
  end.should raise_error(HTTParty::RedirectionTooDeep) {|e| e.response.body.should == 'first redirect'}
527
546
  end
528
547
 
529
548
  it "should fail with redirected PUT" do
530
549
  lambda do
531
- @klass.put('/foo', :no_follow => true)
550
+ @klass.put('/foo', no_follow: true)
532
551
  end.should raise_error(HTTParty::RedirectionTooDeep) {|e| e.response.body.should == 'first redirect'}
533
552
  end
534
553
 
535
554
  it "should fail with redirected HEAD" do
536
555
  lambda do
537
- @klass.head('/foo', :no_follow => true)
556
+ @klass.head('/foo', no_follow: true)
538
557
  end.should raise_error(HTTParty::RedirectionTooDeep) {|e| e.response.body.should == 'first redirect'}
539
558
  end
540
559
 
541
560
  it "should fail with redirected OPTIONS" do
542
561
  lambda do
543
- @klass.options('/foo', :no_follow => true)
562
+ @klass.options('/foo', no_follow: true)
544
563
  end.should raise_error(HTTParty::RedirectionTooDeep) {|e| e.response.body.should == 'first redirect'}
545
564
  end
546
565
  end
@@ -549,20 +568,20 @@ describe HTTParty do
549
568
  before(:each) do
550
569
  @klass.instance_eval do
551
570
  base_uri "http://first.com"
552
- default_params :one => 1
571
+ default_params one: 1
553
572
  end
554
573
 
555
574
  @additional_klass = Class.new
556
575
  @additional_klass.instance_eval do
557
576
  include HTTParty
558
577
  base_uri "http://second.com"
559
- default_params :two => 2
578
+ default_params two: 2
560
579
  end
561
580
  end
562
581
 
563
582
  it "should not run over each others options" do
564
- @klass.default_options.should == { :base_uri => 'http://first.com', :default_params => { :one => 1 } }
565
- @additional_klass.default_options.should == { :base_uri => 'http://second.com', :default_params => { :two => 2 } }
583
+ @klass.default_options.should == { base_uri: 'http://first.com', default_params: { one: 1 } }
584
+ @additional_klass.default_options.should == { base_uri: 'http://second.com', default_params: { two: 2 } }
566
585
  end
567
586
  end
568
587
 
@@ -580,32 +599,32 @@ describe HTTParty do
580
599
  end
581
600
 
582
601
  it "does not modify each others inherited attributes" do
583
- @child1.default_params :joe => "alive"
584
- @child2.default_params :joe => "dead"
602
+ @child1.default_params joe: "alive"
603
+ @child2.default_params joe: "dead"
585
604
 
586
- @child1.default_options.should == { :default_params => {:joe => "alive"} }
587
- @child2.default_options.should == { :default_params => {:joe => "dead"} }
605
+ @child1.default_options.should == { default_params: {joe: "alive"} }
606
+ @child2.default_options.should == { default_params: {joe: "dead"} }
588
607
 
589
608
  @parent.default_options.should == { }
590
609
  end
591
610
 
592
611
  it "inherits default_options from the superclass" do
593
612
  @parent.basic_auth 'user', 'password'
594
- @child1.default_options.should == {:basic_auth => {:username => 'user', :password => 'password'}}
613
+ @child1.default_options.should == {basic_auth: {username: 'user', password: 'password'}}
595
614
  @child1.basic_auth 'u', 'p' # modifying child1 has no effect on child2
596
- @child2.default_options.should == {:basic_auth => {:username => 'user', :password => 'password'}}
615
+ @child2.default_options.should == {basic_auth: {username: 'user', password: 'password'}}
597
616
  end
598
617
 
599
618
  it "doesn't modify the parent's default options" do
600
619
  @parent.basic_auth 'user', 'password'
601
620
 
602
621
  @child1.basic_auth 'u', 'p'
603
- @child1.default_options.should == {:basic_auth => {:username => 'u', :password => 'p'}}
622
+ @child1.default_options.should == {basic_auth: {username: 'u', password: 'p'}}
604
623
 
605
624
  @child1.basic_auth 'email', 'token'
606
- @child1.default_options.should == {:basic_auth => {:username => 'email', :password => 'token'}}
625
+ @child1.default_options.should == {basic_auth: {username: 'email', password: 'token'}}
607
626
 
608
- @parent.default_options.should == {:basic_auth => {:username => 'user', :password => 'password'}}
627
+ @parent.default_options.should == {basic_auth: {username: 'user', password: 'password'}}
609
628
  end
610
629
 
611
630
  it "doesn't modify hashes in the parent's default options" do
@@ -4,8 +4,8 @@ module HTTParty
4
4
  module SSLTestHelper
5
5
  def ssl_verify_test(mode, ca_basename, server_cert_filename, options = {})
6
6
  options = {
7
- :format => :json,
8
- :timeout => 30,
7
+ format: :json,
8
+ timeout: 30,
9
9
  }.merge(options)
10
10
 
11
11
  if mode
@@ -16,8 +16,8 @@ module HTTParty
16
16
 
17
17
  begin
18
18
  test_server = SSLTestServer.new(
19
- :rsa_key => File.read(File.expand_path("../../fixtures/ssl/generated/server.key", __FILE__)),
20
- :cert => File.read(File.expand_path("../../fixtures/ssl/generated/#{server_cert_filename}", __FILE__)))
19
+ rsa_key: File.read(File.expand_path("../../fixtures/ssl/generated/server.key", __FILE__)),
20
+ cert: File.read(File.expand_path("../../fixtures/ssl/generated/#{server_cert_filename}", __FILE__)))
21
21
 
22
22
  test_server.start
23
23
 
@@ -33,8 +33,8 @@ module HTTParty
33
33
  end
34
34
 
35
35
  test_server = SSLTestServer.new({
36
- :rsa_key => path.join('server.key').read,
37
- :cert => path.join(server_cert_filename).read,
36
+ rsa_key: path.join('server.key').read,
37
+ cert: path.join(server_cert_filename).read,
38
38
  })
39
39
 
40
40
  test_server.start
@@ -7,7 +7,7 @@ module HTTParty
7
7
  response = Net::HTTPOK.new("1.1", 200, "Content for you")
8
8
  response.stub!(:body).and_return(data)
9
9
 
10
- http_request = HTTParty::Request.new(Net::HTTP::Get, 'http://localhost', :format => format)
10
+ http_request = HTTParty::Request.new(Net::HTTP::Get, 'http://localhost', format: format)
11
11
  http_request.stub_chain(:http, :request).and_return(response)
12
12
 
13
13
  HTTParty::Request.should_receive(:new).and_return(http_request)
@@ -20,7 +20,7 @@ module HTTParty
20
20
  @body || chunked_data.each(&block)
21
21
  end
22
22
 
23
- http_request = HTTParty::Request.new(Net::HTTP::Get, 'http://localhost', :format => "html")
23
+ http_request = HTTParty::Request.new(Net::HTTP::Get, 'http://localhost', format: "html")
24
24
  http_request.stub_chain(:http, :request).and_yield(response).and_return(response)
25
25
 
26
26
  HTTParty::Request.should_receive(:new).and_return(http_request)
@@ -33,7 +33,7 @@
33
33
  basic_auth 'username', 'password'
34
34
  end
35
35
 
36
- Twitter.post('/statuses/update.json', :query => {:status => "It's an HTTParty and everyone is invited!"})</code></pre>
36
+ Twitter.post('/statuses/update.json', query: {status: "It's an HTTParty and everyone is invited!"})</code></pre>
37
37
 
38
38
  <p>That is really it! The object returned is a ruby hash that is decoded from Twitter's json response. JSON parsing is used because of the .json extension in the path of the request. You can also explicitly set a format (see the examples). </p>
39
39
 
@@ -44,11 +44,11 @@ Twitter.post('/statuses/update.json', :query => {:status => "It's an HTTParty an
44
44
  base_uri 'twitter.com'
45
45
 
46
46
  def initialize(u, p)
47
- @auth = {:username => u, :password => p}
47
+ @auth = {username: u, password: p}
48
48
  end
49
49
 
50
50
  def post(text)
51
- options = { :query => {:status => text}, :basic_auth => @auth }
51
+ options = { query: {status: text}, basic_auth: @auth }
52
52
  self.class.post('/statuses/update.json', options)
53
53
  end
54
54
  end