httparty 0.24.3 → 0.25.1

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.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +2 -4
  3. data/Rakefile +3 -1
  4. data/bin/httparty +32 -11
  5. data/docs/README.md +39 -5
  6. data/examples/README.md +12 -23
  7. data/examples/basic.rb +2 -2
  8. data/examples/basic_auth.rb +19 -0
  9. data/examples/cookies.rb +20 -0
  10. data/examples/crack.rb +2 -2
  11. data/examples/custom_parsers.rb +2 -2
  12. data/examples/debug_output.rb +17 -0
  13. data/examples/google.rb +2 -2
  14. data/examples/headers_and_user_agents.rb +2 -2
  15. data/examples/idn.rb +4 -3
  16. data/examples/logging.rb +2 -2
  17. data/examples/nokogiri_html_parser.rb +2 -2
  18. data/examples/party_foul_mode.rb +1 -0
  19. data/examples/peer_cert.rb +2 -2
  20. data/examples/rescue_json.rb +5 -3
  21. data/examples/stackexchange.rb +2 -2
  22. data/examples/stream_download.rb +2 -2
  23. data/examples/whoismyrep.rb +2 -2
  24. data/httparty.gemspec +5 -2
  25. data/lib/httparty/connection_adapter.rb +6 -6
  26. data/lib/httparty/cookie_hash.rb +1 -1
  27. data/lib/httparty/headers_processor.rb +5 -2
  28. data/lib/httparty/logger/apache_formatter.rb +14 -1
  29. data/lib/httparty/logger/curl_formatter.rb +31 -7
  30. data/lib/httparty/logger/logger.rb +2 -1
  31. data/lib/httparty/module_inheritable_attributes.rb +13 -13
  32. data/lib/httparty/net_digest_auth.rb +9 -11
  33. data/lib/httparty/parser.rb +2 -1
  34. data/lib/httparty/request/body.rb +5 -3
  35. data/lib/httparty/request/streaming_multipart_body.rb +9 -2
  36. data/lib/httparty/request.rb +85 -25
  37. data/lib/httparty/response.rb +16 -4
  38. data/lib/httparty/text_encoder.rb +6 -6
  39. data/lib/httparty/utils.rb +1 -5
  40. data/lib/httparty/version.rb +1 -1
  41. data/lib/httparty.rb +35 -23
  42. metadata +8 -18
  43. data/.github/dependabot.yml +0 -6
  44. data/.github/workflows/ci.yml +0 -24
  45. data/.rubocop.yml +0 -92
  46. data/.rubocop_todo.yml +0 -124
  47. data/Gemfile +0 -27
  48. data/Guardfile +0 -17
  49. data/cucumber.yml +0 -1
  50. data/examples/aaws.rb +0 -36
  51. data/examples/delicious.rb +0 -37
  52. data/examples/rubyurl.rb +0 -14
  53. data/examples/tripit_sign_in.rb +0 -44
  54. data/examples/twitter.rb +0 -31
  55. data/script/release +0 -42
  56. data/website/css/common.css +0 -47
  57. data/website/index.html +0 -73
data/examples/twitter.rb DELETED
@@ -1,31 +0,0 @@
1
- dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
2
- require File.join(dir, 'httparty')
3
- require 'pp'
4
- config = YAML.load(File.read(File.join(ENV['HOME'], '.twitter')))
5
-
6
- class Twitter
7
- include HTTParty
8
- base_uri 'twitter.com'
9
-
10
- def initialize(u, p)
11
- @auth = {username: u, password: p}
12
- end
13
-
14
- # which can be :friends, :user or :public
15
- # options[:query] can be things like since, since_id, count, etc.
16
- def timeline(which = :friends, options = {})
17
- options.merge!({ basic_auth: @auth })
18
- self.class.get("/statuses/#{which}_timeline.json", options)
19
- end
20
-
21
- def post(text)
22
- options = { query: { status: text }, basic_auth: @auth }
23
- self.class.post('/statuses/update.json', options)
24
- end
25
- end
26
-
27
- twitter = Twitter.new(config['email'], config['password'])
28
- pp twitter.timeline
29
- # pp twitter.timeline(:friends, query: {since_id: 868482746})
30
- # pp twitter.timeline(:friends, query: 'since_id=868482746')
31
- # pp twitter.post('this is a test of 0.2.0')
data/script/release DELETED
@@ -1,42 +0,0 @@
1
- #!/bin/sh
2
- #/ Usage: release
3
- #/
4
- #/ Tag the version in the repo and push the gem.
5
- #/
6
-
7
- set -e
8
- cd $(dirname "$0")/..
9
-
10
- [ "$1" = "--help" -o "$1" = "-h" -o "$1" = "help" ] && {
11
- grep '^#/' <"$0"| cut -c4-
12
- exit 0
13
- }
14
-
15
- gem_name=httparty
16
-
17
- # Build a new gem archive.
18
- rm -rf $gem_name-*.gem
19
- gem build -q $gem_name.gemspec
20
-
21
- # Make sure we're on the main branch.
22
- (git branch | grep -q '* main') || {
23
- echo "Only release from the main branch."
24
- exit 1
25
- }
26
-
27
- # Figure out what version we're releasing.
28
- tag=v`ls $gem_name-*.gem | sed "s/^$gem_name-\(.*\)\.gem$/\1/"`
29
-
30
- echo "Releasing $tag"
31
-
32
- # Make sure we haven't released this version before.
33
- git fetch -t origin
34
-
35
- (git tag -l | grep -q "$tag") && {
36
- echo "Whoops, there's already a '${tag}' tag."
37
- exit 1
38
- }
39
-
40
- # Tag it and bag it.
41
- gem push $gem_name-*.gem && git tag "$tag" &&
42
- git push origin main && git push origin "$tag"
@@ -1,47 +0,0 @@
1
- @media screen, projection {
2
- /*
3
- Copyright (c) 2007, Yahoo! Inc. All rights reserved.
4
- Code licensed under the BSD License:
5
- http://developer.yahoo.net/yui/license.txt
6
- version: 2.2.0
7
- */
8
- body {font:13px arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small;}table {font-size:inherit;font:100%;}select, input, textarea {font:99% arial,helvetica,clean,sans-serif;}pre, code {font:115% monospace;*font-size:100%;}body * {line-height:1.22em;}
9
- body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}/*ol,ul {list-style:none;}*/caption,th {text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym {border:0;}
10
- /* end of yahoo reset and fonts */
11
-
12
- body {color:#333; background:#4b1a1a; line-height:1.3;}
13
- p {margin:0 0 20px;}
14
- a {color:#4b1a1a;}
15
- a:hover {text-decoration:none;}
16
- strong {font-weight:bold;}
17
- em {font-style:italics;}
18
- h1,h2,h3,h4,h5,h6 {font-weight:bold;}
19
- h1 {font-size:197%; margin:30px 0; color:#4b1a1a;}
20
- h2 {font-size:174%; margin:20px 0; color:#b8111a;}
21
- h3 {font-size:152%; margin:10px 0;}
22
- h4 {font-size:129%; margin:10px 0;}
23
- pre {background:#eee; margin:0 0 20px; padding:20px; border:1px solid #ccc; font-size:100%; overflow:auto;}
24
- code {font-size:100%; margin:0; padding:0;}
25
- ul, ol {margin:10px 0 10px 25px;}
26
- ol li {margin:0 0 10px;}
27
-
28
-
29
-
30
-
31
-
32
- div#wrapper {background:#fff; width:560px; margin:0 auto; padding:20px; border:10px solid #bc8c46; border-width:0 10px;}
33
- div#header {position:relative; border-bottom:1px dotted; margin:0 0 10px; padding:0 0 10px;}
34
- div#header p {margin:0; padding:0;}
35
- div#header h1 {margin:0; padding:0;}
36
- ul#nav {position:absolute; top:0; right:0; list-style:none; margin:0; padding:0;}
37
- ul#nav li {display:inline; padding:0 0 0 5px;}
38
- ul#nav li a {}
39
- div#content {}
40
- div#footer {margin:40px 0 0; border-top:1px dotted; padding:10px 0 0;}
41
-
42
-
43
-
44
-
45
-
46
-
47
- }
data/website/index.html DELETED
@@ -1,73 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3
- <head>
4
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
5
- <title>HTTParty by John Nunemaker</title>
6
- <link rel="stylesheet" href="css/common.css" type="text/css" />
7
- </head>
8
- <body>
9
-
10
- <div id="wrapper">
11
- <div id="header">
12
- <h1>HTTParty</h1>
13
- <p>Tonight we're gonna HTTParty like it's 1999!</p>
14
-
15
- <ul id="nav">
16
- <li><a href="rdoc/">Docs</a></li>
17
- <li><a href="http://github.com/jnunemaker/httparty">Github</a></li>
18
- <li><a href="http://rubyforge.org/projects/httparty/">Rubyforge</a></li>
19
- </ul>
20
- </div>
21
-
22
- <div id="content">
23
- <h2>Install</h2>
24
- <pre><code>$ sudo gem install httparty</code></pre>
25
-
26
- <h2>Some Quick Examples</h2>
27
-
28
- <p>The following is a simple example of wrapping Twitter's API for posting updates.</p>
29
-
30
- <pre><code>class Twitter
31
- include HTTParty
32
- base_uri 'twitter.com'
33
- basic_auth 'username', 'password'
34
- end
35
-
36
- Twitter.post('/statuses/update.json', query: {status: "It's an HTTParty and everyone is invited!"})</code></pre>
37
-
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
-
40
- <p>That works and all but what if you don't want to embed your username and password in the class? Below is an example to fix that:</p>
41
-
42
- <pre><code>class Twitter
43
- include HTTParty
44
- base_uri 'twitter.com'
45
-
46
- def initialize(u, p)
47
- @auth = {username: u, password: p}
48
- end
49
-
50
- def post(text)
51
- options = { query: {status: text}, basic_auth: @auth }
52
- self.class.post('/statuses/update.json', options)
53
- end
54
- end
55
-
56
- Twitter.new('username', 'password').post("It's an HTTParty and everyone is invited!")</code></pre>
57
-
58
- <p><strong>More Examples:</strong> There are <a href="http://github.com/jnunemaker/httparty/tree/master/examples/">several examples in the gem itself</a>.</p>
59
-
60
- <h2>Support</h2>
61
- <p>Conversations welcome in the <a href="http://groups.google.com/group/httparty-gem">google group</a> and bugs/features over at <a href="http://github.com/jnunemaker/httparty">Github</a>.</p>
62
-
63
-
64
- </div>
65
-
66
- <div id="footer">
67
- <p>Created by <a href="http://addictedtonew.com/about/">John Nunemaker</a> |
68
- <a href="http://orderedlist.com/">Hire Me at Ordered List</a></p>
69
- </div>
70
- </div>
71
-
72
- </body>
73
- </html>