httparty 0.4.3 → 0.5.0
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.
- data/.gitignore +6 -0
- data/History +35 -1
- data/Manifest +1 -4
- data/README.rdoc +54 -0
- data/Rakefile +76 -48
- data/VERSION +1 -0
- data/bin/httparty +33 -22
- data/examples/basic.rb +1 -1
- data/examples/custom_parsers.rb +67 -0
- data/features/steps/env.rb +1 -0
- data/features/steps/httparty_response_steps.rb +2 -2
- data/features/steps/httparty_steps.rb +6 -2
- data/features/steps/mongrel_helper.rb +2 -1
- data/features/steps/remote_service_steps.rb +5 -0
- data/features/supports_timeout_option.feature +12 -0
- data/httparty.gemspec +100 -13
- data/lib/httparty/cookie_hash.rb +16 -3
- data/lib/httparty/core_extensions.rb +9 -3
- data/lib/httparty/exceptions.rb +5 -2
- data/lib/httparty/module_inheritable_attributes.rb +3 -3
- data/lib/httparty/parser.rb +140 -0
- data/lib/httparty/request.rb +92 -50
- data/lib/httparty/response.rb +1 -1
- data/lib/httparty/version.rb +1 -1
- data/lib/httparty.rb +110 -52
- data/spec/httparty/cookie_hash_spec.rb +43 -10
- data/spec/httparty/parser_spec.rb +154 -0
- data/spec/httparty/request_spec.rb +149 -10
- data/spec/httparty/response_spec.rb +1 -1
- data/spec/httparty_spec.rb +210 -39
- data/spec/spec.opts +1 -2
- data/spec/spec_helper.rb +7 -4
- data/website/index.html +35 -36
- metadata +81 -36
- data/README +0 -36
- data/setup.rb +0 -1585
- data/spec/hash_spec.rb +0 -49
- data/spec/string_spec.rb +0 -27
data/website/index.html
CHANGED
|
@@ -1,32 +1,31 @@
|
|
|
1
1
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
2
2
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
3
3
|
<head>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
7
|
</head>
|
|
8
8
|
<body>
|
|
9
9
|
|
|
10
10
|
<div id="wrapper">
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
<p>The following is a simple example of wrapping Twitter's API for posting updates.</p>
|
|
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>
|
|
30
29
|
|
|
31
30
|
<pre><code>class Twitter
|
|
32
31
|
include HTTParty
|
|
@@ -36,9 +35,9 @@ end
|
|
|
36
35
|
|
|
37
36
|
Twitter.post('/statuses/update.json', :query => {:status => "It's an HTTParty and everyone is invited!"})</code></pre>
|
|
38
37
|
|
|
39
|
-
|
|
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>
|
|
40
39
|
|
|
41
|
-
|
|
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>
|
|
42
41
|
|
|
43
42
|
<pre><code>class Twitter
|
|
44
43
|
include HTTParty
|
|
@@ -55,19 +54,19 @@ Twitter.post('/statuses/update.json', :query => {:status => "It's an HTTParty an
|
|
|
55
54
|
end
|
|
56
55
|
|
|
57
56
|
Twitter.new('username', 'password').post("It's an HTTParty and everyone is invited!")</code></pre>
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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>
|
|
66
65
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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>
|
|
71
70
|
</div>
|
|
72
71
|
|
|
73
72
|
</body>
|
metadata
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: httparty
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- John Nunemaker
|
|
8
|
+
- Sandro Turriate
|
|
8
9
|
autorequire:
|
|
9
10
|
bindir: bin
|
|
10
11
|
cert_chain: []
|
|
11
12
|
|
|
12
|
-
date: 2009-
|
|
13
|
-
default_executable:
|
|
13
|
+
date: 2009-12-07 00:00:00 -05:00
|
|
14
|
+
default_executable: httparty
|
|
14
15
|
dependencies:
|
|
15
16
|
- !ruby/object:Gem::Dependency
|
|
16
17
|
name: crack
|
|
@@ -23,14 +24,54 @@ dependencies:
|
|
|
23
24
|
version: 0.1.1
|
|
24
25
|
version:
|
|
25
26
|
- !ruby/object:Gem::Dependency
|
|
26
|
-
name:
|
|
27
|
+
name: activesupport
|
|
27
28
|
type: :development
|
|
28
29
|
version_requirement:
|
|
29
30
|
version_requirements: !ruby/object:Gem::Requirement
|
|
30
31
|
requirements:
|
|
31
|
-
- -
|
|
32
|
+
- - ~>
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
version: "2.3"
|
|
35
|
+
version:
|
|
36
|
+
- !ruby/object:Gem::Dependency
|
|
37
|
+
name: cucumber
|
|
38
|
+
type: :development
|
|
39
|
+
version_requirement:
|
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
+
requirements:
|
|
42
|
+
- - ~>
|
|
43
|
+
- !ruby/object:Gem::Version
|
|
44
|
+
version: "0.4"
|
|
45
|
+
version:
|
|
46
|
+
- !ruby/object:Gem::Dependency
|
|
47
|
+
name: fakeweb
|
|
48
|
+
type: :development
|
|
49
|
+
version_requirement:
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ~>
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: "1.2"
|
|
55
|
+
version:
|
|
56
|
+
- !ruby/object:Gem::Dependency
|
|
57
|
+
name: mongrel
|
|
58
|
+
type: :development
|
|
59
|
+
version_requirement:
|
|
60
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
61
|
+
requirements:
|
|
62
|
+
- - ~>
|
|
63
|
+
- !ruby/object:Gem::Version
|
|
64
|
+
version: "1.1"
|
|
65
|
+
version:
|
|
66
|
+
- !ruby/object:Gem::Dependency
|
|
67
|
+
name: rspec
|
|
68
|
+
type: :development
|
|
69
|
+
version_requirement:
|
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - "="
|
|
32
73
|
- !ruby/object:Gem::Version
|
|
33
|
-
version:
|
|
74
|
+
version: 1.2.9
|
|
34
75
|
version:
|
|
35
76
|
description: Makes http fun! Also, makes consuming restful web services dead easy.
|
|
36
77
|
email: nunemaker@gmail.com
|
|
@@ -39,21 +80,20 @@ executables:
|
|
|
39
80
|
extensions: []
|
|
40
81
|
|
|
41
82
|
extra_rdoc_files:
|
|
42
|
-
-
|
|
43
|
-
- lib/httparty/cookie_hash.rb
|
|
44
|
-
- lib/httparty/core_extensions.rb
|
|
45
|
-
- lib/httparty/exceptions.rb
|
|
46
|
-
- lib/httparty/module_inheritable_attributes.rb
|
|
47
|
-
- lib/httparty/request.rb
|
|
48
|
-
- lib/httparty/response.rb
|
|
49
|
-
- lib/httparty/version.rb
|
|
50
|
-
- lib/httparty.rb
|
|
51
|
-
- README
|
|
83
|
+
- README.rdoc
|
|
52
84
|
files:
|
|
85
|
+
- .gitignore
|
|
86
|
+
- History
|
|
87
|
+
- MIT-LICENSE
|
|
88
|
+
- Manifest
|
|
89
|
+
- README.rdoc
|
|
90
|
+
- Rakefile
|
|
91
|
+
- VERSION
|
|
53
92
|
- bin/httparty
|
|
54
93
|
- cucumber.yml
|
|
55
94
|
- examples/aaws.rb
|
|
56
95
|
- examples/basic.rb
|
|
96
|
+
- examples/custom_parsers.rb
|
|
57
97
|
- examples/delicious.rb
|
|
58
98
|
- examples/google.rb
|
|
59
99
|
- examples/rubyurl.rb
|
|
@@ -69,47 +109,39 @@ files:
|
|
|
69
109
|
- features/steps/mongrel_helper.rb
|
|
70
110
|
- features/steps/remote_service_steps.rb
|
|
71
111
|
- features/supports_redirection.feature
|
|
72
|
-
-
|
|
112
|
+
- features/supports_timeout_option.feature
|
|
73
113
|
- httparty.gemspec
|
|
114
|
+
- lib/httparty.rb
|
|
74
115
|
- lib/httparty/cookie_hash.rb
|
|
75
116
|
- lib/httparty/core_extensions.rb
|
|
76
117
|
- lib/httparty/exceptions.rb
|
|
77
118
|
- lib/httparty/module_inheritable_attributes.rb
|
|
119
|
+
- lib/httparty/parser.rb
|
|
78
120
|
- lib/httparty/request.rb
|
|
79
121
|
- lib/httparty/response.rb
|
|
80
122
|
- lib/httparty/version.rb
|
|
81
|
-
- lib/httparty.rb
|
|
82
|
-
- Manifest
|
|
83
|
-
- MIT-LICENSE
|
|
84
|
-
- Rakefile
|
|
85
|
-
- README
|
|
86
|
-
- setup.rb
|
|
87
123
|
- spec/fixtures/delicious.xml
|
|
88
124
|
- spec/fixtures/empty.xml
|
|
89
125
|
- spec/fixtures/google.html
|
|
90
126
|
- spec/fixtures/twitter.json
|
|
91
127
|
- spec/fixtures/twitter.xml
|
|
92
128
|
- spec/fixtures/undefined_method_add_node_for_nil.xml
|
|
93
|
-
- spec/hash_spec.rb
|
|
94
129
|
- spec/httparty/cookie_hash_spec.rb
|
|
130
|
+
- spec/httparty/parser_spec.rb
|
|
95
131
|
- spec/httparty/request_spec.rb
|
|
96
132
|
- spec/httparty/response_spec.rb
|
|
97
133
|
- spec/httparty_spec.rb
|
|
98
134
|
- spec/spec.opts
|
|
99
135
|
- spec/spec_helper.rb
|
|
100
|
-
- spec/string_spec.rb
|
|
101
136
|
- website/css/common.css
|
|
102
137
|
- website/index.html
|
|
103
138
|
has_rdoc: true
|
|
104
139
|
homepage: http://httparty.rubyforge.org
|
|
140
|
+
licenses: []
|
|
141
|
+
|
|
105
142
|
post_install_message: When you HTTParty, you must party hard!
|
|
106
143
|
rdoc_options:
|
|
107
|
-
- --
|
|
108
|
-
- --inline-source
|
|
109
|
-
- --title
|
|
110
|
-
- Httparty
|
|
111
|
-
- --main
|
|
112
|
-
- README
|
|
144
|
+
- --charset=UTF-8
|
|
113
145
|
require_paths:
|
|
114
146
|
- lib
|
|
115
147
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
@@ -122,14 +154,27 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
122
154
|
requirements:
|
|
123
155
|
- - ">="
|
|
124
156
|
- !ruby/object:Gem::Version
|
|
125
|
-
version: "
|
|
157
|
+
version: "0"
|
|
126
158
|
version:
|
|
127
159
|
requirements: []
|
|
128
160
|
|
|
129
161
|
rubyforge_project: httparty
|
|
130
|
-
rubygems_version: 1.3.
|
|
162
|
+
rubygems_version: 1.3.5
|
|
131
163
|
signing_key:
|
|
132
|
-
specification_version:
|
|
164
|
+
specification_version: 3
|
|
133
165
|
summary: Makes http fun! Also, makes consuming restful web services dead easy.
|
|
134
|
-
test_files:
|
|
135
|
-
|
|
166
|
+
test_files:
|
|
167
|
+
- spec/httparty/cookie_hash_spec.rb
|
|
168
|
+
- spec/httparty/parser_spec.rb
|
|
169
|
+
- spec/httparty/request_spec.rb
|
|
170
|
+
- spec/httparty/response_spec.rb
|
|
171
|
+
- spec/httparty_spec.rb
|
|
172
|
+
- spec/spec_helper.rb
|
|
173
|
+
- examples/aaws.rb
|
|
174
|
+
- examples/basic.rb
|
|
175
|
+
- examples/custom_parsers.rb
|
|
176
|
+
- examples/delicious.rb
|
|
177
|
+
- examples/google.rb
|
|
178
|
+
- examples/rubyurl.rb
|
|
179
|
+
- examples/twitter.rb
|
|
180
|
+
- examples/whoismyrep.rb
|
data/README
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
= httparty
|
|
2
|
-
|
|
3
|
-
== DESCRIPTION:
|
|
4
|
-
|
|
5
|
-
Makes http fun again!
|
|
6
|
-
|
|
7
|
-
== FEATURES:
|
|
8
|
-
|
|
9
|
-
* Easy get, post requests
|
|
10
|
-
* Basic http authentication
|
|
11
|
-
* Default request query string parameters (ie: for api keys that are needed on each request)
|
|
12
|
-
* Automatic parsing of JSON and XML into ruby hashes based on response content-type
|
|
13
|
-
|
|
14
|
-
== EXAMPLES:
|
|
15
|
-
|
|
16
|
-
See http://github.com/jnunemaker/httparty/tree/master/examples
|
|
17
|
-
|
|
18
|
-
== COMMAND LINE INTERFACE
|
|
19
|
-
|
|
20
|
-
httparty also includes the executable <tt>httparty</tt> which can be
|
|
21
|
-
used to query web services and examine the resulting output. By default
|
|
22
|
-
it will output the response as a pretty-printed Ruby object (useful for
|
|
23
|
-
grokking the structure of output). This can also be overridden to output
|
|
24
|
-
formatted XML or JSON. Execute <tt>httparty --help</tt> for all the
|
|
25
|
-
options. Below is an example of how easy it is.
|
|
26
|
-
|
|
27
|
-
httparty "http://twitter.com/statuses/public_timeline.json"
|
|
28
|
-
|
|
29
|
-
== REQUIREMENTS:
|
|
30
|
-
|
|
31
|
-
* Crack http://github.com/jnunemaker/crack/ - For XML and JSON parsing.
|
|
32
|
-
* You like to party!
|
|
33
|
-
|
|
34
|
-
== INSTALL:
|
|
35
|
-
|
|
36
|
-
* sudo gem install httparty
|